Will appreciate your help resolving following issues (JBoss 6.0, Mojarra - 2.2 Snapshot, facelet 1.1 and PrimeFaces 3.0.M4:
Problem is, the request bean's post construct method gets called before getting the value set. How can we make sure the parameter value on a session bean gets set first and then the request bean's post construct method is called.
Issue #1: When clicked on "Next", which is an ajax call 1. testRequestBB's "initialize" post construct method is called 2. testSessionBB's "next" method is called to set the value
Expected behavior should be other way around, set the value in session bean with ajax call and then request bean should be initialized.
Issue #2: The request bean's "initialize" post construct method is called twice.
- Is it because the request bean gets extended from the base class (though no post construct method in the base class).
What can be done to fix this issue of getting post construct method called two times when test.xhtml page is displayed?
Here is the code:
test.xhtml
<h:dataTable id="testId" emptyMessage="#{messages.noData}" var="test" value="#{testList}">
....
<f:facet name="footer">
<h:form id="pgId">
<h:commandLink value="#{messages.next} ">
<f:ajax listener="#{testSessionBB.next}" />
</h:commandLink>
.....
</h:form>
</f:facet>
</h:dataTable>
TestSessionBB.java
@Named("testSessionBB")
@SessionScoped
public class TestSessionBB implements Serializable
{
private int testStartRow;
.....
public String next()
{
if (this.getTestStartRow() + 5 > 15) // hard coded value for simplicity in this post
{
this.setTestStartRow(15);
} else {
this.setTestStartRow(this.getTestStartRow() + 5);
}
log.debug("next - testStartRow: " + this.getTestStartRow());
return "";
}
}
TestRequestBB.java
@Named
@RequestScoped
public class TestRequestBB extends testBase implements Serializable {
....
@PostConstruct
public void initialize()
{
log.debug("Initializing TestRequestBB backing bean ...");
setTestList(allTests()); // load initial list containing 5 rows of test data
log.debug("Initializing TestRequestBB backing bean done ...");
}
@Produces
@Named
public List<Test> getTestList()
{
return super.getTestList();
}
....
}
TestBase.java
public abstract class TestBase implements Serializable {
..... (contains all common code shared by other classes extending this base class)
// does not contain any @PostConstruct method
}