voyent
dataPaginator remaining on the same page even after navigation  XML
Forum Index -> Components
Author Message
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hi there!
I don't know if this is a bug or another feature :), but I get this kind of undesired behavior:
I have a dataTable with a dataPaginator. I go for example to the third page of results. I navigate then to a completely different page (another .faces page). Then, if I navigate back to the first page, the one with the dataTable, the dataPaginator brings me back to that third page of results instead of the first one. While this would be desirable if I stay on the same .faces page, it is totally undesirable after a navigation to a different one and coming back.

I hope I was clear enough :)
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,

So, if what you want to do is reset the state of the datePaginator when renavigating to the page I think you could try using request-scoped beans or manually resetting the dataPaginator. To manually reset the paginator you'll need to bind the component:

<ice:dataPaginator ...binding="#{bean.paginator}"...

Then on the navigation action either away from or to page (whatever's easier your you) you can call:

paginator.goToFirstPage();

Philip>

.
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Hi philip!
Well ... the bean is in request scope (I checked and constructor is called for every new access to the page).
I added the dataPaginator binding and in the setDataPaginator of the bean I put the following lines
Code:
 		System.out.println("The main bean = " + this);
 		System.out.println("Data paginator = " + dataPaginator);
 


Now I go into my application, I go to this page ... I navigate (through a link) to a different page and then again through a link I come back to this page.
Th results are funny:
Code:
 The main bean = xxx.xxxxx.xxxxx.BlaBlaBlaBean@19a82ee
 Data paginator = com.icesoft.faces.component.datapaginator.DataPaginator@1609872
 
 The main bean = xxx.xxxxx.xxxxx.BlaBlaBlaBean@dd0099
 Data paginator = com.icesoft.faces.component.datapaginator.DataPaginator@1609872
 

So..... My bean is indeed in request scope ... but the dataPaginator, although it was binded to this request scoped bean ... is actually reused.
I don't know weather this is a good or a bad thing, but since I navigate to this page from a different one ... I don't know where to hook that gotoFirstPage call.
1. During bean constructor the dataPaginator is still null ...
2. The dataTable's value list is read for each page of results ... so putting the gotoFirstPage here would block me on the first page of results ...
3. During the setDataPaginator .. the dataTable is not initialised yet ... so I can't go to the first page ....
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Update:

After some trace through the getDataPagintor / setDataPaginator methods (from my bean) I came to the following conclusion:
the dataPaginator si created (or read from the bean) only once during the first parsing of my xhtml page (so during the construction of the component tree). This is the only time the getDataPaginator is called.

On the subsequent navigations to his page the request bean is recreated, but the dataPaginator created earlier is reused and only the setDataPaginator is called (everytime with the same DataPaginator object).

I don't know if this is a bug or was designed to be like that ... but I wished it had same lifespan as the main bean (that is request scope).
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


Update:
One little workaround I found would be as follows:
1. The Beans should be in request scope
2. Bind the DataPaginator to this bean through a field "private DataPaginator dataPaginator;", it's get/set methods and "binding" element in the xhtml file.
3. add a field "private boolean shouldGotoFirstPage = true;" to this bean
4. In the method where you return the list populating the dataTable add the lines
Code:
 		if (shouldGotoFirstPage) {
 			shouldGotoFirstPage = false;
 			getDataPaginator().gotoFirstPage();
 		}

In this way, the shouldGotoFirstPage is set to true on each navigation to this page (the bean is in request scope, remember) and set to false for all the subsequent calls to getXxxxList .....
Well ... that should be all!
I repeat ... it's a workaround.
In my opinion the dataPaginator should have the same scope as the bean to which it is binded.
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Have you tried setting concurrentDOMViews to true?

Philip

.
edykory


Joined: 27/Nov/2006 00:00:00
Messages: 332
Offline


No i haven't. We don't need the concurrentDOM facility and I was thinking we could save some bandwidth and server memory by deactivating it. Was I wrong?
Anyway ... I'll give it a try.
Could you please tell me what's the cost of turning the concurrent DOM on?
Thanx a lot
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


pre-1.6 we have a memory leak with request-scoped beans with ConcurrentDOMViews turned off. This has been been fixed in 1.6 Beta. So, once you get your hands on the beta, probably no cost at all.

Philip

.
qzett

Joined: 29/Oct/2007 00:00:00
Messages: 11
Offline


doesnt work with com.icesoft.faces.concurrentDOMViews = true
 
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team