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

[jira] Resolved: (WICKET-2045) FileUploadField.onDetach() causes IllegalStateException()

     [ https://issues.apache.org/jira/browse/WICKET-2045?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Juergen Donnerstag resolved WICKET-2045.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4-RC2
         Assignee: Juergen Donnerstag

thanks

> FileUploadField.onDetach() causes IllegalStateException()
> ---------------------------------------------------------
>
>                 Key: WICKET-2045
>                 URL: https://issues.apache.org/jira/browse/WICKET-2045
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4-RC1
>         Environment: Linux ubuntu 2.6.24-23-generic #1 SMP Thu Nov 27 18:13:46 UTC 2008 x86_64 GNU/Linux
> java version "1.6.0_07"
> Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
> Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)
>            Reporter: Andy Thomson
>            Assignee: Juergen Donnerstag
>            Priority: Minor
>             Fix For: 1.4-RC2
>
>
> This was detected when using the example/sample Upload demo locally.
> ERROR - RequestCycle               - there was an error cleaning up target org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget@-20665159[Page class = org.apache.wicket.examples.upload.UploadPage, id = 0, version = 0]->simpleUpload->interface org.apache.wicket.markup.html.form.IFormSubmitListener.IFormSubmitListener (request paramaters: [RequestParameters  componentPath=0:simpleUpload pageMapName=null versionNumber=0 interfaceName=IFormSubmitListener componentId=null behaviorId=null urlDepth=-1 parameters={} onlyProcessIfPathActive=false]).
> java.lang.IllegalStateException: Attempt to set model object on null model of component: simpleUpload:fileInput
> 	at org.apache.wicket.Component.setDefaultModelObject(Component.java:2962)
> 	at org.apache.wicket.markup.html.form.FormComponent.setModelObject(FormComponent.java:1652)
> 	at org.apache.wicket.markup.html.form.upload.FileUploadField.onDetach(FileUploadField.java:175)
> Looking at the source indicates that unless onDetach() is over-ridden the default will always generate this exception. Here is the source for the FileUpLoadField.onDetach().  The line that creates the exception is noted by the "<<<HERE" in the snippet below.
> FileUpLoadField.onDetach() snippet:
> 	/**
> 	 * Clean up at the end of the request. This means closing all inputstreams which might have been
> 	 * opened from the fileUpload.
> 	 * 
> 	 * @see org.apache.wicket.Component#onDetach()
> 	 */
> 	@Override
> 	protected void onDetach()
> 	{
> 		if (fileUpload != null && forceCloseStreamsOnDetach())
> 		{
> 			fileUpload.closeStreams();
> 			fileUpload = null;
> 			setModelObject(null);   <<<HERE
> 		}
> 		super.onDetach();
> 	}
> Drilling further down, the setModelObject() calls FormComponent.setModelObject(), which in turns calls Component.setDefaultModelObject().  Inside setDefaultModelObject(), a check is done to see if the model object is null, if it is, it throws an exception:
> 	public final Component setDefaultModelObject(final Object object)
> 	{
> 		final IModel<Object> model = (IModel<Object>)getDefaultModel();
> 		// Check whether anything can be set at all
> 		if (model == null)
> 		{
> 			throw new IllegalStateException(
> 				"Attempt to set model object on null model of component: " + getPageRelativePath());
> 		}
>                ...
> }

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