This is my snipped part of xhtml. I have on condition changing styleClass.
`<p:panel id="upload_host" header="CIB HOST" styleClass="#{(bulkToHostBean.titleBackground == 'true') ? 'greencolor' : 'redcolor'}">`
Below is my bean class file. The main purpose of this class file is to return boolean true or false.
@ManagedBean
@SessionScoped
public class BulkToHostBean {
......
private boolean titleBackground;
public boolean getTitleBackground() {
int counter = 0;
for(int i = 0; i < hostList.size();i++ ) {
if(hostList.get(i).getFile_status().trim().equals(Constant.DELAYED)) {
counter = counter + 1;
}
}
//counter = 0;
if(counter == 0) {
logger.info("Set title background to Green");
titleBackground = true;
}else {
logger.info("Set title background to DarkRed");
titleBackground = false;
}
return titleBackground;
}
public void setTitleBackground(boolean titleBackground) {
this.titleBackground = titleBackground;
}
And below is my console result from my eclipse. As you can see, the result printed twice at the same time.
Sep 13, 2017 5:00:50 PM
com.sheaf.payment.dashboard.managedbeans.BulkToHostBean getTitleBackground
INFO: Set title background to DarkRed
Sep 13, 2017 5:00:50 PM
com.sheaf.payment.dashboard.managedbeans.BulkToHostBean getTitleBackground
INFO: Set title background to DarkRed
The code is working fine but I just wonder why it call method two times? Any idea why it call two times?