You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by yr...@netscape.net on 2003/11/15 17:21:11 UTC

Error handling was: Re: Autologin via cookie

Hi everyone!

I'm new to Tapestry,I am only 2 weeks old!! 

Thanks to the powerful Tapestry, I have been doing quite a lot of job in the last 2 weeks. I would like to thank the gurus of this list and the autors of the contributed doc (Illustrating Tap. and the new Tutorial). 

But now, for the first time I am a bit confused. 

My problem is close to this thread. Here my first implementation:

pageA:
submitAction()
  cycle.activate(pageB)

pageB:
pageValidate()
  [Boom, I get an error]
    pageA = getPage("pageA")
    pageA.setErrorMessage("blablabla")
    cycle.activate(pageA)
  
Like it is explained in this thread, the second cycle.activate() doesn't work. So, I tried to use PageRedirectException, but with this I didn't find how to pass values to the redirected page. 

Is there a way to pass values to the redirected page?

Now I'm looking to redefining handlePageRedirectException from BaseEngine or to implement my own "Exception".

Before going further, I would like to know 
 - What is the "Tapestry way" for dealing with ErrorRelatedToMyBusinessLogic? 

In fact I would like to have the same kind of page as Exception but only for my own exception.

Thanks a lot!

Yaneric


Paul Ferraro <pm...@columbia.edu> wrote:

>Once page rendering begins you can't activate a different page - but 
>you've guessed that already.
>Suggestion - try having your LoginPage implement PageValidateListener.  
>In your validate(PageEvent) method, throw a PageRedirectException to 
>your success page if cookie-based login succeeds.
>
>Paul Ferraro
>
>Tom Miller wrote:
>
>> (Excuse the resend, part of my message was chopped inadvertently)
>>
>> I would like to implement a login form with an autologin feature. That
>> is, a checkbox which allows the user to save cookies containing their
>> username and password. The next time they access the login form, the
>> cookies are validated, the login page is bypassed and the first page of
>> the site is activated.
>>
>> I've been attempting to do this with "cycle.activate()" in the
>> pageBeginRender() method of the page containing the login form. However,
>> when cycle.activate() is invoked, nothing happens.
>>
>> Actually, something bad happens. The login form comes up instead of
>> being bypassed. Then if I type in a valid username and password and hit
>> enter: I get this stack trace, indicating, I suppose, that my
>> cycle.activate() hosed something up:
>>
>> org.apache.tapestry.ApplicationRuntimeException
>> Service direct requires either three or four service context parameters.
>> Stack Trace:
>> org.apache.tapestry.engine.DirectService.service(DirectService.java:149)
>> org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:879) 
>>
>> org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238) 
>>
>> org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367) 
>>
>> javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>>
>> The form works properly as long as the autologin feature is not used,
>> and the cookies are not created. So I assume pageBeginRender is not the
>> place to try to activate another page.
>>
>> See code: http://stgabe.org/LoginPage.java
>>
>> Note that in the formSubmit() method, the cycle.activate() works as
>> expected.
>>
>> I'd appreciate any suggestions.
>>
>> Thanks
>> Tom Miller
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

__________________________________________________________________
McAfee VirusScan Online from the Netscape Network.
Comprehensive protection for your entire computer. Get your free trial today!
http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397

Get AOL Instant Messenger 5.1 free of charge.  Download Now!
http://aim.aol.com/aimnew/Aim/register.adp?promo=380455

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Error handling was: Re: Autologin via cookie

Posted by Paul Ferraro <pm...@columbia.edu>.
I think you may be using pageValidate() incorrectly - but I'm making 
several assumptions about what you're trying to do.  I looks like your 
submitAction(IRequestCycle) method is the listener of a form submission, 
correct?  It also seems like you are attempting to implement the 
action's business logic in the pageValidate(PageEvent) method of your 
success page instead of in submitAction() method itself.  The 
pageValidate() mechanism is reserved for authentication/authorization 
type tasks, not for validating form submissions.  Look at the 
ValidationDelegate component and its examples to see how form validation 
and validation error messaging works.
Hopefully, this answered you questions.  Let me know if I'm way off the 
mark.

