You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Durham <dd...@vailsys.com> on 2006/03/21 20:12:07 UTC

LazyValidatorForm FormFile instantiation exception

Hi,

I've got a form-bean definition like so:

     <form-bean name="UploadForm"
        type="org.apache.struts.validator.LazyValidatorForm">
          <form-property name="file"
            type="org.apache.struts.upload.FormFile"/>
      ...
     </form-bean>

When I load the page the first time, I get an instantiation exception:

    java.lang.InstantiationException: org.apache.struts.upload.FormFile

It doesn't seriously affect the application, but I'm curious about the 
solution to this problem.  I searched the user@struts archives but 
didn't find this issue referenced.  Is there some way to set an inital 
value to null?  Maybe that would solve the problem?

Thanks,

Dave


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


Re: LazyValidatorForm FormFile instantiation exception

Posted by Niall Pemberton <ni...@gmail.com>.
The basic LazyDynaBean implementation tried to be smart about
instantiating objects - so that people's regular POJO beans would get
automtaically created. In hindsight IMO this was a mistake. It is
however easy to remedy - by overriding the createOtherProperty()
method - see the "4. Automatic Property Instantiation" section here:

http://www.niallp.pwp.blueyonder.co.uk/lazydynabean.html

So if you want you can create a custom LazyDynaBean with this
behaviour. However, if you want this in LazyValidatorForm - you'll
then need to plug that DynaBean implementation into your own
LazyValidatorForm implementation - which is also pretty straight
forward:

http://www.niallp.pwp.blueyonder.co.uk/lazyactionform.html#section4

Niall

On 3/21/06, David Durham <dd...@vailsys.com> wrote:
> Hi,
>
> I've got a form-bean definition like so:
>
>     <form-bean name="UploadForm"
>        type="org.apache.struts.validator.LazyValidatorForm">
>          <form-property name="file"
>            type="org.apache.struts.upload.FormFile"/>
>      ...
>     </form-bean>
>
> When I load the page the first time, I get an instantiation exception:
>
>    java.lang.InstantiationException: org.apache.struts.upload.FormFile
>
> It doesn't seriously affect the application, but I'm curious about the
> solution to this problem.  I searched the user@struts archives but
> didn't find this issue referenced.  Is there some way to set an inital
> value to null?  Maybe that would solve the problem?
>
> Thanks,
>
> Dave

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