You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Javier Molina <nu...@myrealbox.com> on 2006/01/17 19:47:50 UTC
pageValidate being called inconveniently
I have some public and some protected pages in my application. All pages
are based on the same dreamweaver template, with non-editable sections
that should be present in all pages. In one of these non-editable
sections (and hence in every tapestry page) is a search component (with
it's own jwc, html and java class).
I'm checking for permission in the pageValidate method looking for a
certain object in the Visit.
Problem scenario: the user enters the protected area, then waits for a
long time until his session expires, therefore the visit becomes null.
Then the user tries to use the search component and, because the page
showing it is protected, its pageValidate method is being called, which
results in an exception because the session is expired and the user is
considered not to be authenticated.
Knowing that the search component needs nothing from protected areas,
this behaviour is not really acceptable. I would not expect a "session
expired" message from any webapp if all I was trying to access was a
stateless, public part of the site.
Is there any way to know what listener/component will be called so that
I can prevent pageValidate from throwing an exception if it's not
something that should be protected?
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: pageValidate being called inconveniently
Posted by Chris Conrad <cc...@vasoftware.com>.
Assuming you are using Tapestry 4, set the "stateful" parameter on
the Form component to "false". This will prevent that form from ever
throwing a StaleSessionException.
--Chris
On Jan 17, 2006, at 10:47 AM, Javier Molina wrote:
> I have some public and some protected pages in my application. All
> pages are based on the same dreamweaver template, with non-editable
> sections that should be present in all pages. In one of these non-
> editable sections (and hence in every tapestry page) is a search
> component (with it's own jwc, html and java class).
>
> I'm checking for permission in the pageValidate method looking for
> a certain object in the Visit.
>
> Problem scenario: the user enters the protected area, then waits
> for a long time until his session expires, therefore the visit
> becomes null. Then the user tries to use the search component and,
> because the page showing it is protected, its pageValidate method
> is being called, which results in an exception because the session
> is expired and the user is considered not to be authenticated.
>
> Knowing that the search component needs nothing from protected
> areas, this behaviour is not really acceptable. I would not expect
> a "session expired" message from any webapp if all I was trying to
> access was a stateless, public part of the site.
>
> Is there any way to know what listener/component will be called so
> that I can prevent pageValidate from throwing an exception if it's
> not something that should be protected?
>
>
> ---------------------------------------------------------------------
> 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
Re: pageValidate being called inconveniently
Posted by Kent Tong <ke...@cpttm.org.mo>.
Javier Molina <numeropi <at> myrealbox.com> writes:
>
> Something like that could work for now even if it's a hack, but the code
> seems to be only for T4. Is there something similar for 3.0.3? I can
> only find getRequestCycle().getAttribute(String name) instead of
> getParameter() (which might just have been a typo) but the cycle's
> _attributes Map is null according to the debugger.
Try:
public void pageValidate(PageEvent event) {
RequestContext ctx = getRequestCycle().getRequestContext();
String service = ctx.getParameter("service");
if (service.startsWith(Tapestry.DIRECT_SERVICE) &&
service.indexOf("form1") != -1) {
System.out.println("form1. go ahead.");
return;
}
}
--
Author of a book for learning Tapestry (www.agileskills2.org/EWDT)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: pageValidate being called inconveniently
Posted by Javier Molina <nu...@myrealbox.com>.
Something like that could work for now even if it's a hack, but the code
seems to be only for T4. Is there something similar for 3.0.3? I can
only find getRequestCycle().getAttribute(String name) instead of
getParameter() (which might just have been a typo) but the cycle's
_attributes Map is null according to the debugger.
Kent Tong escribió:
> Javier Molina <numeropi <at> myrealbox.com> writes:
>
>> Is there any way to know what listener/component will be called so that
>> I can prevent pageValidate from throwing an exception if it's not
>> something that should be protected?
>
> Assuming the component id of your search form is "form1", you
> may try this:
>
> public void pageValidate(PageEvent event) {
> String service = getRequestCycle().getParameter(ServiceConstants.SERVICE);
> if (service.equals(Tapestry.DIRECT_SERVICE) &&
> getRequestCycle().getParameter(ServiceConstants.COMPONENT).equals("form1")) {
> System.out.println("form1. go ahead.");
> return;
> }
> }
>
> Obviously this is a hack.
>
> --
> Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
>
>
> ---------------------------------------------------------------------
> 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
Re: pageValidate being called inconveniently
Posted by Kent Tong <ke...@cpttm.org.mo>.
Javier Molina <numeropi <at> myrealbox.com> writes:
> Is there any way to know what listener/component will be called so that
> I can prevent pageValidate from throwing an exception if it's not
> something that should be protected?
Assuming the component id of your search form is "form1", you
may try this:
public void pageValidate(PageEvent event) {
String service = getRequestCycle().getParameter(ServiceConstants.SERVICE);
if (service.equals(Tapestry.DIRECT_SERVICE) &&
getRequestCycle().getParameter(ServiceConstants.COMPONENT).equals("form1")) {
System.out.println("form1. go ahead.");
return;
}
}
Obviously this is a hack.
--
Author of a book for learning Tapestry (http://www.agileskills2.org/EWDT)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org