@Target(value=METHOD) public @interface TitleFunction
Title
.
1) You can use it to annotate a static or non-static public method in your
presenter that returns a string (the title). This method can optionally
accept a PlaceRequest
parameter to
contain the place request for which the title is desired. It can also
optionally accept another parameter corresponding to your custom ginjector.
Using a static method is more efficient, as it doesn't force instantiation of
the associated presenter and view. Example of use:
2) You can use it to annotate a static or non-static public method in your presenter that returns@
TitleFunction static public String getTranslatedTitle( MyGinjector ginjector ) { return ginjector.getTranslations().productTitle(); }@
TitleFunction public String getTitle( PlaceRequest placeRequest ) { prepareFromRequest( placeRequest ); return "Email #" + getEmailId(); }
void
but accept a parameter of type
SetPlaceTitleHandler
. In this case,
your method is responsible for calling this handler's onSetPlaceTitle
with the title for this place, or null
if the place doesn't have a
title. This is useful if the title can only be accessed in an asynchronous
fashion, for example following a call to the server. As above, your method
can accept a PlaceRequest
parameter
and your custom ginjector. Example of use:
@
TitleFunction public void getTitle( PlaceRequest placeRequest, final SetPlaceTitleHandler handler ) { prepareFromRequest( placeRequest ); dispatcher.execute( new GetUserNameAction( getUserId(), new AsyncCallback(){ public void onSuccess(GetUserNameResult result) { handler.onSetPlaceTitle( result.getUserName() ); } public void onFailure(Throwable caught) { handler.onSetPlaceTitle(null); } } }
Copyright © 2010–2014 Arcbees. All rights reserved.