Yes that would work too with the ViewController, but then I prefer my
solution.
Because you can write little action classes like this one.
@bean(name="userActivate",scope=Scope.REQUEST)
class UserActivateAction {
// fill properties from param
public String activate() {
//do something
return "outcome"
}
}
Why I would like to combine it with shale-remoting is the dynamic
interpretation of the request path like
/dynamic/userActivate/activate.faces. So I wouldn't need to define the
action path explicitly.
To integrate such a solution in shale we need to define a new uri prefix
like "/dynamic" and a new Processor.
- Ingo
Craig McClanahan schrieb:
On 9/28/06, Ingo Düppe <[EMAIL PROTECTED]> wrote:
Hi Craig,
guess you are right that the remoting is not the solution for my
problem. What I like to realize is the following:
- The user gets an email with a link to the webapp.
- When the user click on this link an action method should decide
whether the link is still valid or not.
- If the link is still valid the user is redirected to the login page.
- If not the user is redirected to a new request page.
That seems like a reasonable use case.
So what I need is a solution to trigger an action method by a get
request that returns an outcome that is handled by jsf?
JSF doesn't have any direct support for this, but here's an approach
to it
using Shale. An interesting fact is that the prerender() method of a
ViewController gets called before rendering, even on a GET request. The
return method here is void, so you can't just return a string and let the
standard NavigationHandler do its thing, but you *can* fake this out.
Consider the following:
public class MyLinkChecker extends AbstractViewController {
...
public void prerender() {
FacesContext context = FacesContext.getCurrentInstance();
boolean isValid = ...; // Examine current state, determine if
its valid
if (!isValid) {
// Force the user to see the logon page instead of the
requested one
ViewController vc = context.getApplication
().getViewController();
vc.createView(context, "/logon.jsp");
} else {
... prepare any data needed to render this page ...
}
...
}
You could put logic like this in the view controller of any page that
needs
this sort of check, or perhaps build a common superclass to
encapsulate it.
Then, just use a normal URL for the page in the email link that you send
out.
Craig