You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Will Jaynes <ja...@umich.edu> on 2002/01/16 17:37:15 UTC

DynaBean examples?

Does someone have any code demonstrating the use of the DynaBean stuff? 
I'm sure I want to use it, but I need a little kick-start.

Will


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


Re: DynaBean examples?

Posted by Ted Husted <hu...@apache.org>.
Paul Speed wrote:
> Does this mean that we'll be able to use things like HashMaps as our
> form data storage instead of having to build out a full class with
> sets/gets?  If so, that's awesome news.  I long ago got rid of
> presentation layer beans since everything is retrieved and set by
> property name anyway... just made using struts kind of difficult.
> Translation into business objects happens later down the pipeline and
> goes right from Map->Business object.
> 
> -Paul

In the nightly build, you can actually that now, using the extended
syntax. 

On the ActionForm, define these methods to access your map: 

public void setProperty(String key, Object value)
public Object getProperty(String key)

then you can use this notation in the JavaServer Pages

<html:text property="property(key)"/>

and 

<bean:write name="formBean" property="property(key)"/>


But the DynaBeans can use a standard syntax, and can go anywhere a
JavaBean is expected.

Bryan is using DyanBeans in his new persistence layer package, 

http://netmeme.org/simper/


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Building Java web applications with Struts.
-- Tel +1 585 737-3463.
-- Web http://www.husted.com/struts/

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


Re: DynaBean examples?

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

On Wed, 16 Jan 2002, Paul Speed wrote:

> Date: Wed, 16 Jan 2002 14:53:20 -0500
> From: Paul Speed <ps...@progeeks.com>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: Struts Developers List <st...@jakarta.apache.org>
> Subject: Re: DynaBean examples?
>
>
>
> "Craig R. McClanahan" wrote:
> [ snip ]
> >
> > Look for a check-in of DynaActionForm (so that you can define the
> > properties of form beans without having to create a Java clas for every
> > one) real soon now ...
> >
> > Craig
> >
>
> Does this mean that we'll be able to use things like HashMaps as our
> form data storage instead of having to build out a full class with
> sets/gets?

Yes., but as Ted points out you can do that already -- we extended
PropertyUtils a while back to support "mapped" properties, and DynaBeans
have equivalent support.

>  If so, that's awesome news.  I long ago got rid of
> presentation layer beans since everything is retrieved and set by
> property name anyway... just made using struts kind of difficult.
> Translation into business objects happens later down the pipeline and
> goes right from Map->Business object.
>

I'm debugging my DynaActionForm instance right now, which will make this a
standard capability of Struts without giving up the other things that
ActionForm does for you.

> -Paul
>

Craig


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


Re: DynaBean examples?

Posted by Paul Speed <ps...@progeeks.com>.

"Craig R. McClanahan" wrote:
[ snip ]
> 
> Look for a check-in of DynaActionForm (so that you can define the
> properties of form beans without having to create a Java clas for every
> one) real soon now ...
> 
> Craig
> 

Does this mean that we'll be able to use things like HashMaps as our 
form data storage instead of having to build out a full class with
sets/gets?  If so, that's awesome news.  I long ago got rid of 
presentation layer beans since everything is retrieved and set by 
property name anyway... just made using struts kind of difficult.  
Translation into business objects happens later down the pipeline and 
goes right from Map->Business object.

-Paul

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


This is cool. DynaBeans!!

Posted by Phase Communcations <ma...@phase.ws>.
Something to look forward to :-)

Brandon Goodin
Phase Web and Multimedia
P (406) 862-2245
F (406) 862-0354
mail@phase.ws
http://www.phase.ws


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




On Wed, 16 Jan 2002, Will Jaynes wrote:

> Date: Wed, 16 Jan 2002 11:37:15 -0500
> From: Will Jaynes <ja...@umich.edu>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: DynaBean examples?
>
> Does someone have any code demonstrating the use of the DynaBean stuff?
> I'm sure I want to use it, but I need a little kick-start.
>

One place to start would be to look at the unit test programs in the
commons-beanutils nightly source bundle.  But, fundamentally, it's not
totally different from how yo access properties using PropertyUtils, where
you might say:

  MyBean bean = ...;
  String name = PropertyUtils.getSimpleProperty(bean, "name");

you would instead say

  MyBean bean = ...;  // Must implement DynaBean
  String name = bean.get("name");

One very nice feature is that PropertyUtils has been enhanced to
understand DynaBeans internally, so you can actually use *either* syntax
in your application.  That way, all the Struts tags that already use
PropertyUtils will be able to auto-magically work with DynaBeans as well.

Look for a check-in of DynaActionForm (so that you can define the
properties of form beans without having to create a Java clas for every
one) real soon now ...

> Will
>

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: DynaBean examples?

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

On Wed, 16 Jan 2002, Will Jaynes wrote:

> Date: Wed, 16 Jan 2002 11:37:15 -0500
> From: Will Jaynes <ja...@umich.edu>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: DynaBean examples?
>
> Does someone have any code demonstrating the use of the DynaBean stuff?
> I'm sure I want to use it, but I need a little kick-start.
>

One place to start would be to look at the unit test programs in the
commons-beanutils nightly source bundle.  But, fundamentally, it's not
totally different from how yo access properties using PropertyUtils, where
you might say:

  MyBean bean = ...;
  String name = PropertyUtils.getSimpleProperty(bean, "name");

you would instead say

  MyBean bean = ...;  // Must implement DynaBean
  String name = bean.get("name");

One very nice feature is that PropertyUtils has been enhanced to
understand DynaBeans internally, so you can actually use *either* syntax
in your application.  That way, all the Struts tags that already use
PropertyUtils will be able to auto-magically work with DynaBeans as well.

Look for a check-in of DynaActionForm (so that you can define the
properties of form beans without having to create a Java clas for every
one) real soon now ...

> Will
>

Craig


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