here is my situation in short.
I have page with datatable and few buttons backed by bean. Bean should be initialized with some default properties. That properties can be changed depending on action. I started with RequestScoped bean and @PostConstruct annotated method. but it seems that datatable works well only with View(Session)scoped. Now my setup look like this:
@ManagedBean
@ViewScoped
public class ProductsTableBean implements Serializable {
private LazyDataModel<Products> productsData;
@Inject
private ProductsFacade model;
public void onPageLoad() {
// here some defaults are set
// ...
System.err.println("onPageLoad called");
}
public void addRow() {
// andhere some defaults redefined
// ...
System.err.println("addRow called");
}
...
and snippet from jsf page:
<p:commandButton action="#{productsTableBean.addRow()}"
title="save"
update="@form" process="@form" >
</p:commandButton>
...
<f:metadata>
<f:event type="preRenderView" listener="#{productsTableBean.onPageLoad}"/>
</f:metadata>
And here is the main problem arise in calling order, i have following output:
onPageLoad called
addRow called
onPageLoad called <-- :(
But i want addRow to be the last action to be called, like this:
onPageLoad called
addRow called
Any simple solution here ?