Is there a way to tell h:outputText
of JSF (2.0) to insert a line break (or even better: A custom string like \"-\") into very long words within strings?
My pro
you can use h:inputTextarea rather than h:outputText , don't remember set readonly attribute true and remove border like this:
<h:inputTextarea rows="10" cols="50" readonly="true" value="multiline String" style="border-color: white" />
if you have very long word in String you can use word-break: break-all;
like this:
<h:outputText value="111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" style="word-break: break-all;"/>
but it required CSS3. link: word-break
This can be accomplished by two steps
1)Apply style as table-layout:fixed to the panelGrid
E.g: <h:panelGrid style="table-layout:fixed;">
2) Then apply style of word-wrap break-word to the <h:outputText />
as below.
E.g: <h:outputText style="word-wrap:break-word;">
Hope this helps.
<h:outputText value="Very Wordy<br />Table Column<br />Heading" escape="false" />
Output
Very Wordy
Table Column
Heading
Set CSS word-wrap property of the element in question to break-word
.
<h:outputText styleClass="someClass" />
with
.someClass {
word-wrap: break-word;
}