You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Victor Igumnov (JIRA)" <ji...@apache.org> on 2009/05/11 02:24:45 UTC

[jira] Created: (WICKET-2270) GET/POST mismatch with stateless page/form.

GET/POST mismatch with stateless page/form. 
--------------------------------------------

                 Key: WICKET-2270
                 URL: https://issues.apache.org/jira/browse/WICKET-2270
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4-RC2
         Environment: JDK6/OpenSolaris/Jetty
            Reporter: Victor Igumnov


Stateless page constructor is hit on a stateless form POST, as if it was a GET request. Basically failing the example below. 

See example..

	public GroupSearchResultsPage(final PageParameters pp) {
		super(pp);
		this.pp = pp;
                // On stateless POST this will get executed and fail here.
		if(pp.getString("search") == null) {
			throw new RestartAt404Page();
		} else {
			this.searchName = pp.getString("search");
		}
	}

Here is the fix...

	public GroupSearchResultsPage(final PageParameters pp) {
		super(pp);
		this.pp = pp;
                // Make sure it is a GET request. 
		if(RequestHandlerUtils.getInstance().getHttpServletRequest().getMethod().equalsIgnoreCase("GET")) {
			if(pp.getString("search") == null) {
				throw new RestartAt404Page();
			} else {
				this.searchName = pp.getString("search");
			}
		}
	}

See the issue? stateless form POSTs hit the constructor as if it was a GET request and fail. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (WICKET-2270) GET/POST mismatch with stateless page/form.

Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-2270?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-2270.
-----------------------------------

       Resolution: Won't Fix
    Fix Version/s: 1.4-RC5
         Assignee: Igor Vaynberg

the whole point of stateless pages is that they are recreated every request so the constructor is always hit.

pageparameters only contains GET parameters. if you want search string to always be inside get you can override your form's action and append it to the action url, that should eliminate your check.

> GET/POST mismatch with stateless page/form. 
> --------------------------------------------
>
>                 Key: WICKET-2270
>                 URL: https://issues.apache.org/jira/browse/WICKET-2270
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4-RC2
>         Environment: JDK6/OpenSolaris/Jetty
>            Reporter: Victor Igumnov
>            Assignee: Igor Vaynberg
>             Fix For: 1.4-RC5
>
>
> Stateless page constructor is hit on a stateless form POST, as if it was a GET request. Basically failing the example below. 
> See example..
> 	public GroupSearchResultsPage(final PageParameters pp) {
> 		super(pp);
> 		this.pp = pp;
>                 // On stateless POST this will get executed and fail here.
> 		if(pp.getString("search") == null) {
> 			throw new RestartAt404Page();
> 		} else {
> 			this.searchName = pp.getString("search");
> 		}
> 	}
> Here is the fix...
> 	public GroupSearchResultsPage(final PageParameters pp) {
> 		super(pp);
> 		this.pp = pp;
>                 // Make sure it is a GET request. 
> 		if(RequestHandlerUtils.getInstance().getHttpServletRequest().getMethod().equalsIgnoreCase("GET")) {
> 			if(pp.getString("search") == null) {
> 				throw new RestartAt404Page();
> 			} else {
> 				this.searchName = pp.getString("search");
> 			}
> 		}
> 	}
> See the issue? stateless form POSTs hit the constructor as if it was a GET request and fail. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.