在標籤如直接看到內部的功能,如果兩次會更容易理解我的問題,這個問題變的styleClass屬性裏面:調用JSF標籤
<h:outputText value="#{prod.actualStock}"
styleClass="
#{productBean.getSeverity(prod.actualStock, prod.replacementAlertLevel).equals('INFO') ?
'severity-info' : productBean.getSeverity(prod.actualStock, prod.replacementAlertLevel).equals('WARN') ?
'severity-warn' : 'severity-danger'}" />
現在,請注意,我調用兩個乘以'getSeverity()'函數,三次返回中的每一次都爲outputText提供了不同的樣式類。只有保持相同的邏輯才能調用函數嗎?
''標籤放在表格中。
當然,對不起。需要清除我的思想!哈哈。謝謝! –
您應該將業務邏輯與表示邏輯分開。從託管bean設置CSS值不是一個好的解決方案。它應該有一個屬性來處理嚴重性值並在JSF代碼中進行比較。 –