Hi I am using rich:dataTable bound to a list of beans. I have a column value where I have a choice between it being negative or positive number. If it is negative I want (RED TEXT) and if its positive just render as usual. I have tired several different methods to get this choice working including wrapping the column itself in the c:when/c:otherwise, as shown here
<c:choose> <c:when test="#{position.mtmNegative == true}"> <rich:column id="mtmCol" style="text-align:right; color: red" label="#{msg['PositionKeeper.MTM']}"> <f:facet name="header"> <h:outputText value="#{msg['PositionKeeper.MTM']}" style="font-weight:bold;"/> </f:facet> <h:outputText value="#{position.pnlSnap}"><f:convertNumber pattern="(###,###,###,##0.00)"/></h:outputText> </rich:column> </c:when> <c:otherwise> <rich:column id="mtmCol" style="text-align:right;" label="#{msg['PositionKeeper.MTM']}"> <f:facet name="header"> <h:outputText value="#{msg['PositionKeeper.MTM']}" style="font-weight:bold;"/> </f:facet> <h:outputText value="#{position.pnlSnap}"><f:convertNumber pattern="###,###,###,##0.00"/></h:outputText> </rich:column> </c:otherwise> </c:choose>
<rich:column id="amountCol" style="text-align:right;" label="#{msg['PositionKeeper.AMOUNT']}"> <f:facet name="header"> <h:outputText value="#{msg['PositionKeeper.AMOUNT']}" style="font-weight:bold;"/> </f:facet> <c:choose> <c:when test="#{position.amtNegative == true}"> <h:outputText value="#{position.ccySnap}" style="color: red"><f:convertNumber pattern="(###,###,###,##0.00)"/></h:outputText> </c:when> <c:otherwise> <h:outputText value="#{position.ccySnap}"><f:convertNumber pattern="###,###,###,##0.00"/></h:outputText> </c:otherwise> </c:choose> </rich:column>
Hi,
You can use "rendered" attribute and remove c:when/c:choose:
<h:outputText rendered="#{position.amtNegative}" value="#{position.ccySnap}" style="color: red"><f:convertNumber pattern="(###,###,###,##0.00)"/></h:outputText>