Hello there!
I'm writing a GWT api for use in my web applications, and one of the
problems I'm running into is an inability to distinguish between user
input on the address bar and the back and forward buttons.
I've got only a little over 1000 LOC written, so I'm not opposed to
scrapping the client code entirely and starting over. I'll just
explain the gist of the problem I'm trying to invent a solution to, in
light of what I want the API to be, and we'll see where we can get.
If you don't want the setup (so that you understand more clearly _why_
I'm asking) skip to the bottom, just beneath the second set of
asterisks.
*******************************************
First, let me introduce a small abstract class:
package org.codingventures.blog.client;
import java.util.Map;
public abstract class BlogWidget {
public abstract void addWidgetToRootPanel();
public abstract boolean isTokenRelated(String token);
}
I want another class, let's call it ClientHistoryHandler, which
implements ValueChangeHandler and which I can make any number of.
Each ClientHistoryHandler has a list of BlogWidget's which it simply
loops through (in the onValueChange method), and does something like:
if(widget.isTokenRelated(token) widget.addWidgetToRootPanel(); for
each widget. You would add these ClientHistoryHandler's to the
History class.
I want a single static method, something like
ClientHistoryListener.update(String token), which is the proper way
for calling History.newItem(String token).
Finally, there should be a an abstract StateHandler class, which the
API user should implement, which does the initial setup (of tokens, or
state data gathered from the server). It should provide a method
called validateToken(String token), which should take a questionable
token from the address bar, evaluate it, and spit out the closest
valid token it can find (or you could just have it redirect your user
to the home page - whatever).
The problem comes with identifying those key words: questionable
tokens. How do I do that? I've got a mechanism now which clearly
differentiates between things which call ClientHistoryHandler.update
(), and things that have just simply called History.newItem(), but
it's not robust: I need a clear way to know the source of a url
change so that I can handle it appropriately.
****************************************************
Here's how I'd like it to work:
User enters a URL: new token is removed from the current history
without reloading elements on the page, token is evaluated by the
developer's StateHandler's validateToken() method, and
ClientHistoryHandler.update() is called with a proper token.
User hits back or forward or triggers a change through page
interaction (button, link, etc): token is assumed to be correct and
ClientHistoryHandler.update() is called immediately.
Right now I can differentiate between browser and page interactions,
but I need to treat the back and forward buttons as if they were page
interactions. How can I do this?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---