css - Force linebreak OutputLabel -


i have outputlabel contains lot of text (about 5000 characters of text), outputlabel has add new line after line 200px, possible?

<p:outputlabel value="#{object.body}" /> <p:outputlabel value="#{object.body}" style="width: 200px" /> 

this code doesn't work:

public string getbodywithlinebreaks(){     return body.replaceall("(.{100})", "$1<br/>"); } 

it not solution because method not if word finished, starts new line @ 100th character.

some more code:

<p:datatable id="datatable" var="object" value="#{notificationoverview.objects}">       <!--some more columns...-->        <p:rowexpansion>           <h:panelgrid id="display" columns="2" cellpadding="4" style="width:300px;"                                                    styleclass=" ui-widget-content grid">           <f:facet name="header">notification information</f:facet>         <h:outputtext value="sender:"/>         <h:outputtext value="#{object.sender.username}"/>          <h:outputtext value="time send:"/>         <h:outputtext value="#{object.datesend}">             <f:convertdatetime pattern="yyyy-mm-dd hh:mm:ss"/>         </h:outputtext>     <h:outputtext value="title:"/>    <h:outputtext value="#{object.title}"/> </h:panelgrid>  <br/><br/>  <div style='width: 200px;'>    <h:outputtext value="#{object.body}" /> </div> </p:rowexpansion> </p:datatable> 

the <p:outputlabel> generates html <label> element default inline element. can't set dimensions of inline element. can set on block element.

one way adding display: block style.

<p:outputlabel value="#{object.body}" style="display: block; width: 200px;" /> 

additionally, given inside <p:datatable> cell, has default css white-space property set nowrap, need set normal. can set on same component, preferably set on parent <p:column> itself:

<p:column style="white-space: normal;"> 

note: part of practice, should prefer styleclass on style.


unrelated concrete problem, html <label> element designed label input element identified for attribute. i.e. when click on it, associated input element retrieves focus (and checkbox/radiobutton selected). when validation performed, label used identify input element. however, fact you're trying display 5000 characters inside label element, user unfriendly when used real label, suggests you're abusing label wrong purpose of displaying "plain text". should using <h:outputtext> instead. generates html <span> element default inline element. above answer applies on well:

<h:outputtext value="#{object.body}" style="display: block; width: 200px;" /> 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -