I have a check box
in my application and I want to call selectPlan method to execute when user select the check box
But when ever I select the check box
it call the @PostConstruct
method before the selectPlan method.
This leads to unwanted calls to back end as I have written some functions to populate data when page load in the @PostConstruct
<td>
<h:selectBooleanCheckbox value="#{plan.checked}">
<f:ajax listener="#{planOverlay.selectPlan}" render=":overlayForm:myTable"/>
</h:selectBooleanCheckbox>
</td>
Below is the bean class
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean(name = "planOverlay")
@ViewScoped
public class PlanOverlayBean extends OverlayBean {
@PostConstruct
public void init() {
super.init();
loadPlansFrom_DB();
}
public void selectPlan(AjaxBehaviorEvent event) throws Exception {
getOverlay().getService().setSelectedPlan(rowdata);
}
}