You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Kies <da...@gmail.com> on 2005/12/14 17:41:09 UTC

DynaValidatorActionForm File Upload

Hello.  I am using DynaValidatorActionForm and I want to use File upload to
upload a local file to my struts action class.  Is this possible?
Everything I have seen uses hardcoded forms.

Here is my dynavalidatoraction form:
                <form-bean name="factSheet" type="
org.apache.struts.validator.DynaValidatorActionForm">
                        <form-property name="thefile" type="
org.apache.struts.upload.FormFile"></form-property>
                </form-bean>

and jsp code:
                                <td align="left"><html:file
property="thefile"></html:file></td>

Here is how I try to get the file out of the form:

        FormFile thefile        = (FormFile)dynaActionForm.get("thefile");
        logger.log(Level.SEVERE, "thefile "+thefile);

And stack trace:
Could not invoke the service() method on servlet action. Exception thrown :
javax.servlet.ServletException: BeanUtils.populate
        at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)

        at org.apache.struts.action.RequestProcessor.processPopulate(
RequestProcessor.java:821)
        at org.apache.struts.action.RequestProcessor.process(
RequestProcessor.java:254)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)

        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled
Code))
        at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled
Code))
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(
ServletWrapper.java(Compiled Code))
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(
ServletWrapper.java(Compiled Code))
        at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest
(CacheServletWrapper.java(Compiled Code))
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(
WebContainer.java(Compiled Code))
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(
WCChannelLink.java(Compiled Code))
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(
HttpInboundLink.java(Compiled Code))
        at
com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(
HttpInboundLink.java(Compiled Code))
        at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete
(HttpICLReadCallback.java(Compiled Code))
        at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(
WorkQueueManager.java(Compiled Code))
        at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(
WorkQueueManager.java(Compiled Code))
        at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(
WorkQueueManager.java(Compiled Code))
        at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(
WorkQueueManager.java(Compiled Code))
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled
Code))
---- Begin backtrace for Nested Throwables
org.apache.commons.beanutils.ConversionException: Cannot assign value of
type 'java.lang.String' to property 'thefile' of type '
org.apache.struts.upload.FormFile'
        at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:423)

        at org.apache.commons.beanutils.PropertyUtils.setSimpleProperty(Propert

Re: DynaValidatorActionForm File Upload

Posted by Daniel Kies <da...@gmail.com>.
Ok, thanks.  I never used that property before and I overlooked it.  Thanks
for your help.

On 12/14/05, Dave Newton <ne...@pingsite.com> wrote:
>
> Daniel Kies wrote:
>
> >Here it is:
> ><html:form action="/SaveFactSheet">
> >
> >
> Should be a multipart form, no?
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: DynaValidatorActionForm File Upload

Posted by Dave Newton <ne...@pingsite.com>.
Daniel Kies wrote:

>Here it is:
><html:form action="/SaveFactSheet">
>  
>
Should be a multipart form, no?

Dave



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


Re: DynaValidatorActionForm File Upload

Posted by Daniel Kies <da...@gmail.com>.
Here it is:
<html:form action="/SaveFactSheet">
        <table  cellspacing="2" cellpadding="2" class="brdr-primary"
align="center">
                <TR>
                        <TD>
                        <table border="1" cellspacing="2" cellpadding="2"
class="brdr-primary" align="center">
                        <tr>
                                <td align="right">File:</td>
                                <td align="left"><html:file
property="thefile"></html:file></td>
                        </tr>
                </table>
                <BR>
                </TD>
        </TR>
        <TR>
                <TD align="center">
                        <input type="reset" name="Reset" value="Reset">
                        <input type="submit" name="Submit" value="Submit">
                </TD>
        </TR>
</table>
</html:form>

On 12/14/05, Dave Newton <ne...@pingsite.com> wrote:
>
> Daniel Kies wrote:
>
> >Hello.  I am using DynaValidatorActionForm and I want to use File upload
> to
> >upload a local file to my struts action class.  Is this possible?
> >
> >
> Sure; I use FormFiles with DynaValidatorActionForms often.
>
> >and jsp code:
> >                                <td align="left"><html:file
> >property="thefile"></html:file></td>
> >
> >
> What does the html:form tag look like?
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: DynaValidatorActionForm File Upload

Posted by Dave Newton <ne...@pingsite.com>.
Daniel Kies wrote:

>Hello.  I am using DynaValidatorActionForm and I want to use File upload to
>upload a local file to my struts action class.  Is this possible?
>  
>
Sure; I use FormFiles with DynaValidatorActionForms often.

>and jsp code:
>                                <td align="left"><html:file
>property="thefile"></html:file></td>
>  
>
What does the html:form tag look like?

Dave



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