Insert new line in a backing bean string value

孤人 提交于 2020-02-02 10:06:50

问题


How to insert a new line between words for a backing bean value and display it on UI using JSF 2.0 framework? If we have address. The street name should be in first line and city and state should be in the second line. I am using a converter to add new line. But it does not show up on the UI.


回答1:


JSF is basically a HTML code generator. A new line is in HTML to be presented by the <br /> tag, not by \r\n characters or something. You can just do it straight in the view instead of mingling view-specific details in the managed bean or a converter.

<h:outputText value="#{user.address.street} #{user.address.houseNumber}" />
<br />
<h:outputText value="#{user.address.city}, #{user.address.state}" />


来源:https://stackoverflow.com/questions/7853790/insert-new-line-in-a-backing-bean-string-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!