You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (Commented) (JIRA)" <ji...@apache.org> on 2012/01/02 10:08:30 UTC

[jira] [Commented] (WICKET-4290) Confusion between a form component's wicket:id and a PageParameter in Wicket 1.5.x

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

Martin Grigorov commented on WICKET-4290:
-----------------------------------------

I think the problem lies somewhere else.
org.apache.wicket.Component#urlFor(RequestListenerInterface) and org.apache.wicket.Component#urlFor(Behavior, RequestListenerInterface) pass PageProvider with a Page instance to IRequestMapper and this way page's parameters are encoded in the url.
Page's parameters are the parameters in the request when the page is constructed. They are available in any version of the page lifecycle with page.getPageParameters(). I think they shouldn't be encoded in every Link's href, or Form's action, ...

I think we should change the API for the two methods above to accept PageParameters explicitly. This way the user can decide what parameter to encode in the url.

In 1.5 the old methods will delegate to the new version and will be deprecated. In 6.0 change the API.
                
> Confusion between a form component's wicket:id and a PageParameter in Wicket 1.5.x
> ----------------------------------------------------------------------------------
>
>                 Key: WICKET-4290
>                 URL: https://issues.apache.org/jira/browse/WICKET-4290
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.0, 1.5.1, 1.5.2, 1.5.3
>         Environment: OS Linux Mint
> Java 1.6
>            Reporter: Victor MONTANER
>         Attachments: 0001-WICKET-4290-remove-page-parameters-in-onBeforeRender.patch, Zencontact.tar.gz
>
>
> A Form has a strange behavior when a component has the same wicket:id than a page parameter.
> To create a Bookmarkable link after a form is submited, setResponsePage is called, and a PageParameter object is given as a parameter : 
> 			PageParameters params = new PageParameters();
> 			params.add("searchString", searchField.getValue());
> 			setResponsePage(SomePage.class, params);
> In Wicket 1.5, if "searchString" is also a form-component's wicket:id, the form will only be submitted once : 
> searchField.getValue() will always return the first value entered by the user.
> Here's an example : 
> public class SearchPanel extends Panel {
> 	public SearchPanel(String id) {
> 		super(id);
> 		add(new SearchForm("searchForm"));
> 	}
> 	private class SearchForm extends Form<String> {
> 		private static final long serialVersionUID = 1L;
> 		private TextField<String> searchField;
> 		public SearchForm(String id) {
> 			super(id);
> 			searchField = new TextField<String>("searchString", new Model<String>(""));
> 			add(searchField);
> 		}
> 		@Override
> 		public void onSubmit() {
> 			PageParameters params = new PageParameters();
> 			params.add("searchString", searchField.getValue());
> 			setResponsePage(ListContactsPage.class, params);
> 		}
> 	}
> }
> I tested the same application with Wicket 1.4.17 and it was fine. I only had this problem in Wicket 1.5.2 and 1.5.3.

--
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