Question

I have an <h:inputText> field in my JSF page and I registered an entity with the name having double whitespace in it.

Example:

Black  Coffee

The problem is when the page is re-rendered and the program makes a comparison between the value in the text field and the value in the entity. When it's re-rendered, the double whitespace is turned into a singular whitespace.

Example before:

Black  Coffee

After:

Black Coffee

Do someone have any idea in how to solve it? I read something about using the <pre> tag but I found it useless to me since it seems to work only to <h:outputText>.

Was it helpful?

Solution

What is supposed to work here is set a style="white-space: pre" in your tag. So <h:inputText style="white-space: pre" value="#{bean.data}" />

But that said, I have varying results with this. One page I have, you get the input with the extra spaces not showing but when you refresh the page suddenly they are there. And it's the same in all browsers (Well IE, Chrome and FF.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top