Paul Ferraro

yroussel2000@netscape.net wrote:

>Hi everyone!
>
>I'm new to Tapestry,I am only 2 weeks old!! 
>
>Thanks to the powerful Tapestry, I have been doing quite a lot of job in the last 2 weeks. I would like to thank the gurus of this list and the autors of the contributed doc (Illustrating Tap. and the new Tutorial). 
>
>But now, for the first time I am a bit confused. 
>
>My problem is close to this thread. Here my first implementation:
>
>pageA:
>submitAction()
>  cycle.activate(pageB)
>
>pageB:
>pageValidate()
>  [Boom, I get an error]
>    pageA = getPage("pageA")
>    pageA.setErrorMessage("blablabla")
>    cycle.activate(pageA)
>  
>Like it is explained in this thread, the second cycle.activate() doesn't work. So, I tried to use PageRedirectException, but with this I didn't find how to pass values to the redirected page. 
>
>Is there a way to pass values to the redirected page?
>
>Now I'm looking to redefining handlePageRedirectException from BaseEngine or to implement my own "Exception".
>
>Before going further, I would like to know 
> - What is the "Tapestry way" for dealing with ErrorRelatedToMyBusinessLogic? 
>
>In fact I would like to have the same kind of page as Exception but only for my own exception.
>
>Thanks a lot!
>
>Yaneric
>
>
>Paul Ferraro <pm...@columbia.edu> wrote:
>
>  
>
>>Once page rendering begins you can't activate a different page - but 
>>you've guessed that already.
>>Suggestion - try having your LoginPage implement PageValidateListener.  
>>In your validate(PageEvent) method, throw a PageRedirectException to 
>>your success page if cookie-based login succeeds.
>>
>>Paul Ferraro
>>
>>Tom Miller wrote:
>>
>>    
>>
>>>(Excuse the resend, part of my message was chopped inadvertently)
>>>
>>>I would like to implement a login form with an autologin feature. That
>>>is, a checkbox which allows the user to save cookies containing their
>>>username and password. The next time they access the login form, the
>>>cookies are validated, the login page is bypassed and the first page of
>>>the site is activated.
>>>
>>>I've been attempting to do this with "cycle.activate()" in the
>>>pageBeginRender() method of the page containing the login form. However,
>>>when cycle.activate() is invoked, nothing happens.
>>>
>>>Actually, something bad happens. The login form comes up instead of
>>>being bypassed. Then if I type in a valid username and password and hit
>>>enter: I get this stack trace, indicating, I suppose, that my
>>>cycle.activate() hosed something up:
>>>
>>>org.apache.tapestry.ApplicationRuntimeException
>>>Service direct requires either three or four service context parameters.
>>>Stack Trace:
>>>org.apache.tapestry.engine.DirectService.service(DirectService.java:149)
>>>org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:879) 
>>>
>>>org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:238) 
>>>
>>>org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:367) 
>>>
>>>javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
>>>
>>>The form works properly as long as the autologin feature is not used,
>>>and the cookies are not created. So I assume pageBeginRender is not the
>>>place to try to activate another page.
>>>
>>>See code: http://stgabe.org/LoginPage.java
>>>
>>>Note that in the formSubmit() method, the cycle.activate() works as
>>>expected.
>>>
>>>I'd appreciate any suggestions.
>>>
>>>Thanks
>>>Tom Miller
>>>
>>>
>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>>    
>>
>
>__________________________________________________________________
>McAfee VirusScan Online from the Netscape Network.
>Comprehensive protection for your entire computer. Get your free trial today!
>http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
>
>Get AOL Instant Messenger 5.1 free of charge.  Download Now!
>http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>  
>