You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Howard M. Lewis Ship (JIRA)" <ta...@jakarta.apache.org> on 2005/08/14 17:56:54 UTC

[jira] Resolved: (TAPESTRY-190) PageRedirectException does not fulfill the contract

     [ http://issues.apache.org/jira/browse/TAPESTRY-190?page=all ]
     
Howard M. Lewis Ship resolved TAPESTRY-190:
-------------------------------------------

    Resolution: Invalid
     Assign To:     (was: Tapestry Developer List)

It is very explicit in Tapestry that a page, once loaded by name, is part of the request and future accesses of the same page, by name, return the same object.

> PageRedirectException does not fulfill the contract
> ---------------------------------------------------
>
>          Key: TAPESTRY-190
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-190
>      Project: Tapestry
>         Type: Bug
>   Components: Framework
>     Versions: 3.0
>  Environment: Operating System: Other
> Platform: All
>     Reporter: Anatoli Krassavine

>
> PageRedirectException has a constructor accepting an explicit instance of IPage
> PageRedirectException(IPage page)
> Although not explicitly documented, one would expect from API that this is the 
> page instance which will be used for this request - this is supported by 
> examples (see one below).
> Nevertheless, in implementation:
>     public PageRedirectException(IPage page)
>     {
>         this(page.getPageName());
>     }
> and later AbstractEngine uses getTargetPageName() to lookup the page in 
> question.
> This is not what I would have expected - I would have expected 
> PageRedirectException to store the exact page instance.
> Current behaviour works in normal cases, because RequestCycle caches requested 
> pages and within the context of RequestCycle the same page instance will be 
> returned for the same page name.
> In essense, PageRedirectException makes an explicit undocumeneted assumption 
> that the page instance passed in constructor has already been cached in current 
> request cycle. This is a dangerous assumption (especially since it is not 
> explicitly documented). What would happen if I have already requested page with 
> a particular name (it is cached) and after that thrown PageRedirectException 
> with a newly instantiated page?
> I think this should at least documented and possibly changed:
> 1) Explicitly document the existing behaviour in PageRedirectException and 
> examples
> 2) Modify the behaviour as described below
> - In constructor, check if the page is already cached in current request cycle. 
> If not - throw an exception
> OR
> - If the constructor with explicit page instance is invoked, then the 
> AbstractEngine code should use this page instance "as is", instead of "by name".
> ---------------------------------------------------
> A code from Tapestry documentation:
>  *      private Integer _itemId;
>  *
>  *      public void validate(IRequestCycle cycle) throws RequestCycleException {
>  *          Visit visit = (Visit) getVisit();
>  *
>  *          if (!visit.isAuthenticated()) {
>  *              Login login = (Login) cycle.getPage("Login");
>  *
>  *              login.setCallback
>  *                  (new ExternalCallback(this,cycle.getServiceParameters()));
>  *
>  *              throw new PageRedirectException(login);
>  *          }
>  *      }
>  *

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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