On Wednesday, January 13, 2016 at 11:10:10 AM UTC+1, Tugdual Huertas wrote:
>
> Hi,
>
> I'm facing a little question about PlaceHistoryMapper file. 
> Is there a way to have more than one file to list all places?
>
> I have this use case (I'm using multi-modules maven projects):
>
> Standard project:
>            - model project
>            - business project
>            - service project
>            - gwt project (containing PlaceHistoryMapper file)
>    + webapp project only used to define web.xml and standard application 
> version for example).
>
> Specific project
>          Uses of gwt project (and all other projects except webapp one) 
> and add some widgets / screens.
>          Define its webapp (new web.xml, entry point ...)
>    I this specific project i'd like to use PlaceHistoryMapper file defined 
> in gwt project and create a new one containig only specific places instead 
> of creating one containing all places (gwt prject places and specific 
> places) which can lead to oversights... Is there a way to do that?
>
>
You'll want to create PlaceHistoryMapper instance that delegates to the one 
you get from the "parent" project (and possibly to one for your "specific 
project" if you let GWT generate the implementation based on 
@WithTokenizers).
Something like:

public class ChainingPlaceHistoryMapper implements PlaceHistoryMapper {
  private PlaceHistoryMapper[] mappers;

  public ChainingPlaceHistoryMapper(PlaceHistoryMapper... delegates) {
    this.mappers = mappers;
  }

  @Override public Place getPlace(String token) {
    for (PlaceHistoryMapper mapper : mappers) {
      Place place = mapper.getPlace(token);
      if (place != null) {
        return place;
      }
    }
    return null;
  }

  @Override public String getToken(Place place) {
    for (PlaceHistoryMapper mapper : mappers) {
      String token = mapper.getToken(place);
      if (token != null) {
        return token;
      }
    }
    return null;
  }
}

And you'd use it like: new 
ChainingPlaceHistoryMapper(GWT.create(SpecificPlaceHistoryMapper.class), 
GWT.create(GenericPlaceHistoryMapper.class))

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to