Thank you Thomas.

from your comments:

1- "But this is what CachingActivityMapper does it the Place passed to it 
equals() the previous one."

2- "Because your Activity instance spans many places, it can listen to 
PlaceChangeEvent-s and thus be kept inform of the place change without being 
restarted, and therefore update its data with the page number from the new 
place."

are these two different solutions, or they need to be used together ?
1 AND 2 , or 1 OR 2 ?
do I need to use CachingActivityMapper together with listening on 
PlaceChangeEvents, or need to choose only one of the two?

and what happens if when navigating to a different page of result,the 
Activity just get started/stopped everytime.
what is the downside to the Activity being started over and over ? this 
Activity uses RF to get the Result and populate a CellTable in a view.
if we use an ActivityProvider in Singleton scope, this Provider gives us the 
Activity, and we set PageNumber on the Activity,
as a result, the Activity can use this page number, in its 
RequestFactory.findEmployeeEntries(start, length)
and use this page number on CellTable setRowData. 

What is wrong with this approach ?


//our Main ActivityMapper 
public class MainActivityMapper implements ActivityMapper { 

Provider<ListEmployeeActivity> listEmployeeActivityProvider; // bound in 
Singleton scope

Activity getActivity(Place place){ 

      if(place instanceof ListEmployeePlace){ 
                ListEmployeePlace listPlace = (ListEmployeePlace) place;   
               
                ListEmployeeActivity  listEmployeeActivity = 
listEmployeeActivityProvider.get(); 
                listEmployeeActivity.setRangeStart( 
listPlace.getPageNumber());
                 
               return listEmployeeActivity;
        }
} 

} 



//ListEmployeeActivity

public class ListEmployeeActivity extends AbstractActivity {

private int rangeStart;

    public int getRangeStart() {
        return rangeStart;
    }

    public void setRangeStart(int rangeStart) {
        this.rangeStart = rangeStart;
    }

// RequestFactory, PlaceController 
public EmployeeListActivity(EmployeeListView view,
                                         PlaceController placeController,
                                         RequestFactory requestFactory)
rangeChangeHandler = getView().asHasData()
                .addRangeChangeHandler(
                        new RangeChangeEvent.Handler() {
                            public void onRangeChange(RangeChangeEvent 
event) {
                                
EmployeeListActivity.this.onRangeChanged(getView().asHasData());
                            }
                        });
//RF,place controller initialization

}
public void start(final AcceptsOneWidget display, EventBus eventBus){

requestFactory
                .employeeRequest()
                .findEmployeeEntries(getRangeStart(), MAX_RESULTS_PER_PAGE)
                .fire(new Receiver<List<EmployeeProxy>>() {
                    @Override
                    public void onSuccess(List<EmployeeProxy> response) {
                        if (view == null) {
                            // This activity is dead
                            return;
                        }
                        getView().asHasData()
                                .setRowData(getRangeStart(), response);
                        if (display != null) {
                            display.setWidget(getView());
                        }
                    }
                });

}

 public void onRangeChanged(HasData<EmployeeProxy> listView) {
        final Range range = listView.getVisibleRange();
        placeController.goTo(new EmployeeListPlace(range.getStart()));

}


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

Reply via email to