You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Darren Hartford <dh...@ghsinc.com> on 2004/01/14 22:14:49 UTC

FW: Multiple formfile uploads - howto?

Hey all,
With a simple JSP page with just one <strutshtml:file> tag I can easily load a file into a FormFile object into my Form (with normal getter and setter), and then use an Action to work with the Form.

But, when trying to make this simple JSP page display 1-N <strutshtml:file...> tags to load up many files, the system breaks in between the JSP page and the Form, never reaching the Action.  I have not had success with FormFile[], HashMap, etc. 

==JSP code==
<!-----for HashMap---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
    <TR>
        <TD>
            <CENTER><strutshtml:text name="ai" property="key"/>filename</centeR>

        </TD>
        <TD>
            <strutshtml:file styleClass="fileInput" size="100" name="ai" property="value" />
        </TD>
    </TR>
</strutslogic:iterate>
<!-----or for FormFile[]---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
        <TD>
            <CENTER><strutshtml:text name="ai" property="mystuff"/></centeR>

        </TD>
</strutslogic:iterate>


==Form code==
public class UploadForm extends BaseForm {

/*HashMap doesn't work*/
protected java.util.HashMap mystuff = new HashMap();
public HashMap getMystuff() {
  return mystuff;
}
public void setMystuff(HashMap mystuff) {
  this.mystuff = mystuff;
}

/*FormFile[] doesn't work*/
protected FormFile[] mystuff;
public FormFilegetMystuff() {
  return mystuff;
}
public void setMystuff(FormFilemystuff) {
  this.mystuff = mystuff;
}


==ERROR==
argument type mismatch

Has anyone been successful in uploading an unknown number of files at once through Struts, or is Struts unable to handle this?

TIA!
-D 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: Multiple formfile uploads - howto?

Posted by Andrew Hill <an...@gridnode.com>.
There have been quite a few threads on this topic.
If you search the archives you should be able to find some tips on how to do
it.
http://marc.theaimsgroup.com/?l=struts-user&w=2&r=1&s=multiple+file+upload&q
=b

-----Original Message-----
From: Darren Hartford [mailto:dhartford@ghsinc.com]
Sent: Thursday, 15 January 2004 05:15
To: struts-user@jakarta.apache.org
Subject: FW: Multiple formfile uploads - howto?


Hey all,
With a simple JSP page with just one <strutshtml:file> tag I can easily load
a file into a FormFile object into my Form (with normal getter and setter),
and then use an Action to work with the Form.

But, when trying to make this simple JSP page display 1-N
<strutshtml:file...> tags to load up many files, the system breaks in
between the JSP page and the Form, never reaching the Action.  I have not
had success with FormFile[], HashMap, etc.

==JSP code==
<!-----for HashMap---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
    <TR>
        <TD>
            <CENTER><strutshtml:text name="ai"
property="key"/>filename</centeR>

        </TD>
        <TD>
            <strutshtml:file styleClass="fileInput" size="100" name="ai"
property="value" />
        </TD>
    </TR>
</strutslogic:iterate>
<!-----or for FormFile[]---->
<strutslogic:iterate id="ai" name="uploadform" property="mystuff">
        <TD>
            <CENTER><strutshtml:text name="ai" property="mystuff"/></centeR>

        </TD>
</strutslogic:iterate>


==Form code==
public class UploadForm extends BaseForm {

/*HashMap doesn't work*/
protected java.util.HashMap mystuff = new HashMap();
public HashMap getMystuff() {
  return mystuff;
}
public void setMystuff(HashMap mystuff) {
  this.mystuff = mystuff;
}

/*FormFile[] doesn't work*/
protected FormFile[] mystuff;
public FormFilegetMystuff() {
  return mystuff;
}
public void setMystuff(FormFilemystuff) {
  this.mystuff = mystuff;
}


==ERROR==
argument type mismatch

Has anyone been successful in uploading an unknown number of files at once
through Struts, or is Struts unable to handle this?

TIA!
-D

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org