How do I insert non breaking space character   in a JSF page?

JsfFacelets

Jsf Problem Overview


How do I insert a non breaking space character in JSF page like I can in HTML using  ? Is there such a tag in JSF?

Jsf Solutions


Solution 1 - Jsf

this will work

<h:outputText value="&#160;" />

Solution 2 - Jsf

Putting the HTML number directly did the trick for me:

&#160;

Solution 3 - Jsf

If your using the RichFaces library you can also use the tag rich:spacer which will add an "invisible" image with a given length and height. Usually much easier and prettier than to add tons of nbsp;.

Where you want your space to show you simply add:

<rich:spacer height="1" width="2" />

Solution 4 - Jsf

You can also use primefaces <p:spacer width="10" height="10" />

Solution 5 - Jsf

Eventually, you can try this one, if just using &nbsp; fails...

<h:outputText value="& nbsp;" escape="false"/>

(like Tom, I added a space between & and nbsp; )

Solution 6 - Jsf

The easiest way is:

<h:outputText value=" " />

Solution 7 - Jsf

I found that the parser would complain if I used the &nbsp; entity in my page. After a little research, I learned that if I added a DOCTYPE declaration to the beginning of the page, the entity was allowed. I use this DOCTYPE declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

A side effect of this is that the resulting code (as seen by using the "view source" feature of a web browser) doesn't actually contain the &nbsp; entity. It instead includes the actual characters that represent a nonbreaking space. Although it works, it's not really what I want. I'm still looking for a way to make the parser not replace the entity with the character.

More information here: http://java.net/jira/browse/JAVASERVERFACES-1576

Solution 8 - Jsf

You can use primefaces library

 <p:spacer width="10" />

Solution 9 - Jsf

just to add to options: <h:outputText value="&amp;nbsp;" escape="false"/> worked

Solution 10 - Jsf

Not necessary to give 160 . 141 will also work. For the value field provide value="" .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSureshView Question on Stackoverflow
Solution 1 - JsfMadhuView Answer on Stackoverflow
Solution 2 - JsfluistamawongView Answer on Stackoverflow
Solution 3 - JsfChris DaleView Answer on Stackoverflow
Solution 4 - JsfihebihebView Answer on Stackoverflow
Solution 5 - JsfRomain LinsolasView Answer on Stackoverflow
Solution 6 - JsfDarkoView Answer on Stackoverflow
Solution 7 - JsfMr. Lance E SloanView Answer on Stackoverflow
Solution 8 - JsfMohamed Aymen CharradaView Answer on Stackoverflow
Solution 9 - JsfscorppView Answer on Stackoverflow
Solution 10 - JsfPratik RoyView Answer on Stackoverflow