JBoss Seam s:fileUpload and null data

Sometimes I can be a real schmuck.  Some people believe I always am one, but in this case it was a 30 minute lapse in neuron activity.  I had a JBoss Seam xhtml JSF page like this:

 

  <div class="field">
    <s:fileUpload id="restore" data="#{noteManagement.restoreNotesData}" />
  </div>

However it ALWAYS returned null for noteManagement.restoreNotesData which is a byte[] property on the noteManagement seam component.  The reason?  Idiot me forgot to wrap that s:fileUpload in a separate form element declared as a multipart form:

	<h:form id="restore_notes_form" enctype="multipart/form-data">
	     ...
        </h:form>
After adding that, file uploads worked beautifully.  Of course you still have to have this in components.xml:
		  <component class="org.jboss.seam.web.MultipartFilter">
	    <property name="createTempFiles">true</property>
	    <property name="maxRequestSize">1000000</property>
	  </component>

Blog Categories:

Comments

Thanks man, I was a schmuck too. Take me two hours qith same problem till I read your post.

Pages

Add new comment

Back to top