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

Reply via email to