You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Anil Mandava <am...@altoweb.com> on 2002/01/17 00:27:25 UTC

Self-Initializing DynaBean ?

It would be nice to implement a DynaBean version that can self-populate 
or self-initialize the properties.

Say, if it were possible to encode property type in the 
property name as: "myProp{MyPropClass}"
then the DyanBean's getter/setter can auto add a corresponding dyna
property.
This will enable any sub properties of MyPropClass to be invoked properly.

That is all possible, only if we extend the property specification to
include {type} part.
Do you feel this is a reasonable thing to do, or are there any pitfalls here
?

I am more interested in doing this with (Craig's soon to come)
DynaActionForm.
My end goal is to have one generic form bean (that will work for all
actions).
For such a generic form bean to handle multi-level properties 
such as "myProp{MyPropClass}.subProp", it has to infer and initialize the 
first property, so that the setter on the subProp can be invoked.

I am interested in knowing your thoughts and opinions on this.
If it does work out and I happen to implement it, I will provide a patch.

Thank you all for the great work !
Anil

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Self-Initializing DynaBean ?

Posted by David Winterfeldt <dw...@yahoo.com>.
--- "Craig R. McClanahan" <cr...@apache.org> wrote:
<snip>
> We should also consider whether it makes sense to
> integrate the
> configuration of the validation criteria into
> struts-config.xml -- not as
> a *replacement* for the existing mechanism, but as
> an alternative for
> Struts based users.
<snip>

Did you have anything specific in mind for the
structure?  I think that this has been mentioned
before, but I wasn't sure how to cleanly include this
in with the struts-config.xml.  The basic information
could be add to the form-bean definitions, but how
would multiple locale validation rules be handled? 
Would there be multiple form-beans that defined the
locale?  

<form-bean name="logonForm"
type="org.apache.struts.action.DynaActionForm">
   <form-property 
      name="username" 
      type="java.lang.String" 
      initial="user"
      depends="required">
       <arg0 key="user.displayname"/>
   </form-property> 
   <form-property 
      name="password" 
      type="java.lang.String">
      depends="required"/>
       <arg0 key="password.displayname"/>
   </form-property> 
</form-bean>

Also since the Validator is in Commons now, something
like this would require maintaining a separate
resource initializer to handle the different xml
structure.  Which might be worthwhile to maintain if
it would enhance usability enough.  If the current
Validator xml structure was just placed as is in the
struts-config.xml, then the main resource intializer
could be made to take a parameter for the xml root to
use (instead of /form-validation to use
/struts-config/form-validation in
${xml.root}/formset/form/field).

Martin had mentioned in Commons whether or not to move
the Struts Validator interface out of commons and into
Struts proper.  Any thoughts on this?  It was on the
1.1 to do list to have a validation framework built
in.  I could go either way, but I think it would be
nice if it was in the core.  Especially since there
are so few classes left since most are in the Commons
now.

David

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Self-Initializing DynaBean ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 16 Jan 2002, David Winterfeldt wrote:

> Date: Wed, 16 Jan 2002 22:09:51 -0800 (PST)
> From: David Winterfeldt <dw...@yahoo.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: RE: Self-Initializing  DynaBean ?
>
> --- "Craig R. McClanahan" <cr...@apache.org> wrote:
> > Not yet ... we'll need to look at how to integrate
> > valiation support together with it.
>
> The Validator uses BeanUtils for all property calls to
> retrieve values to validate.  And BeanUtils works with
> DynaBeans now, right?
>    ex:  value = PropertyUtils.getProperty(bean,
> property);
>

Yes -- although BeanUtils.populate() had problems until I fixed it today.

> So if I extend DynaActionForm (making
> ValidatorDynaActionForm) and add in a validate method
> that calls the Validator Framework shouldn't that
> work?  The Validator extension of the DynaActionForm
> instance would be the bean variable in the example
> above.  Hope that was clear.
>

That should work.

We should also consider whether it makes sense to integrate the
configuration of the validation criteria into struts-config.xml -- not as
a *replacement* for the existing mechanism, but as an alternative for
Struts based users.

> David
>

Craig


> --- "Craig R. McClanahan" <cr...@apache.org> wrote:
> >
> >
> > On Wed, 16 Jan 2002, Matt Raible wrote:
> >
> > > Date: Wed, 16 Jan 2002 18:59:49 -0700
> > > From: Matt Raible <ma...@yahoo.com>
> > > Reply-To: Struts Developers List
> > <st...@jakarta.apache.org>,
> > >      matt@raibledesigns.com
> > > To: Struts Developers List
> > <st...@jakarta.apache.org>
> > > Subject: RE: Self-Initializing  DynaBean ?
> > >
> > > I'd love to use this, but I'm worried about losing
> > the lovely
> > > "ValidatorForm" that my BaseForm extends.  Any way
> > I can use the Validator
> > > form with the "DynaActionForm"?
> > >
> >
> > Not yet ... we'll need to look at how to integrate
> > valiation support
> > together with it.
> >
> > > Thanks,
> > >
> > > Matt
> > >
> >
> > Craig
> >
> >
> > > -----Original Message-----
> > > From: Craig R. McClanahan
> > [mailto:craigmcc@apache.org]
> > > Sent: Wednesday, January 16, 2002 5:33 PM
> > > To: Struts Developers List
> > > Subject: Re: Self-Initializing DynaBean ?
> > >
> > >
> > >
> > >
> > > On Wed, 16 Jan 2002, Anil Mandava wrote:
> > >
> > > > Date: Wed, 16 Jan 2002 15:27:25 -0800
> > > > From: Anil Mandava <am...@altoweb.com>
> > > > Reply-To: Struts Developers List
> > <st...@jakarta.apache.org>
> > > > To: 'Struts Developers List'
> > <st...@jakarta.apache.org>
> > > > Subject: Self-Initializing  DynaBean ?
> > > >
> > > > It would be nice to implement a DynaBean version
> > that can self-populate
> > > > or self-initialize the properties.
> > > >
> > > > Say, if it were possible to encode property type
> > in the
> > > > property name as: "myProp{MyPropClass}"
> > > > then the DyanBean's getter/setter can auto add a
> > corresponding dyna
> > > > property.
> > > > This will enable any sub properties of
> > MyPropClass to be invoked properly.
> > > >
> > > > That is all possible, only if we extend the
> > property specification to
> > > > include {type} part.
> > > > Do you feel this is a reasonable thing to do, or
> > are there any pitfalls
> > > here
> > > > ?
> > > >
> > > > I am more interested in doing this with (Craig's
> > soon to come)
> > > > DynaActionForm.
> > > > My end goal is to have one generic form bean
> > (that will work for all
> > > > actions).
> > > > For such a generic form bean to handle
> > multi-level properties
> > > > such as "myProp{MyPropClass}.subProp", it has to
> > infer and initialize the
> > > > first property, so that the setter on the
> > subProp can be invoked.
> > > >
> > > > I am interested in knowing your thoughts and
> > opinions on this.
> > > > If it does work out and I happen to implement
> > it, I will provide a patch.
> > > >
> > >
> > > I just checked in the code for DynaActionForm,
> > along with support for it
> > > in Struts.  I also added a way to configure the
> > initial value for dynamic
> > > properties that is used in the reset() method.
> > So, you could preconfigure
> > > the logon form's values like this:
> > >
> > >   <form-bean name="logonForm"
> > > type="org.apache.struts.action.DynaActionForm">
> > >     <form-property name="username"
> > type="java.lang.String" initial="user"/>
> > >     <form-property name="password"
> > type="java.lang.STring"/>
> > >   </form-bean>
> > >
> > > much the same as you can preinitialize normal
> > instance variables with
> > > initial values when the bean is created.
> > >
> > > Does that do what you were looking for?
> > >
> > > > Thank you all for the great work !
> > > > Anil
> > > >
> > >
> > > Craig
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Self-Initializing DynaBean ?

Posted by David Winterfeldt <dw...@yahoo.com>.
--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> Not yet ... we'll need to look at how to integrate
> valiation support together with it.

The Validator uses BeanUtils for all property calls to
retrieve values to validate.  And BeanUtils works with
DynaBeans now, right?
   ex:  value = PropertyUtils.getProperty(bean,
property);	

So if I extend DynaActionForm (making 
ValidatorDynaActionForm) and add in a validate method
that calls the Validator Framework shouldn't that
work?  The Validator extension of the DynaActionForm
instance would be the bean variable in the example
above.  Hope that was clear.

David

--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> 
> 
> On Wed, 16 Jan 2002, Matt Raible wrote:
> 
> > Date: Wed, 16 Jan 2002 18:59:49 -0700
> > From: Matt Raible <ma...@yahoo.com>
> > Reply-To: Struts Developers List
> <st...@jakarta.apache.org>,
> >      matt@raibledesigns.com
> > To: Struts Developers List
> <st...@jakarta.apache.org>
> > Subject: RE: Self-Initializing  DynaBean ?
> >
> > I'd love to use this, but I'm worried about losing
> the lovely
> > "ValidatorForm" that my BaseForm extends.  Any way
> I can use the Validator
> > form with the "DynaActionForm"?
> >
> 
> Not yet ... we'll need to look at how to integrate
> valiation support
> together with it.
> 
> > Thanks,
> >
> > Matt
> >
> 
> Craig
> 
> 
> > -----Original Message-----
> > From: Craig R. McClanahan
> [mailto:craigmcc@apache.org]
> > Sent: Wednesday, January 16, 2002 5:33 PM
> > To: Struts Developers List
> > Subject: Re: Self-Initializing DynaBean ?
> >
> >
> >
> >
> > On Wed, 16 Jan 2002, Anil Mandava wrote:
> >
> > > Date: Wed, 16 Jan 2002 15:27:25 -0800
> > > From: Anil Mandava <am...@altoweb.com>
> > > Reply-To: Struts Developers List
> <st...@jakarta.apache.org>
> > > To: 'Struts Developers List'
> <st...@jakarta.apache.org>
> > > Subject: Self-Initializing  DynaBean ?
> > >
> > > It would be nice to implement a DynaBean version
> that can self-populate
> > > or self-initialize the properties.
> > >
> > > Say, if it were possible to encode property type
> in the
> > > property name as: "myProp{MyPropClass}"
> > > then the DyanBean's getter/setter can auto add a
> corresponding dyna
> > > property.
> > > This will enable any sub properties of
> MyPropClass to be invoked properly.
> > >
> > > That is all possible, only if we extend the
> property specification to
> > > include {type} part.
> > > Do you feel this is a reasonable thing to do, or
> are there any pitfalls
> > here
> > > ?
> > >
> > > I am more interested in doing this with (Craig's
> soon to come)
> > > DynaActionForm.
> > > My end goal is to have one generic form bean
> (that will work for all
> > > actions).
> > > For such a generic form bean to handle
> multi-level properties
> > > such as "myProp{MyPropClass}.subProp", it has to
> infer and initialize the
> > > first property, so that the setter on the
> subProp can be invoked.
> > >
> > > I am interested in knowing your thoughts and
> opinions on this.
> > > If it does work out and I happen to implement
> it, I will provide a patch.
> > >
> >
> > I just checked in the code for DynaActionForm,
> along with support for it
> > in Struts.  I also added a way to configure the
> initial value for dynamic
> > properties that is used in the reset() method. 
> So, you could preconfigure
> > the logon form's values like this:
> >
> >   <form-bean name="logonForm"
> > type="org.apache.struts.action.DynaActionForm">
> >     <form-property name="username"
> type="java.lang.String" initial="user"/>
> >     <form-property name="password"
> type="java.lang.STring"/>
> >   </form-bean>
> >
> > much the same as you can preinitialize normal
> instance variables with
> > initial values when the bean is created.
> >
> > Does that do what you were looking for?
> >
> > > Thank you all for the great work !
> > > Anil
> > >
> >
> > Craig
> >
> >
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Self-Initializing DynaBean ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 16 Jan 2002, Matt Raible wrote:

> Date: Wed, 16 Jan 2002 18:59:49 -0700
> From: Matt Raible <ma...@yahoo.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>,
>      matt@raibledesigns.com
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: RE: Self-Initializing  DynaBean ?
>
> I'd love to use this, but I'm worried about losing the lovely
> "ValidatorForm" that my BaseForm extends.  Any way I can use the Validator
> form with the "DynaActionForm"?
>

Not yet ... we'll need to look at how to integrate valiation support
together with it.

> Thanks,
>
> Matt
>

Craig


> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: Wednesday, January 16, 2002 5:33 PM
> To: Struts Developers List
> Subject: Re: Self-Initializing DynaBean ?
>
>
>
>
> On Wed, 16 Jan 2002, Anil Mandava wrote:
>
> > Date: Wed, 16 Jan 2002 15:27:25 -0800
> > From: Anil Mandava <am...@altoweb.com>
> > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > To: 'Struts Developers List' <st...@jakarta.apache.org>
> > Subject: Self-Initializing  DynaBean ?
> >
> > It would be nice to implement a DynaBean version that can self-populate
> > or self-initialize the properties.
> >
> > Say, if it were possible to encode property type in the
> > property name as: "myProp{MyPropClass}"
> > then the DyanBean's getter/setter can auto add a corresponding dyna
> > property.
> > This will enable any sub properties of MyPropClass to be invoked properly.
> >
> > That is all possible, only if we extend the property specification to
> > include {type} part.
> > Do you feel this is a reasonable thing to do, or are there any pitfalls
> here
> > ?
> >
> > I am more interested in doing this with (Craig's soon to come)
> > DynaActionForm.
> > My end goal is to have one generic form bean (that will work for all
> > actions).
> > For such a generic form bean to handle multi-level properties
> > such as "myProp{MyPropClass}.subProp", it has to infer and initialize the
> > first property, so that the setter on the subProp can be invoked.
> >
> > I am interested in knowing your thoughts and opinions on this.
> > If it does work out and I happen to implement it, I will provide a patch.
> >
>
> I just checked in the code for DynaActionForm, along with support for it
> in Struts.  I also added a way to configure the initial value for dynamic
> properties that is used in the reset() method.  So, you could preconfigure
> the logon form's values like this:
>
>   <form-bean name="logonForm"
> type="org.apache.struts.action.DynaActionForm">
>     <form-property name="username" type="java.lang.String" initial="user"/>
>     <form-property name="password" type="java.lang.STring"/>
>   </form-bean>
>
> much the same as you can preinitialize normal instance variables with
> initial values when the bean is created.
>
> Does that do what you were looking for?
>
> > Thank you all for the great work !
> > Anil
> >
>
> Craig
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Self-Initializing DynaBean ?

Posted by Matt Raible <ma...@yahoo.com>.
I'd love to use this, but I'm worried about losing the lovely
"ValidatorForm" that my BaseForm extends.  Any way I can use the Validator
form with the "DynaActionForm"?

Thanks,

Matt

-----Original Message-----
From: Craig R. McClanahan [mailto:craigmcc@apache.org]
Sent: Wednesday, January 16, 2002 5:33 PM
To: Struts Developers List
Subject: Re: Self-Initializing DynaBean ?




On Wed, 16 Jan 2002, Anil Mandava wrote:

> Date: Wed, 16 Jan 2002 15:27:25 -0800
> From: Anil Mandava <am...@altoweb.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: 'Struts Developers List' <st...@jakarta.apache.org>
> Subject: Self-Initializing  DynaBean ?
>
> It would be nice to implement a DynaBean version that can self-populate
> or self-initialize the properties.
>
> Say, if it were possible to encode property type in the
> property name as: "myProp{MyPropClass}"
> then the DyanBean's getter/setter can auto add a corresponding dyna
> property.
> This will enable any sub properties of MyPropClass to be invoked properly.
>
> That is all possible, only if we extend the property specification to
> include {type} part.
> Do you feel this is a reasonable thing to do, or are there any pitfalls
here
> ?
>
> I am more interested in doing this with (Craig's soon to come)
> DynaActionForm.
> My end goal is to have one generic form bean (that will work for all
> actions).
> For such a generic form bean to handle multi-level properties
> such as "myProp{MyPropClass}.subProp", it has to infer and initialize the
> first property, so that the setter on the subProp can be invoked.
>
> I am interested in knowing your thoughts and opinions on this.
> If it does work out and I happen to implement it, I will provide a patch.
>

I just checked in the code for DynaActionForm, along with support for it
in Struts.  I also added a way to configure the initial value for dynamic
properties that is used in the reset() method.  So, you could preconfigure
the logon form's values like this:

  <form-bean name="logonForm"
type="org.apache.struts.action.DynaActionForm">
    <form-property name="username" type="java.lang.String" initial="user"/>
    <form-property name="password" type="java.lang.STring"/>
  </form-bean>

much the same as you can preinitialize normal instance variables with
initial values when the bean is created.

Does that do what you were looking for?

> Thank you all for the great work !
> Anil
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Self-Initializing DynaBean ?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 16 Jan 2002, Anil Mandava wrote:

> Date: Wed, 16 Jan 2002 15:27:25 -0800
> From: Anil Mandava <am...@altoweb.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: 'Struts Developers List' <st...@jakarta.apache.org>
> Subject: Self-Initializing  DynaBean ?
>
> It would be nice to implement a DynaBean version that can self-populate
> or self-initialize the properties.
>
> Say, if it were possible to encode property type in the
> property name as: "myProp{MyPropClass}"
> then the DyanBean's getter/setter can auto add a corresponding dyna
> property.
> This will enable any sub properties of MyPropClass to be invoked properly.
>
> That is all possible, only if we extend the property specification to
> include {type} part.
> Do you feel this is a reasonable thing to do, or are there any pitfalls here
> ?
>
> I am more interested in doing this with (Craig's soon to come)
> DynaActionForm.
> My end goal is to have one generic form bean (that will work for all
> actions).
> For such a generic form bean to handle multi-level properties
> such as "myProp{MyPropClass}.subProp", it has to infer and initialize the
> first property, so that the setter on the subProp can be invoked.
>
> I am interested in knowing your thoughts and opinions on this.
> If it does work out and I happen to implement it, I will provide a patch.
>

I just checked in the code for DynaActionForm, along with support for it
in Struts.  I also added a way to configure the initial value for dynamic
properties that is used in the reset() method.  So, you could preconfigure
the logon form's values like this:

  <form-bean name="logonForm" type="org.apache.struts.action.DynaActionForm">
    <form-property name="username" type="java.lang.String" initial="user"/>
    <form-property name="password" type="java.lang.STring"/>
  </form-bean>

much the same as you can preinitialize normal instance variables with
initial values when the bean is created.

Does that do what you were looking for?

> Thank you all for the great work !
> Anil
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>