have you tried to return the name of the page or the page class

Object onSuccess() {
    return "afterLoginPage";
or
    return AfterLoginPage.class;
}

if you want to redirect to a external url return a Link instance

g,
kris





Gabriel Landais <[EMAIL PROTECTED]> 
14.03.2008 11:35
Bitte antworten an
"Tapestry users" <[email protected]>


An
Tapestry users <[email protected]>
Kopie

Thema
Redirect on login







Hi,
 when a user try to connect to my app, it checks if user is logged.
I'm trying to redirect him to page is was trying to access, but I don't 
know how to do it in Tapestry way. With plain old sendRedirect of 
servlet response it works, but not as clean as it should.
All pages inherits of this page :

    @ApplicationState
    private SimExplorerState applicationState;

    Object onActivate() throws SimExplorerException {
        [...]
        if (!userLogged) {
            String fromURL = requestGlobals.getRequest().getPath(); // 
get url being tried
            applicationState.setRequestedURL(fromURL); // save it in 
application state of user
            return "Login"; // redirect to login page
        }
        [...]
        return null;
    }

Then in Login :

    public Object onSuccessFromFormLogin() throws SimExplorerException, 
IOException {
        [...]
        if (success) {
            [...] 
            String fromURL = applicationState.getRequestedURL();
            if (fromURL == null) {
                return elementList;
            }
            //return fromURL.substring(1); // doesn't work, as context 
is then included in page name
            requestGlobals.getResponse().sendRedirect(fromURL); // bad 
as Tapestry will try to commit data again in response afterwards....
            return null;
        }
        return this;
    }

Thanks for any advice!

-- 
Gabriel <[EMAIL PROTECTED]>
http://www.codelutin.com
tel : 02 40 50 29 28 / fax : 09 59 92 29 28


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to