Question

Im using Mojarra 2.1.3, Netbeans 7.0.1, primefaces 3.2.

I am currently in a quandary whether to use STATE_SAVING_METHOD client or server. Currently Im setting the saving method to client. And this involves me doing adjustment to seriazibility of many objects. And putting transient keyword on the stateless facade session beans.

@ManagedBean
@ViewScoped
public class SaProductController implements Serializable {
@EJB
transient SaProductFacade saProductFacade;
@EJB
transient SaKeywordFacade saKeywordFacade;
....

My xhtml page has a primefaces dataTable with pagination. The first time loading the page it works by showing the first page in the datatable. However, upon clicking on next page, this lines throws a NullPointerException error.

data = saProductFacade.selectAll(first, pageSize);

Why is that? Is it because saProductFacade @EJB property declared as transient and it's destroyed on postback to the same page. The ViewScoped managed bean is still alive anyway. Please help, how to solve this issue? Or am I doing it wrong?

For information, this works perfectly if I set the STATE_SAVING_METHOD to server. But the peril of the browser back button made me decide to go the client state saving option. And also, memory limitation on the server is warranting client state saving.

Was it helpful?

Solution

Just for information, for beginners, Im using server state saving method now. And I use session variables to remember where am I if user press on back button. This way the ViewScoped backing bean is recreated and automatically paginate to the page where the user last viewed. So that I can redirect the user to where their last datatable page was before they navigate to another page using GET HTTP request.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top