# Including spaces/html entities in JSF component output.

Posted

Rather a silly problem but a problem nevertheless, including html entities as spaces special charactes etc… causes them to be escaped by the jsf.

So something like getSpacedName(){return "Hello   world";} will be outputed in the pages exactly as we have entered in out method above. On regulat h:outputText we can use ‘escape’ attribute and set it to false and get what we desire but with other components that output a dropdown or something where formating is in need thats not possible.

Solution is to use the Unicode characters

getSpacedName(){ String space = "\u00a0"; return String.format("Hello%s%s%%sworld",space, space, space); }

I know that we should not be doing crazy things like this in our backingbeans but when you have to you have to.

1. Artem says:

Thank you.