开发者

Question on whitespaces in h:outputText and h:inputText [duplicate]

This question already has an answer here: h:outputText seems to trim whitespace, 开发者_StackOverflow社区how do I preserve whitespace? (1 answer) Closed 7 years ago.

I am getting issue somthing h:outputText and h:inputText both are displaying values but they are collapse the multiple whitespaces into single white space

for that i tried with style="white-space:pre" but it also not working

so i am adding   in between strings

String str="hi & nbsp jsf"

and

<h:inputtext value="#{bean.str}">

while displaying it shows in input text box with value "hi & nbsp ;jsf" not "hi jsf" So, what should i have to do so that that it will display without "& nbsp;"

actually i have put that space between & nbsp; because here it will replaceing with white space

I don't want <h:outputText> with escape="false" for displaying because at some place i need h:inputText. In h:inputText there is no option for escape attribute

any other permanent solution for white Space Issue


I had the same problem and through trial and error was able to get around it by adding a style to my outputText:

<h:outputText style="white-space:pre;" value="My Text Here"/>

I hope this helps!


the white spaces from outputText are there if you look at the source code.

it sounds like you do not want to escape   but you want to escape everything else, which you cant. you cant have the cookie and eat it too.

sounds like this is a ui problem that you should handle with html/css

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