On Thu, 25 Apr 2002, Chuck Cavaness wrote:

> Date: Thu, 25 Apr 2002 07:41:19 -0400
> From: Chuck Cavaness <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: DynaActionForm problem with non-string objects
>
> I think that you'll have to extend the framework. The "initial" value is
> really designed to be a primitive or one of the wrappers around it.  The
> ConvertUtils "convert" method is used and it's not really capable of doing
> what you want it to do. I think you might take a look at extending the
> FormPropertyConfig class, rather than the DynaActionForm. The
> DynaActionForm uses a Map already and should be capable of dealing with
> Objects. It's the initialization portion of the process that you need to
> override and I believe that starts in the FormPropertyConfig class.
>

Recently, the ConvertUtils code in commons-beanutils (which is called by
the initial() method in FormPropertyConfig) was enhanced to support the
ability to register custom String->Object converters.  If you can create
such a Converter that transforms a string representation of your data type
into a corresponding object, then the DynaActionForm initialization
process should utilize it.

> Chuck Cavaness
>

Craig


> At 11:38 AM 4/19/2002 -0300, you wrote:
> >I'm using some DynaActionForms, but some of them
> >require more complex objects with nested fields, and
> >not only Strings as fields.
> >The problem is that I can only seem to set my objects
> >as null, and it causes problems in the JSPs.
> >Consider this example, taken from struts-config.xml:
> >
> >     <form-bean
> >type="org.apache.struts.action.DynaActionForm"
> >name="myForm">
> >         <form-property name="myObject"
> >type="vo.MyObject" />
> >     </form-bean>
> >
> >
> >I could not use the "initial" property of the
> >form-property element because my object is not a
> >String. So it is set to null instead.
> >All I want is a new instance of the object to be
> >created as the field's initial value.
> >I could set a newly allocated object to the Dynamic
> >form myself, but it sounds like a rather crude
> >solution to me.
> >Isn't there a better way to do this, or will I have to
> >extend the DynaActionForm class to solve this issue?
> >
> >
> >=====
> >----------------------------------------
> >Frederico Ferro Schuh
> >[EMAIL PROTECTED]
> >ICQ: 20486081
> >
> 
>>_______________________________________________________________________________________________
> >Yahoo! Empregos
> >O trabalho dos seus sonhos pode estar aqui. Cadastre-se hoje mesmo no
> >Yahoo! Empregos e tenha acesso a milhares de vagas abertas!
> >http://br.empregos.yahoo.com/
> >
> >--
> >To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to