Search code examples
gwtgwt-rpcgwt-mvp

GWT: RPC and MVP and Place Tokenizer


I'm just starting off on my first attempt at the MVP architecture in GWT.

My understanding is that the job of PlaceTokenizer.getPlace(String) is to take the token in the URL after the hash, parse it, and return a Place with the object to which that token refers.

In my application, I have a resource (say, a video), which I tokenize by the video's unique id. Then my getPlace method ought to take this id, and retrieve the video information from the server. Is this the right approach?

As far as how to execute this, the only way that I could figure out would be to have my RemoteService right on the PlaceTokenizer, and make the call right in that getPlace method. Something about this made me hesitate. It seems like the call would be better suited for the Activity or somewhere else.

Is this how it's done? If not, is there a better way?


Solution

  • Your Place doesn't need to download the video. It could just contain the video's id.

    Your Activity will receive the Place, which has the video id, and now the Activity can do the downloading or whatever heavy lifting you want.

    So: Your PlaceTokenizer only needs to know enough to store the video id in the Place. Let the Activity do the work after that. The only function of getPlace is to turn a String into a Place.

    It helped me to mentally rename Place to PlaceTag. The place objects really do not represent places - they represent tags or pointers to places. The actual place is represented by, terribly, the Activity.