how to calculate cell values of B column and how to change their css style dynamically

my java object :
public class MyObject{
private Date date;
private int A;
private int C;
//Getters & Setters
}
my managed bean :
public class MyBean(){
List<MyObject> List = myObjectDao.FindAll();
//Getters & Setters
}
my jsf code :
<p:dataTable id="idList" var="list" value="#{myBean.list}" >
<p:column headerText="DATE">
<h:outputText value="#{list.date}" />
</p:column>
<p:column headerText="A">
<h:outputText value="#{list.A}" />
</p:column>
<p:column headerText="B">
<h:outputText value="????????" style="???????" //>
</p:column>
<p:column headerText="C">
<h:outputText value="#{list.C} />
</p:column>
</p:dataTable>
You can just use the conditional operator
?:in EL.E.g.
If
Bis also used elsewhere in the model or controller, then you could add apublic int getB()method which just containsreturn (A/C) * 100;and then use#{list.B}instead of#{B}.Note that proper design is to use a CSS class instead. E.g.
with
You can of course also perform the determination of CSS style/class in a getter method as suggested by the other answer, but that’s a poor separation of concerns.