MyFaces seems to be ignoring my call to getStateHelper.put() in this component:
public class BFTableComponent extends UINamingContainer {
...
private void setCurrentPageNumber(int currentPageNumber) {
getStateHelper().put(PropertyKeys.currentPageNumber, currentPageNumber);
}
public int getCurrentPageNumber() {
return (Integer) getStateHelper().eval(PropertyKeys.currentPageNumber, 0);
}
public void nextPage() {
setCurrentPageNumber(getCurrentPageNumber() + 1);
updateCurrentPage();
}
public void previousPage() {
setCurrentPageNumber(getCurrentPageNumber() - 1);
updateCurrentPage();
}
...
}
As you can see, when the frontend component calls nextPage, the goal is to advance the page number by one. However, when running this in MyFaces, the eval() call will work for the immediate request lifecycle, but the next request, it will return 0. If I put null instead of 0, I gett an NPE.
The pageNumber state needs to carry for the lifetime of the component, not just the current request. What am I doing wrong? This code runs fine under Mojarra, but not in MyFaces.