h:outputText line break for long words within strings

后端 未结 5 1291
小蘑菇
小蘑菇 2020-12-30 06:12

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

相关标签:
5条回答
  • 2020-12-30 06:23

    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"  />
    
    0 讨论(0)
  • 2020-12-30 06:25

    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

    0 讨论(0)
  • 2020-12-30 06:33

    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.

    0 讨论(0)
  • 2020-12-30 06:45
     <h:outputText value="Very Wordy&lt;br /&gt;Table Column&lt;br /&gt;Heading" escape="false" />  
    

    Output

    Very Wordy
    Table Column
    Heading
    
    0 讨论(0)
  • 2020-12-30 06:46

    Set CSS word-wrap property of the element in question to break-word.

    <h:outputText styleClass="someClass" />
    

    with

    .someClass {
        word-wrap: break-word;
    }
    
    0 讨论(0)
提交回复
热议问题