i would recommend the following approach,
in your AppEntry/ main class define the HistoryMapper something similar to
the following
//default place
final Place defaultPlace = new Home(userName);
// Start PlaceHistoryHandler with our PlaceHistoryMapper
AppPlaceHistoryMapper historyMapper=
GWT.create(AppPlaceHistoryMapper.class);
PlaceHistoryHandler historyHandler = new
PlaceHistoryHandler(historyMapper);
historyHandler.register(placeController, eventBus, defaultPlace);
// Goes to the place represented on URL else default place
historyHandler.handleCurrentHistory();
here i am considering the following as my distinct places Home, Accounts,
Search
My AppPlaceHistoryMapper is defined as below
@WithTokenizers(value = { Home.Tokenizer.class , Accounts.Tokenizer.class,
Search.Tokenizer.class})
public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {
}
lets just look at my home place
public class Home extends Place {
private String helloName;
public Home(String token) {
super();
if (null != token)
this.helloName = token;
else
this.helloName = "GUEST"; //guest user
}
public String getHelloName() {
return helloName;
}
public static class Tokenizer implements PlaceTokenizer<Home> {
@Override
public Home getPlace(String token) {
return new Home(token);
}
@Override
public String getToken(Home helloPlace) {
return helloPlace.getHelloName();
}
}
}
lets assume my view has a tablayoutpanel and each of my first tab is the
home place and second tab is the accounts place
on click of the tab, make your view forward the request to the delegate. The
delegate would determine which tab was selected, now if its a tab the
delegate does not handle or determines its a place change event then it
throws a placeControllder.goTo(new Accounts()); //issue a place change event
You have to define an ActivityMapper for your application
public final class AppMasterActivities implements ActivityMapper {
private ApplicationRequestFactory requests;
private PlaceController placeController;
@Inject
public AppMasterActivities(ApplicationRequestFactory requests,
PlaceController placeController) {
this.requests = requests;
this.placeController = placeController;
}
@Override
public Activity getActivity(Place place) {
if (place instanceof Home) {
//call home activity or which ever activity would
render your home tab
return new HomeActivity(requests, placeController);
}
else if(place instanceof Accounts) {
//call accounts activity
return new AccountsActivity(requests,
placeController)
}
}
Now , you place is mapped to activities and history through the above
definitions.
When you move between tabs history mapping would automatically happen and
the corresponding activities would be invoked and pages fetched.
Regards
Ashwin
On Tue, Jul 19, 2011 at 8:56 AM, Mark Wengranowski
<[email protected]>wrote:
> OK, so i have that working properly now but im stuck on configuring
> browser history. How can i make it so that each of my tabs has their
> own browser history so that when i flip to a different tab it will
> change to it's previous page without affecting the others.
>
> For testing purposes i created a second variable of the following:
>
> EventBus eventBus = clientFactory.getEventBus();
> EventBus eventBus1 = clientFactory.getEventBus1();
>
>
> PlaceController placeControllerTab1 =
> clientFactory.getPlaceControllerTab1();
> PlaceController placeControllerTab2 =
> clientFactory.getPlaceControllerTab2();
>
> PlaceHistoryHandler historyHandlerTab1 = new
> PlaceHistoryHandler(historyMapper);
> PlaceHistoryHandler historyHandlerTab2 = new
> PlaceHistoryHandler(historyMapper);
>
> historyHandlerTab1.register(placeControllerTab1,
> eventBus, defaultPlace);
> historyHandlerTab2.register(placeControllerTab2,
> eventBus1, defaultPlace);
>
> I keep track of which tab is currently selcted and utilize the
> variables depending on the selected index of the tab. for example when
> the second tab is selected the 2 variables are used. doing this still
> combines all the browser history together no matter what tab is
> selected. Is there something im missing?
>
>
> thanks,
> -Mark
>
> On Jul 18, 10:39 am, "[email protected]"
> <[email protected]> wrote:
> > render to the content inside your tab panel. ie. each tab panel has a
> header
> > (for rendering the tabs) and a content area. your view should expose the
> > content area as a widget. Your activity should render to this widget
> >
> > On Mon, Jul 18, 2011 at 11:06 PM, Mark Wengranowski <
> [email protected]
> >
> >
> >
> > > wrote:
> > > Thanks! Should i be using the content panel that contains the tab
> > > panel or should i somehow create content panels and activity mappers
> > > for each tab panel.
> >
> > > On Jul 18, 10:30 am, "[email protected]"
> > > <[email protected]> wrote:
> > > > Mark,
> >
> > > > I think you should be able to achieve it using places. Try to have an
> > > > additional property in your place, lets say location which would tell
> you
> > > > which tab the user clicked. Now pass this value to the activity/
> Delegate
> > > > which drives your view. Based on the location render the contents.
> >
> > > > Regards
> > > > Ashwin
> >
> > > > On Mon, Jul 18, 2011 at 10:50 PM, Mark Wengranowski <
> > > [email protected]
> >
> > > > > wrote:
> > > > > Hi Everyone, im looking for suggestions on the best way to
> implement
> > > > > places in the following scenario.
> >
> > > > > I have a main content container which contains a dynamic tab tanel:
> > > > > i.e. you can have have up to 3 tabs open at once with different
> pages
> > > > > in each, tabs can be closed/opened.
> >
> > > > > When i use the goto(place newplace) call it navigates away from my
> > > > > current place (dynamic tabs) and loads the new place. This is
> normally
> > > > > how you would want things to happen.
> >
> > > > > What i want to happen is that instead of navigating away from the
> > > > > current place of the main content window, the tab which is in focus
> > > > > will navigate to the new place. Can this be done with places so
> that i
> > > > > can take advantage of browser history? Ideally when the goto()
> > > > > function is called i'd like to insert some custom logic that
> controls
> > > > > the tabs
> >
> > > > > Thanks,
> > > > > -Mark
> >
> > > > > --
> > > > > 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.-Hidequoted
> > > text -
> >
> > > > - Show quoted text -
> >
> > > --
> > > 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.- Hide quoted
> text -
> >
> > - Show quoted text -
>
> --
> 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.
>
>
--
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.