jsf 2 - How to display a html tag if JSF conditon is true? -
i want display <span>lorem ipsum</span>
if backing-bean value not empty.
<h:outputtext rendered="#{not empty pubcontroller.location}"> <span>lorem ipsum</span> </h:outputtext>
the lorem ipsum never display. apparently, doesn't work if remove not in condition.
fyi: before run h:outputtext, print boolean statements. prints expect. true values not empty. also, rendered-condition works h:form tag expect it. looks h:outputtext inappropriate in case, it?
is there better approach using h:outputtext want do?
this can't work because h:outputtext
doesn't accept child elements stated in documentation:
if element has children, must ignored default. implementions may provide configuration option allows element render children.
trying following code should solve problem:
<h:outputtext value="lorem ipsum" rendered="#{not empty pubcontroller.location}"/>
note following:
<h:panelgroup rendered="#{not empty pubcontroller.location}"> <span>lorem ipsum</span> </h:panelgroup>
that useful if need display more complicated structure simple span
element.
Comments
Post a Comment