On Thursday, March 8, 2012 12:37:19 PM UTC+1, tanteanni wrote:
>
> Sometimes i have two places that differ only in thier prefix. For example
> a "SelectionPlace" and a "ResultOfSelectionPlace". So both places share all
> code but differ in @Prefix(value"..."). At the moment i implemented this by
> using an abstract class but i have to copy the code of the tokenizer to get
> tokenizers with different prefixes.
>
> Is there a way to let the concrete class only set the prefix of a shared
> tokenizer class? Or is there probably a complete different way to achieve
> this?
>
I believe it's possible using a parameterized tokenizer, a
PlaceHistoryMapperWithFactory and using the @Prefix on the factory methods
rather than on the tokenizer class:
class FooPlace extends AbstractMyPlace { }
class BarPlace extends AbstractMyPlace { }
abstract class AbstractMyPlace extends Place {
static class Tokenizer<T extends AbstractMyPlace> extends
PlaceTokenizer<T> { … }
…
}
class MyFactory {
@Prefix("foo")
public PlaceTokenizer<FooPlace> foo() { return new
AbstractMyPlace.Tokenizer<FooPlace>(); }
@Prefix("bar")
public PlaceTokenizer<BarPlace> bar() { return new
AbstractMyPlace.Tokenizer<BarPlace>(); }
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/UTFNVG8BuL4J.
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.