0

First of all: not native english speaker here, so sorry if I may sound a little confusing sometimes.

I'm looking for a way to persist a DataTable (that shows a query result list) state when I navigate through different views in my application (so it's not an Ajax call), in other words: I need to render a new page with a DataTable exactly as it was in the previous view. First thing you should know about this is that I have a way to transport objects through my views using ELFlash.getFlash().put(param, obj), so my problem is not recovering objects.

I was able to make the DataTable open with all the previous result list with no problems... BUT it has a paginator and I was supposed to get to the second view not only with the query results but also opened in the same page that it was before.

I already tried to keep the current page number in an object and put a code to change the paginator to that page in the post construct, but it didn't work:

DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent(":form:dataTable");
String javaScript = "PF('widgetVarName').getPaginator().setPage(" + this.pageNumber + ")";
RequestContext.getCurrentInstance().execute(javaScript);

The saddest thing here is that It didn't work in post construct and the DataTable doesn't open in the right page, but if I call this code in another button, after the page is already rendered, it works.

Do you guys have any ideia?

Denis Klein
  • 101
  • 1
  • 11
  • I have never tried this, but maybe you can bind (`binding` atribute ) the table to a SessionScoped bean – SJuan76 Apr 15 '16 at 12:24
  • @SJuan76: nope, http://stackoverflow.com/q/14911158 – BalusC Apr 15 '16 at 12:45
  • I'm not allowed by the project architect to change the scope of my managed beans anyway... that's why I'm using ELFlash to transport my objects through views. I'd need another solution - if there is any. – Denis Klein Apr 15 '16 at 12:52
  • Do you guys think there is anyway that I use this DataTable object and make my new view be rendered setting this object as the reference of the new DataTable? That is something that I thought, but I couldn't find a way to do it... (and I have no idea that it would work in my PostConstruct either) – Denis Klein Apr 15 '16 at 12:56

0 Answers0