[英]JSF/RichFaces: conditional text styling
I have a string which can be yes or no, instantiated in an object in a Java backing bean. 我有一个可以是yes或no的字符串,在Java辅助bean的对象中实例化。 I can't seem to find the best way to conditionally style the text red or green dependent on whether the JSF gets yes or no from the bean respectively.
我似乎无法找到有条件地将文本设置为红色或绿色的最佳方式,这取决于JSF是否分别从bean获得yes或no。 I'm using richfaces, but should I be using
<c:if>
tags? 我正在使用richfaces,但我应该使用
<c:if>
标签吗?
(in order of preference): (按优先顺序排列):
style="color: #{yourVar == 'yes' ? 'green' : 'red'};"
<h:outputText>
components with different styles, each with a different rendered
attribute (one #{yourVar == 'yes'}
and the other #{yourVar == 'no'}
) <h:outputText>
组件,每个组件具有不同的rendered
属性(一个#{yourVar == 'yes'}
,另一个#{yourVar == 'no'}
) styleClass="#{my:getStyleClass(yourVar)}"
styleClass="#{my:getStyleClass(yourVar)}"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.