That's basically correct. However, you could use Commons BeanUtils to
help make this cleaner and a lot shorter. Something like this should
do it:

    String name = item.getFieldName();
    String value = item.getString();
    MyObjectModel om = new MyObjectModel();
    PropertyUtils.setProperty(om, name, value);

There is also a pending enhancement to FileUpload to provide a request
wrapper so that non-file parameters can be accessed in the same manner
as for regular requests. I am hoping to get to that very soon.

--
Martin Cooper


On Fri, 15 Oct 2004 10:56:42 -0700 (PDT), Joe Smith <[EMAIL PROTECTED]> wrote:
> 
> When we process the form data without file upload control in JSP. We can use 
> JavaBeans in JSP, then the following will store all the request form data to 
> MyObjectModel object:
> 
> <jsp:useBean id="om" class="MyObjectModel" />
> 
> <jsp:setProperty name="om" property="*" />
> 
> However, when we process the form data that contains file upload, and uses 
> commons-fileupload, then we should approach the following, is that correct?
> 
> if (item.isFormField())
> 
> {
> 
>      String name = item.getFieldName();
> 
>      String value = item.getString();
> 
>      MyObjectModel om = new MyObjectModel();
> 
>      if (name.equals("fieldName1"))
> 
>            ad.setFieldName1(value);
> 
>      else if (name.equals("fieldName2"))
> 
>            ad. setFieldName2(value);
> 
>      else if (name.equals("fieldName3"))
> 
>            ad.setFieldName3(value);
> 
>      //etc...
> 
> }
> 
> Please advise. Thanks!!
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Mail Address AutoComplete - You start. We finish.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to