Fixed: How to remember the DataTable state and still use buttons
Lets say that you have a DataTable on a page, with a bunch of hyper links and buttons on the same page (for navigation to various parts of your application). If you use the built in pagination and sorting, you will find that the following behaviour:
1. DataTable remembers its state (sorting, page number, etc.) if you click on any hyper link. You can even go back to a different page, and then come back to the original page to find that your DataTable is in the state you left it (very cool, it is session scope and works as intended).
2. If you click on any button, DataTable does not remember its previous state (goes back to page 1 and default worting, etc.). After playing around with it and going nuts, I discovered the way to use Button and still have the DataTable remember its state. I wanted to share it with the rest of you:
public String btnClose_action(){
try{
this.getExternalContext().redirect("faces/users.jsp");
}catch (Exception ex){
log("Error: userDetail > btnClose_action", ex);
}
returnnull;
}
This was my original post:
http://swforum.sun.com/jive/thread.jspa?threadID=103583
Message was edited by:
Sabir

