On Tuesday, May 22, 2012 10:55:15 AM UTC+2, tanteanni wrote:
>
> I am using "PlaceHistoryMapperWithFactory" as suggested
> here<http://stackoverflow.com/questions/10089964/places-that-share-all-but-prefix-or-how-to-use-placehistorymapperwithfactory>.
>
> The factory is set within my "ClientModule" (gin):
>
> @Provides
>>
>> @Singleton
>>
>> @Inject
>>
>> public final PlaceHistoryMapperWithFactory<TokenizerFactory>
>>> getPlaceHistoryMapper(AppPlaceHistoryMapper hm,
>>
>>
>>> TokenizerFactory tf) {
>>
>> hm.setFactory(tf);
>>
>> return hm;
>>
>> }
>>
>>
> I watched the code with debugger (Breakpoints on two lines above and on
> "NullPointerException"):
> 1. The factory is set within "AbstractPlaceHistoryMapper<F>" and "hm"
> with set factory is returned
> 2. AppPlaceHistoryMapperImpl throws NPEx at "return new
> PrefixAndToken("ContentMenu", factory.contentMenuPlace().getToken(place));"
> because factory is null
>
> What is going wrong here?
>
> One probably important thing: This problem is only (re)producible in
> hosted mode. If app is deployed it works fine!
>
Are you sure you're having the same AppPlaceHistoryMapper instance in both
places?
If I were you, I'd rather write my module as:
@Provides @Singleton
PlaceHistoryMapperWithFactory<TokenizerFactory>
providePlaceHistoryMapper(TokenizerFactory tf) {
PlaceHistoryMapperWithFactory<TokenizerFactory> hm =
GWT.create(AppPlaceHistoryMapper.class);
hm.setFactory(tf);
return hm;
}
Alternatively, you can also remove that method entirely and simply override
and annotate the setFactory method in your AppPlaceHistoryMapper interface:
public interface AppPlaceHistoryMapper extends
PlaceHistoryMapperWithFactory<TokenizerFactory> {
@Inject
void setFactory(TokenizerFactory tf);
}
That will work with GIN (would fail with Guice though); see
http://code.google.com/p/google-web-toolkit/issues/detail?id=6151#c4
(BTW, why is your method annotated with @Inject?)
As for the difference between DevMode and prod mode, you should probably
file a bug on GIN.
--
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/-/E4-dYDWQns4J.
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.