You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rakeshxp <ra...@gmail.com> on 2007/08/06 21:12:49 UTC

Struts2 + Dynamic Forms + File Upload

Hi,

I am trying to create a form which would have dynamic number of file tag (
this would be created by the JS ). I am looking for a way to do so in
struts. 

I have created the following class 
public class FileDetails {
    private File file;

    private String contentType;

    private String filename;

    public void setUpload(File file) {
        this.file = file;
    }

    public void setUploadContentType(String contentType) {
        this.contentType = contentType;
    }

    public void setUploadFileName(String filename) {
        this.filename = filename;
    }
}

And in my action class I am trying to do 

 private List<FileDetails> beanList = new ArrayList<FileDetails>();
    public List<FileDetails> getBeanList() {
        return beanList;
    }

    public void setBeanList(List<FileDetails> beanList) {
        this.beanList = beanList;
    }

And in the JSP,
<s:form namespace="/xyz" action="doUpload" method="post"
enctype="multipart/form-data">
	  <s:file name="beanList(0).upload" value="%{value}" />      
	  <s:file name="beanList(1).upload" value="%{value}" />      
      <s:submit/>
 </s:form>

Above method does work as it results in lot of OGNL errors like 
[ERROR] XWorkMethodAccessor - An unexpected exception occurred
<ognl.OgnlException: Error getting property descriptor:
null>ognl.OgnlException: E
rror getting property descriptor: null
        at
com.opensymphony.xwork2.util.XWorkCollectionPropertyAccessor.getProperty(XWorkCollectionPropertyAccessor.java:92)
        at
com.opensymphony.xwork2.util.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:61)

Could any one suggest a solution to my problem ?
-- 
View this message in context: http://www.nabble.com/Struts2-%2B-Dynamic-Forms-%2B-File-Upload-tf4226132.html#a12022372
Sent from the Struts - User mailing list archive at Nabble.com.


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