I'm trying break line in <h:outputText />
value.
I simply put a <br>
in my value as HTML theory. But it doesn't work and a page error show up.
When I removed the <br/>
. It works again properly.
My code is:
<h:outputText value="[#{order.product.code}] #{order.product.name} <br/> #{order.qty}"/>
I tried another way.
<h:outputText value="[#{order.product.code}] #{order.product.name} 
 #{order.qty}"/>
No change at all.
Use <
for <
& >
for >
, then make your html tag.
Like:
<br /> - For <br />
Then you have to tell the renderer not to escape html tag, place escape= "false"
attribute inside <h:outputText />
.
According to your requirement try this,
Sample code:
<h:outputText value="value-one <br /> value-two <br /> value-three" escape="false" />
Output:
value-one
value-two
value-three
Why exactly do you need <h:outputText>
? You don't seem to taking benefit of any of its additional features on top of plain EL in template text.
Just get rid of it and write it like so:
[#{order.product.code}] #{order.product.name} <br/> #{order.qty}
Note that this is not possible in legacy JSP, but given that you're using PrimeFaces, which doesn't have a JSP compatible tag library (JSP is deprecated >4 years ago), then you should surely be using Facelets.
You can use multiple h:outputTex
tags with < br />
tags inbetween. Try the following:
<h:outputText value="[#{order.product.code}]"/>
<br/>
<h:outputText value="#{order.product.name}"/>
<br/>
<h:outputText value="#{order.qty}"/>
UPDATE:
Or use escape="false"
:
<h:outputText value="[#{order.product.code}]<br />#{order.product.name}<br />#{order.qty}" escape="false" />
Thank you so much everyone..! Especially @Wanna coffee and @hurleytom. Your codes really work.
<h:outputText value="[#{order.product.code}]<br />#{order.product.name}<br />#{order.qty}" escape="false" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With