You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Tsutomu YANO (Issue Comment Edited) (JIRA)" <ji...@apache.org> on 2012/03/07 16:24:58 UTC

[jira] [Issue Comment Edited] (WICKET-4441) PageProvider should create a new Page instance if PageParameters are changed, even if a stored page exists.

    [ https://issues.apache.org/jira/browse/WICKET-4441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13224401#comment-13224401 ] 

Tsutomu YANO edited comment on WICKET-4441 at 3/7/12 3:24 PM:
--------------------------------------------------------------

I know that the PageParameters object is that contains the GET parameters which ware available when the page was created, because it is described in Javadoc. Truly, THAT was a reason I post this issue as a BUG.

Before I post this issue, same as you wrote in previous post, I thought that I could get the new parameter-value from getRequest().getRequestParameters(). But I couldn't, because getRequest().getRequestParameters() doesn't contain the parameters which encoded into mount-path like '/mount-path/${parameter-name}', but it contains only current query-parameters and post-parameters. Because the encoded parameters are not query-parameters nor post-parameters.  Simplly a part of url.

I attach a new sample project where I log all parameter-keys and values of getRequest().getRequestParameter() in onBeforeRender().  That doesn't contain the parameters encoded into mount-path.

(Note: a attached project references wicket 1.5.4 statically for testing. But same with wicket-1.5-SNAPSHOT.)


Our problem is that we have no way to easily get parameter-values from mount-path. We can get parameter-values of query-parameters and post-parameters, because wicket provide the way through getRequestParameters(), getQueryParameters() or getPostParameters(). But there is no way to get the parameters encoded into url.

The only way to retrieve the values from url is that we do same thing which MountedMapper do. Is it the right way to do that in wicket? I can not believe it. 

summary:

1. PageParameters is the object which contains the parameters which the page is created (it is decribed in JavaDoc, so we can not change the behavior easily).

2. getRequest().getRequestParameters() contains only query-parameters and post-parameters, but doesn't contain parameters which encoded into url by mount-path (the function for encoding parameters into URL is introduced from wicket 1.5, so older versions don't have this issue, I think.).

3. There is no easy way to retrieve parameter-values from URL (I think the only way is doing same thing MountedMapper do).

4. So the only easily implementable and ligically acceptable way to provide ALL CURRENT parameters (including parameters encoded into url) for users is that we reconstruct a new page if a part of parameters is changed. Users can get all current parameters from PageParameters.

If URL is changed, the page object is newly created. Parameters encoded into URL are a part of URL, so it is acceptable for me.

If there are another easy ways already, this ticket is my mistake, but I could not find them. I think, if creating a new page instance for each parameter-change is not acceptable for you, (I hope) you should provide another way to retrieve ALL CURRENT PARAMETER VALUES easily for our users of Wicket. We can retrieve query-parameters and post-parameters easily, but not parameters encoded into url.


                
      was (Author: t_yano):
    I know that the PageParameters object is that contains the GET parameters which ware available when the page was created, because it is described in Javadoc. Truly, THAT was a reason I post this issue as a BUG.

Before I post this issue, same as you wrote in previous post, I thought that I could get the new parameter-value from getRequest().getRequestParameters(). But I couldn't, because getRequest().getRequestParameters() doesn't contain the parameters which encoded into mount-path like '/mount-path/${parameter-name}', but it contains only current query-parameters and post-parameters. Because the encoded parameters are not query-parameters nor post-parameters.  Simplly a part of url.

I attach a new sample project where I log all parameter-keys and values of getRequest().getRequestParameter() in onBeforeRender().  That doesn't contain the parameters encoded into mount-path.

(Note: a attached project references wicket 1.5.4 statically for testing. But same with wicket-1.5-SNAPSHOT.)


Our problem is that we have no way to easily get parameter-values from mount-path. We can get parameter-values of query-parameters and post-parameters, because wicket provide the way through getRequestParameters(), getQueryParameters() or getPostParameters(). But there is no way to get the parameters encoded into url.

The only way to retrieve the values from url is that we do same thing which MountedMapper do. Is it the right way to do that in wicket? I can not believe it. 

summary:

1. PageParameters is the object which contains the parameters which the page is created (it is decribed in JavaDoc, so we can not change the behavior easily).

2. getRequest().getRequestParameters() contains only query-parameters and post-parameters, but doesn't contain parameters which encoded into url by mount-path (the function for encoding parameters into URL is introduced from wicket 1.5, so older versions don't have this issue, I think.).

3. There is no easy way to retrieve parameter-values from URL (I think the only way is doing same thing MountedMapper do).

4. So the only easily implementable and ligically acceptable way to provide ALL CURRENT parameters (including parameters encoded into url) for users is that we reconstruct a new page if a part of parameters is changed. Users can all current parameters from PageParameters.

If URL is changed, the page object is newly created. Parameters encoded into URL are a part of URL, so it is acceptable for me.

If there are another easy ways already, this ticket is my mistake, but I could not find them. I think, if creating a new page instance for each parameter-change is not acceptable for you, (I hope) you should provide another way to retrieve ALL CURRENT PARAMETER VALUES easily for our users of Wicket. We can retrieve query-parameters and post-parameters easily, but not parameters encoded into url.


                  
> PageProvider should create a new Page instance if PageParameters are changed, even if a stored page exists.
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4441
>                 URL: https://issues.apache.org/jira/browse/WICKET-4441
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.5
>         Environment: all platform.
>            Reporter: Tsutomu YANO
>         Attachments: fix-WICKET-4441.patch, pagebug.tar.gz, pagebug2.tar.gz
>
>
> The 'getStoredPage(int)' method returns a stored page instance even if user changes parameter values encoded into URL, and the PageParameters object of the stored page instance is never changed. So same page is displayed always though user changes url on browser manually.
> ** HOW TO REPRODUCT **
> 1. unpack the attached sample project 'pagebug.tar.gz'.
> 2. mvn jetty:run
> 3. access to http://localhost:8080/user/user1
> You will see a form filled with information about user 1. The user's name is 'user 1', age is 30 and country is 'Japan'.
> The mount path of this page is '/user/${userId}'. so 'user1' in the accessed url is a parameter value.
> after accessing to the url, the url will be changed to http://localhost:8080/user/user1?0 .  it contains the page id of the currently displayed page.
> 4. change some values and submit the form. page id will be changed on every submit.
> 5. change only parameter value in url to 'user2'. Never change page-id.
> for example, if you now access to http://localhost:8080/user/user1?5, change the url to http://localhost:8080/user/user2?5 .
> 6. This program must display information about user2, because the parameter value of url is changed. But you will see the information of user 1. Wicket always display the page of page-id = 5 (even though user changed url manually).
> In this sample program, I use LoadableDetachableModel for retrieving current parameter-value. But I don't get the new parameter-value because pageParameters object in a page instance is never changed after the construction. pageParameters is fixed in the constructor of Page class.
> I think that there are no easy way to retrieve parameter-values encoded into mount-path. Request.getRequestParameters() does not contain parameters encoded into mount-path. So there are no work-around for this issue.
> ** HOW TO FIX THIS ISSUE **
> We must return null from getStoredPage(int) method of PageProvider class, if current PageParameters is not same with the PageParameters of a stored page. In current code, getStoredPage(int) checks only if the class of both pages are same. We must check the PageParameters of both pages.
> ** PATCH **
> I attached a pache for PageProvider class. try it.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira