Yeeswar,

The normal model I've seen for logon is something like this:

//Once created, this is shared within the session on any page where it is declared. The name //of the variable doesn't matter. You can have one page where it is called user1 and another //where it is called user2. The class is what determines what to pull out of the session. So
//you can only have one application state variable per class type.
        @ApplicationState
        private User user;

//this can be used to check to see if the user has been created without instantiating it. //Tapestry will automatically fill this is with the state of the variable called user.
        private boolean userExists;             
        
        private String userName;
        private String password;
        

        Object onSubmitFromLoginForm() {
_logger.debug("Password: "+password +"\nCorrect: " + _messages.get("password"));
                
                user = Security.authenticate(userName, password);
                if(user == null) {
                        _logger.debug("Incorrect password.  Reload login page");
                        
                        return null;
                }
                return "admin/Menu";
        }

<snip>getters and accessors</snip>

Also if you have a page that needs to be only available on login you can do something like this:

public class AbstractAuthenticatedPage {

        @ApplicationState
        private User user;
        private boolean userExists;     
        @InjectPage
        private Login loginPage;
        
        Object onActivate() {
                if(!userExists) {

                        loginPage.setNext(this.getClass());
                        return loginPage;
                }
                return null;
        }
}


And then extend this class for login protected pages. In this case the loginPage keeps track of where you were trying to go so it can send you back once you login. (It doesn't keep track of the context, so if you are going to a detail page, that information is lost.)


Mark
        

On Mar 4, 2008, at 7:05 AM, Yeeswara Nadapana (HCL Financial Services) wrote:

Hi Ted and Chris,

Thanks. Great help from u guys.

I have used @Persist("session") with my code and got it fixed. My
assumptions with the Page pooling was wrong. You guided me the right
way. Thanks.

Regards,
Yeeswar.


-----Original Message-----
From: Ted Steen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2008 6:13 PM
To: Tapestry users
Subject: Re: Problem with Page pooling

It's all here
http://tapestry.apache.org/tapestry5/tapestry-core/guide/appstate.html


2008/3/4, Yeeswara Nadapana (HCL Financial Services)
<[EMAIL PROTECTED]>:
Hi Chris and Ted,

Thanks to you guys. I am new to Tapestry. Can you help me more in
this
context. Do I need to configure my AppModule.java with the
ApplicationStateCreator() to handle ASOs in my Tapestry project?
Please
explain.

Thanks,
Yeeswara N.


-----Original Message-----
From: Ted Steen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2008 4:39 PM
To: Tapestry users
Subject: Re: Problem with Page pooling

Exactly. Also, from what I can see you use the constructor for
setting
up login-logic.
you should use public void onActivate() {...} for this, as the page
class is created only once.


2008/3/4, Chris Lewis <[EMAIL PROTECTED]>:
I think you are expecting @Persist to work as @ApplicationState,
and
it
doesn't. Read about application state here:


http://tapestry.apache.org/tapestry5/tapestry-core/guide/appstate.html

This line is from the start of that page:
"Ordinary persistent page data is not appropriate, since
persistent
fields apply to a specific page and aren't shared across pages."

In your case "isLoggedIn" will only contain the value in the
context
of
that page (or component, as it seems), because persistent
properties
are
associated with specific page classes.



Yeeswara Nadapana (HCL Financial Services) wrote:
Hi Chris and Ted,

Thanks for u fast replies. Here's what I am doing...

This is my header.java class:

     @Persist
     private boolean isLoggedIn = true;

     public Header() {
             LogonCheck logonCheck = new LogonCheck();
             String logonStatus = logonCheck.checkLogon();
             if(!logonStatus.equals("1.0"))
                     isLoggedIn = false;
     }
     // followed by my getters and setters......

This is my header.tml:

     <t:pageLink t:page="Start" class="horizontal_navi">
                Introduction
     </t:pageLink>

     <t:if test="isLoggedIn" negate="true">
             <t:pageLink t:page="LogInPage"
class="horizontal_navi">
                     LogIn
             </t:pageLink>
     </t:if>




Thanks,
Yeeswar.

-----Original Message-----
From: Chris Lewis [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2008 4:14 PM
To: Tapestry users
Subject: Re: Problem with Page pooling

If you can, you should paste some code. What you're saying
sounds
like a
logic problem, but it almost certainly has nothing to do with
page
pooling. Page pooling has to do with created instances of your
page
classes. These instances do not retain any kind of cached state.
Instead
the relevant rendering and/or component event methods are
executed
freshly on each request. Even when you use an ASO or a
persistent
field,
those members are not tied to that instance of that page.
Instead
they
are tied to the client's request (session) and read by the page
class on
each request.

chris

Yeeswara Nadapana (HCL Financial Services) wrote:

Hi,



I am using Tapestry 5.0.7 for my application. On my menu bar, I
put

some

links with <t:pageLink>. I have put some links under <t:if>
conditions
so as to check the Login status.



Problem is::: When I was not logged in, some links doesn't show
up,
which is CORRECT. Now, I logs in and can find those links. Now,
when I
click on a link which I clicked prior to Loggin in, I will get
the

page

from Tapestry POOL and cannot see those links under <t:if>
conditions
even logged in. Please suggest me a way to solve this. Or shall
I
have
to disable page pooling for this.



Thanks and Regards

Yeeswara N





************************************************************************

****

This mail is transmitted to you on behalf of HCL Technologies.

Diese Post wird Ihnen im Namen der HCL Technologies ubermittelt





************************************************************************

****





DISCLAIMER:




------------------------------------------------------------------------
-----------------------------------------------

The contents of this e-mail and any attachment(s) are
confidential
and

intended for the named recipient(s) only.

It shall not attach any liability on the originator or HCL or
its

affiliates. Any views or opinions presented in

this email are solely those of the author and may not
necessarily

reflect the opinions of HCL or its affiliates.

Any form of reproduction, dissemination, copying, disclosure,

modification, distribution and / or publication of

this message without the prior written consent of the author of
this

e-mail is strictly prohibited. If you have

received this email in error please delete it and notify the
sender

immediately. Before opening any mail and

attachments please check them for viruses and defect.





------------------------------------------------------------------------
-----------------------------------------------






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



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







--
/ted

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


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




--
/ted

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


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



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

Reply via email to