GWT MVP Development with Activities and Places

141 views
Skip to first unread message

MBKG

unread,
Nov 12, 2010, 2:58:36 AM11/12/10
to Google Web Toolkit
I read the article:
http://code.google.com/webtoolkit/doc/latest/DevGuideMvpActivitiesAndPlaces.html

Quote:"Many Places in your app might not save any state to the URL, so
they could just extend a BasicPlace which declares a PlaceTokenizer
that returns a null token."

Where can I find BasicPlace?

David Chandler

unread,
Nov 12, 2010, 12:12:25 PM11/12/10
to google-we...@googlegroups.com
Here you go:

import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceTokenizer;


public class BasicPlace extends Place {
public class BasicPlaceTokenizer implements PlaceTokenizer
{
// Instance of a BasicPlace that will be returned
// for a null token
private BasicPlace place;

// Init this tokenizer with a subclass of BasicPlace
public BasicPlaceTokenizer(BasicPlace basicPlace) {
this.place = basicPlace;
}

@Override
public Place getPlace(String token) {
return this.place;
}

@Override
public String getToken(Place place) {
// BasicPlaces have no state so we can always
// return null. By default, GWT creates a
// URL containing the class name of the Place
// so we don't have to worry about that part.
return null;
}
}
}

Along with this, you'll have to use a TokenizerFactory which provides
a method to obtain the BasicPlaceTokenizer for each sub-class,
something like this:

PlaceTokenizer<MyBasicPlaceSubclass> getMySubclassPlaceTokenizer()
{
return new BasicPlaceTokenizer(new MyBasicPlaceSubclass());
}

In retrospect, BasicPlace likely doesn't buy you much. It's probably
just as easy to create a PlaceTokenizer for each Place in your app as
shown in the article.

/dmc

> --
> 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-we...@googlegroups.com.
> To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

--
David Chandler
Developer Programs Engineer, Google Web Toolkit
http://googlewebtoolkit.blogspot.com/

MBKG

unread,
Nov 12, 2010, 10:22:49 PM11/12/10
to Google Web Toolkit
Thanks David.
My 2 cents:
If user can go back (URL history) when using BasicPlace?
Could you give a full small example?
Thanks in advance.

On 13 Tháng Mười Một, 00:12, David Chandler <drfibona...@google.com>
wrote:

Ashton Thomas

unread,
Nov 13, 2010, 7:35:38 AM11/13/10
to Google Web Toolkit
You can find this example: http://gwt.acrinta.com

it is a small sample app that shows how to implement MVP/Gin/etc

It uses AppPlace which other places extends and then
AppPlaceHistoryMapper directly handles all the mapping but you may
want to do something a little more dynamic. This is just one simple
way

on github: https://github.com/ashtonthomas/gwt-seminar
Reply all
Reply to author
Forward
0 new messages