此处的情况是未经授权的用户尝试访问我希望用户导航到默认页面的位置。在我的情况下,一个地方只能访问管理员用户,因此当非管理员用户尝试访问此地点时可以显示(方法被调用。这里我试图从canReveal()方法揭示默认位置,但不是揭示默认位置,它再次调用revealUnauthorised()位置和更新网址但不揭示默认页面。这有什么办法? 下面是我的代码 canReveal():
@Override
public boolean canReveal()
{
boolean canReveal = false;
IModelObject userSession = KernelGinjector.INSTANCE.getSession().getClientDataModel().getUserSessionObject();
if( userSession != null )
{
IProperty<?> contextGroup = userSession.getPropertyObject( IAdminGatekeeper.GROUP );
if( contextGroup != null )
{
String group = contextGroup.getDisplayValue();
if( group.compareToIgnoreCase( IAdminGatekeeper.DBAGroup ) != 0 )
{
PlaceRequest placeRequest = new PlaceRequest(
showGatewaySubLocation );
m_uiService.getPlaceManager().revealPlace( placeRequest, true );
}
else
{
canReveal = true;
}
}
}
return canReveal;
}
揭示地点的实施:
@Override
public void revealPlace( final PlaceRequest request, final boolean updateBrowserUrl )
{
if( !request.getNameToken().equals( getCurrentPlaceRequest().getNameToken() ) && m_leavePlaceHandler != null )
{
m_leavePlaceHandler.handleLeavePlace( new AsyncCallbackWithContextPair<PlaceRequest, Boolean, Void>(
request, Boolean.valueOf( updateBrowserUrl ) )
{
@Override
public void onSuccess( PlaceRequest placeRequest, Boolean bUpdateBrowserUrl, Void result )
{
internalRevealPlace( placeRequest, bUpdateBrowserUrl.booleanValue() );
}
@Override
public void onFailure( PlaceRequest placeRequest, Boolean bUpdateBrowserUrl, Throwable caught )
{
Logger.getLogger( UIPlaceManager.class.getName() ).log( Level.SEVERE, caught.getLocalizedMessage(),
caught );
}
} );
}
else
{
internalRevealPlace( request, updateBrowserUrl );
}
}
答案 0 :(得分:0)
您是否看过@UnauthorizedPlace
注释?
(https://github.com/ArcBees/GWTP/wiki/PlaceManager)?
您可以使用它将其设置为与DefaultPlace
相同的位置 bindConstant().annotatedWith(UnauthorizedPlace.class).to(NameTokens.defaultPlaceToken);