You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2007/08/22 17:02:54 UTC
T5:Login and session
Hi,
what is the correct way to manage sessions in T5? let's say, user has to
login before it can go to other pages, how other pages check if a request is
from a logined user or not? Thanks.
A.C.
--
View this message in context: http://www.nabble.com/T5%3ALogin-and-session-tf4312177.html#a12276631
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5:Login and session
Posted by 蝈蝈龙 <el...@gmail.com>.
Application State is for it.
see http://tapestry.apache.org/tapestry5/tapestry-core/guide/appstate.html
I have written some examples like this:
There are follwing page classes to be protected.
UserEdit.java
ShopSetting.java
if the session is null , above these pages won't be opened.
firstly I let all them extends AdminRootPage.java. the class is like this:
public class AdminRootPage {
@ApplicationState
private SessionData _session;
private boolean _sessionExists;
String onActivate() {
if(!_sessionExists){
return "Login";
}
return null;
}
}
The session data is a value object which you can put any fields value in it.
Usually the SessionData cotain the current user information whick like this
public class SessionData {
private String username ;
public String getUsername() {
return username;
}
public void setUsername(String name) {
this.username = name;
}
When you visit http://...../useredit , the adminRootPage.onActive() will
check the sessionData is null.
If it's null then go to page Login. the Login.java may be like this
public class Login {
.....
// the method will be execute when a submit button named 'login' on
Login.html
void onSelectedFromLogin() {
User user = _service.checkValidUser(username,password);
// init session if it's a valid user.
if (user==null) {
loginFrm.recordError(_passwordField, "Invalid user name or
password.");
}
_session.setUsername(username);
_session.setUser(user);
this.nextPage = PageConstant.SHOP_OVERVIEW;
}
....
}
After onSelectedFromLogin() is executed, the session will be initialized a
appropriated value
2007/8/22, Angelo Chen <an...@yahoo.com.hk>:
>
>
> Hi,
>
> what is the correct way to manage sessions in T5? let's say, user has to
> login before it can go to other pages, how other pages check if a request
> is
> from a logined user or not? Thanks.
>
> A.C.
> --
> View this message in context:
> http://www.nabble.com/T5%3ALogin-and-session-tf4312177.html#a12276631
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: T5:Login and session
Posted by Daniel Jue <te...@gmail.com>.
Please check the Tapestry website and Wiki.
Specifically the T5 section, and more specifically the Tapestry-Core section.
http://tapestry.apache.org/tapestry5/tapestry-core/guide/appstate.html
You probably won't need the "Configuring ASOs" part right now.
On 8/22/07, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> what is the correct way to manage sessions in T5? let's say, user has to
> login before it can go to other pages, how other pages check if a request is
> from a logined user or not? Thanks.
>
> A.C.
> --
> View this message in context: http://www.nabble.com/T5%3ALogin-and-session-tf4312177.html#a12276631
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org