So I have a page 'ViewCube'. This page can be accessed by anyone and does
not allow any editing rights. I then have a page 'EditCube' which extends
ViewCube and uses some extension points to allow the user with editing
rights to modify the cube (please don't worry about what a "Cube" is!)
I want to make sure that unauthorised users cannot access the EditCube page,
so I have the following redirect onActivate:
@OnEvent(EventConstants.ACTIVATE)
public Object checkUser() throws IOException {
if(isPageRequest()) {
if(!userService.isLoggedIn() ||
!userService.getActiveUser().getId().equals(getCube().getUserId())) {
return
linkSource.createPageRenderLinkWithContext("ViewCube",
getCube().getId());
}
}
return null;
}
I don't want to bother doing this checking if the request is XHR or a POST,
so I have this check:
protected boolean isPageRequest() {
return !request.isXHR() && request.getMethod()=="GET";
}
Problem is, when I have a normal actionLink component:
<t:actionLink t:id="AddCard" id="AddCard">Just Add</t:actionLink>
Inside a component called 'CardLightBox' in EditCube. When this makes the
following request:
/editcube.cardlightbox.addcard
The onActivate method kicks in, returning null and my request is not
fulfilled by the event handler in the page class.
So - am I doing the redirect in the right way? Is this inheritance
sensible? I tried using response.sendRedirect so that I don't need a return
value but this fails with the following:
java.lang.NullPointerException
org.apache.tapestry5.internal.services.assets.CompressionAnalyzerImpl.isCompressable(CompressionAnalyzerImpl.java:34)
$CompressionAnalyzer_13f1db2b6d3d1a.isCompressable(Unknown Source)
Any help much appreciated.
--
View this message in context:
http://tapestry.1045711.n5.nabble.com/Redirect-onActivate-how-to-handle-ActionLink-requests-tp5718883.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]