You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Gabriel Landais <la...@codelutin.com> on 2008/03/14 11:35:53 UTC
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 <la...@codelutin.com>
http://www.codelutin.com
tel : 02 40 50 29 28 / fax : 09 59 92 29 28
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect on login
Posted by Gabriel Landais <la...@codelutin.com>.
Cordenier Christophe a écrit :
> In fact, this is a better solution if you have an activation context.
>
> So to achieve this, we still may use the "ComponentResources" class and its "createPageLink" method
>
> Christophe.
>
Thanks all, it works great now :
@ApplicationState
private SimExplorerState applicationState;
@Inject
private ComponentResources resources;
Object onActivate(Object... pageContext) throws SimExplorerException {
[...]
if (!userLogged) {
applicationState.setPageName(resources.getPageName());
applicationState.setPageContext(pageContext);
return "Login"; // redirect to login page
}
[...]
return null;
}
Then in Login :
public Object onSuccessFromFormLogin() throws SimExplorerException,
IOException {
[...]
if (success) {
[...]
String fromPage = applicationState.getPageName();
if (fromPage == null) {
return elementList;
}
return
resources.createPageLink(applicationState.getPageName(), true,
applicationState.getPageContext());
}
return this;
}
--
Gabriel <la...@codelutin.com>
http://www.codelutin.com
tel : 02 40 50 29 28 / fax : 09 59 92 29 28
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: Redirect on login
Posted by Cordenier Christophe <Ch...@atosorigin.com>.
In fact, this is a better solution if you have an activation context.
So to achieve this, we still may use the "ComponentResources" class and its "createPageLink" method
Christophe.
-----Message d'origine-----
De : Stephane Decleire [mailto:sdecleire@cariboo-networks.com]
Envoyé : vendredi 14 mars 2008 12:05
À : Tapestry users
Objet : Re: Redirect on login
I would recommend to store a Link (which can contain the page name and
the context of the request) and return this link in the success method.
Stephane
Cordenier Christophe a écrit :
> Why do you not store the page name instead of the request Path and then returning the page name in the success method ?
>
> As your success method return an Object you can return a String containing the requested page name...
>
> @Inject
> ComponentResources resources;
>
> ...
>
> // Store this in application state
> resources.getPageName();
>
>
> Hope this helps
>
> Christophe.
>
> -----Message d'origine-----
> De : Gabriel Landais [mailto:landais@codelutin.com]
> Envoyé : vendredi 14 mars 2008 11:36
> À : Tapestry users
> Objet : 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 <la...@codelutin.com>
> http://www.codelutin.com
> tel : 02 40 50 29 28 / fax : 09 59 92 29 28
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>
> Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
>
> This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Redirect on login
Posted by Stephane Decleire <sd...@cariboo-networks.com>.
I would recommend to store a Link (which can contain the page name and
the context of the request) and return this link in the success method.
Stephane
Cordenier Christophe a écrit :
> Why do you not store the page name instead of the request Path and then returning the page name in the success method ?
>
> As your success method return an Object you can return a String containing the requested page name...
>
> @Inject
> ComponentResources resources;
>
> ...
>
> // Store this in application state
> resources.getPageName();
>
>
> Hope this helps
>
> Christophe.
>
> -----Message d'origine-----
> De : Gabriel Landais [mailto:landais@codelutin.com]
> Envoyé : vendredi 14 mars 2008 11:36
> À : Tapestry users
> Objet : 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 <la...@codelutin.com>
> http://www.codelutin.com
> tel : 02 40 50 29 28 / fax : 09 59 92 29 28
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>
> Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
>
> This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
RE: Redirect on login
Posted by Cordenier Christophe <Ch...@atosorigin.com>.
Why do you not store the page name instead of the request Path and then returning the page name in the success method ?
As your success method return an Object you can return a String containing the requested page name...
@Inject
ComponentResources resources;
...
// Store this in application state
resources.getPageName();
Hope this helps
Christophe.
-----Message d'origine-----
De : Gabriel Landais [mailto:landais@codelutin.com]
Envoyé : vendredi 14 mars 2008 11:36
À : Tapestry users
Objet : 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 <la...@codelutin.com>
http://www.codelutin.com
tel : 02 40 50 29 28 / fax : 09 59 92 29 28
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Ce message et les pièces jointes sont confidentiels et réservés à l'usage exclusif de ses destinataires. Il peut également être protégé par le secret professionnel. Si vous recevez ce message par erreur, merci d'en avertir immédiatement l'expéditeur et de le détruire. L'intégrité du message ne pouvant être assurée sur Internet, la responsabilité du groupe Atos Origin ne pourra être recherchée quant au contenu de ce message. Bien que les meilleurs efforts soient faits pour maintenir cette transmission exempte de tout virus, l'expéditeur ne donne aucune garantie à cet égard et sa responsabilité ne saurait être recherchée pour tout dommage résultant d'un virus transmis.
This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this e-mail in error, please notify the sender immediately and destroy it. As its integrity cannot be secured on the Internet, the Atos Origin group liability cannot be triggered for the message content. Although the sender endeavours to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
RE: Redirect on login
Posted by Kristian Marinkovic <kr...@porsche.co.at>.
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 <la...@codelutin.com>
14.03.2008 11:35
Bitte antworten an
"Tapestry users" <us...@tapestry.apache.org>
An
Tapestry users <us...@tapestry.apache.org>
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 <la...@codelutin.com>
http://www.codelutin.com
tel : 02 40 50 29 28 / fax : 09 59 92 29 28
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org