Hmmm. Strange.
I dont get that problem in my apps.
What struts version are you using?

-----Original Message-----
From: Ben Janes [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 17 December 2003 17:41
To: Struts Users Mailing List
Subject: RE: BUG!!! FormFile



Yes,

as it works perfecrtly as long as someone enters a file in the html input
field



Benjamin A. Janes
------------------------------------
BLUEWAVE SVERIGE

M. +46 (0)40-631 1068
F. +46 (0)40 -631 10 50
F. +46 (0)46-540 03 50
Drottninggatan 18,
S-211 49 Malmö,
Sweden


|---------+-------------------------------->
|         |           "Andrew Hill"        |
|         |           <[EMAIL PROTECTED]|
|         |           idnode.com>          |
|         |                                |
|         |           2003-12-17 10:31     |
|         |           Please respond to    |
|         |           "Struts Users Mailing|
|         |           List"                |
|         |                                |
|---------+-------------------------------->

>---------------------------------------------------------------------------
----------------------------------------------------------------------------
---------------|
  |
|
  |       To:       "Struts Users Mailing List"
<[EMAIL PROTECTED]>
|
  |       cc:
|
  |       Subject:  RE: BUG!!! FormFile
|

>---------------------------------------------------------------------------
----------------------------------------------------------------------------
---------------|




Did you remember to make it a multipart form???
(And use input type="file" in the page?)


-----Original Message-----
From: Ben Janes [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 17 December 2003 17:28
To: [EMAIL PROTECTED]
Subject: BUG!!! FormFile


Hi


Further to my other mail I have tracked the source of my problem here....
org.apache.commons.beanutils.PropertyUtils#setSimpleProperty

The problem is that when you submit a form, with a file element and the user
has left the file
elemet blank, it crashes.... The altered code below from line 1773 in
PropertyUtils gives the
following output just before the error

descriptor.getWriteMethod():1:public void
com.meganexus.networking.struts.form.ChangeContactForm.setPhoto(org.apache.s
truts.upload.FormFile)
descriptor.getWriteMethod():2:public void
com.meganexus.networking.struts.form.ChangeContactForm.setPhoto(org.apache.s
truts.upload.FormFile)
params:interface org.apache.struts.upload.FormFile,value.getClass():class
java.lang.String

So as you can see, the program expects a FormFile parameter, but gets a
String....  Major error I
think


        // Retrieve the property setter method for the specified property
        PropertyDescriptor descriptor =
                getPropertyDescriptor(bean, name);
        if (descriptor == null) {
            throw new NoSuchMethodException("Unknown property '" +
                    name + "'");
        }

System.out.println("descriptor.getWriteMethod():1:"+descriptor.getWriteMetho
d().toString());
        Method writeMethod = getWriteMethod(descriptor);

System.out.println("descriptor.getWriteMethod():2:"+descriptor.getWriteMetho
d().toString());

        if (writeMethod == null) {
            throw new NoSuchMethodException("Property '" + name +
                    "' has no setter method");
        }
        System.out.print("params:");
        Class [] cls=writeMethod.getParameterTypes();
        for (int i=0;i<cls.length;i++) {
            System.out.print(cls[i].toString()+",");
        }
        System.out.println();
        // Call the property setter method
        Object values[] = new Object[1];
        values[0] = value;
        System.out.println("value.getClass():"+value.getClass());
        writeMethod.invoke(bean, values);
}

[EMAIL PROTECTED]
Benjamin A. Janes
------------------------------------
BLUEWAVE SVERIGE

M. +46 (0)40-631 1068
F. +46 (0)40 -631 10 50
F. +46 (0)46-540 03 50
Drottninggatan 18,
S-211 49 Malmö,
Sweden



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



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







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



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

Reply via email to