Hej Arun,

I believe everything you need is in my first post.

//Adam

On 28 Apr, 06:27, Arun <arun.r...@gmail.com> wrote:
> Hi Adam,
>
> I would looking for similar solution, Could you please show here how
> to do it?
>
> It would be a great help.
>
> Arun.
>
> On Apr 26, 11:19 am, Adam T <adam.t...@gmail.com> wrote:
>
> > have you implemented the onHistoryChanged(String token) method?  In
> > have to rebuild the state yourself based on the token as it's not done
> > automatically.  I think you may also need to slightly refactor the
> > code to gethistoryworking as you want.  I would most likely have the
> > following:
>
> > In your class definition tell it your are implementing the GWThistory
> > code:
>
> > public class MyClass implements EntryPoint, ValueChangeHandler<String>
> > {....}
>
> > In the onModuleLoad method, link into theHistory:
>
> > public void onModuleLoad(){
> >                 .....
> >                 // Add 'this' as the change handler
> >                History.addValueChangeHandler(this);
> >                 // Run the handler for the first time in case user has
> > come in to application with a URL containing ahistorytoken
> >                History.fireCurrentHistoryState();
>
> > }
>
> > then you have the onHistoryChanged method you would handle thehistory
> > token in the URL - in this case I'm guessing you would have a token
> > for page 2 which indicates you want to display page 2 and if there's
> > no token, then display page 1:
>
> > public void onHistoryChanged(String token){
> >    if (token.equals(PAGE_TWO_TOKEN){
> >           rootpanel.get("foo").clear();
> >           rootpanel.get("foo").add(new page2());
> >    } else {
> >           rootpanel.get("foo").clear();
> >           rootpanel.get("foo").add(new page1());
> >    }
>
> > }
>
> > THen, in you button handler you would just set the token instead of
> > trying to create the page two, i.e.
>
> > onButtonClick(){
> >    // Add token and allow value change event to be fired - the change
> > is the picked up by thehistorysubsystem in the onHistoryChange
> > method and new page shown
> >    History.newItem(PAGE_TWO_TOKEN, true);
>
> > }
>
> > (don't forget to keep thehistoryiframe, created when you create an
> > application, in your html code frhistoryto work in some browsers)
>
> > Hope that helps in some way!
>
> > //Adam
>
> > On 25 Apr, 21:10, mrfreeze81 <mrfreez...@gmail.com> wrote:
>
> > > Hi,
> > >   I'm implementing a code using GWT. I want to implementhistoryusing
> > > ValueChangeHandler. This is a feature in the new 1.6 version of GWT.
> > > This is how my application looks for now
>
> > > I have a new class for every page I want to create. i.e page1.java and
> > > page2.java each of which extents Composite.
> > > On module load, I assign page1 to rootpanel.
> > > When a button is clicked on page1 i navigate to page2 by
>
> > > onClickButton ( ) {
> > >     rootpanel.get("foo").clear();
> > >     rootpanel.get("foo").add(new page2());
>
> > > }
>
> > > I have added page1's state to thehistoryHistory.nextItem
> > > (page1state);
>
> > > I have also added implements ValueChangeHandler to Page1.java class. I
> > > don't have a separatehistoryhandler and so I do
> > >History.addValueChangeHandler(this);
>
> > > What do I do to the unimplemented onValueChange() method in my page1
> > > class. And where do I fire the inital state?
> > >History.fireCurrentHistoryState(); ???
>
> > > Also, when I am in the second page (page2), and hit refresh, it loads
> > > back the first page and not the current state, even if my token reads
> > > the next state.
>
> > > Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to