Friday, January 21, 2011

Re: do you think RangeChange of CellTable should update the History Token ?

Thomas, I tried your suggestion, about using CachedActivityMapper.

CachingActivityMapper cached = new CachingActivityMapper(mainActivitiesMapper);
ActivityManager mainActivityManager = new ActivityManager(cached, eventBus);

However, the Activity is still getting restarted,
(i put a log message in start method as well as the constructor,
 and I can see them, everytime i go to a new page of the result set)

my employeeList places are like below:

employee/list 
employee/list/p2
employee/list/p3

p2 = second page of the result set, pageNumber = 2

public class EmployeeListPlace(String name, int pageNumber)

my equals/hashcode method, use name and pageNumber.
as a result, EmployeeListPlace("list", 1) is different than EmployeeListPlace("list", 2);
and they are interpreted differently.

Threfore CachingActivityMapper will treat these two places as two distinct places,
and start method is called, as i go from .../p2 to .../p3

then what is the benefit of using CachingActivityMapper in this case ?

how can CachingActivityMapper treat these two places the same, when they are in fact different ?
(different pageNumber field).
I replaced equals/hashcode with one that uses only the name, but I could not make a place transition,
the token remained the same, and no data was being shown (that celltable loading bar kept showing forever).

however, the approach I outlined,
0- user navigates to employee/list
1- ActivityFactory uses EmployeeListActivityProvider to get hold of EmployeeListActivity
employeeListActivity = employeeListActivityProvider.get(); //normal provider, NOT SINGLETON

2- ActivityFactory sets the pageNumber field on this EmployeeListActivity, and gives it to a "normal" ActivityMapper
 employeeList.setPageNumber(employeeListPlace.getPageNumber());

3- EmployeeListActivity is started, uses pageNumber and Max_Result_Per_Page , to display first page of result set. (setRowData...)
4- when user clicks on Table Pager, onRangeChanged is called on CellTable, and EmployeeListActivity uses this Range
to figure out the next placeNumber, and calls placeController.goTo(new EmployeeListPlace("list", nextPage).

5- ActivityMapper will see this as a new Place (how can it not ? different nextPage), finds the ActivityFactory,
and back to step 1

EmployeeListActivity gets started over and over again, and it works.


what is wrong with this approach ?

based on GWT philosophy, Activities are supposed to be throwaways, right ?
so is it expensive to start/stop an Activity over and over again ? will there be a performance problem ?

and why your suggestion on using CachingActivityMapper did not work ?
if I override equal/hashcode to not take pageNumber into account,
as user clicks on Pager, we remain in the same place, the history token doesnt change,
it would be the same as not integrating celltable with place at all.

what I am doing wrong : (

Thank You

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate