You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Francois Fernandes (JIRA)" <ji...@apache.org> on 2009/02/13 16:25:59 UTC

[jira] Commented: (WICKET-2092) SignInPanel IllegalArgumentException exception

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

Francois Fernandes commented on WICKET-2092:
--------------------------------------------

the problem is even worse: The two Methods newPage(Class) and newPage(Class, PageParameters) both delegate their call to newPage(Constructor, Object) 

If newPage(Class, PageParameters) is getting called wirth PageParameters = null wicket will try to retrieve the constructor with PageParameters.
This constructor is then passed to 
newPage(Constructor, Object)
 which will check whether the provided argument is null. The code mentioned in the description will invoke the constructor as if it would be a parameterless constructor (because argument == null)which is simply wrong as the one with PageParameters has been requested.

In my opinion newPage(Class, PageParameters) should check whether the parameters are null and if that is true, delegate the call to newPage(Class). That means, I suggest to change the method as follows:

public final <C extends Page> Page newPage(final Class<C> pageClass,
	final PageParameters parameters)
{
	// check if the parameters are null and delegate to newPage(Class)
	if (parameters == null)
	{
		return newPage(pageClass);
	}
	
	// Try to get constructor that takes PageParameters
	Constructor<?> constructor = constructor(pageClass, PageParameters.class);

	// If we got a PageParameters constructor
	if (constructor != null)
	{
		// return new Page(parameters)
		return newPage(constructor, parameters);
	}

	// Always try default constructor if one exists
	return newPage(pageClass);
}


> SignInPanel IllegalArgumentException exception
> ----------------------------------------------
>
>                 Key: WICKET-2092
>                 URL: https://issues.apache.org/jira/browse/WICKET-2092
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-auth-roles
>    Affects Versions: 1.3.5, 1.4-RC1
>            Reporter: Juri Prokofiev
>            Priority: Minor
>
> If HomePage don't have a default constructor there seems to be a problem with SignInPanel -- after the form submission an exception occured: java.lang.IllegalArgumentException: wrong number of arguments.
> The following code in DefaultPageFactory class might be bogus:
> if (argument != null)
>   return (Page)constructor.newInstance(new Object[] { argument });
> else
>   return (Page)constructor.newInstance(new Object[] {});
> Quickfix for solving the problem - replace "(PageParameters)null" with "new PageParameters()":
> setResponsePage(getApplication().getSessionSettings().getPageFactory().newPage(getApplication().getHomePage(), new PageParameters()));

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