You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by wb...@Ensign-BickfordInd.com on 2002/07/01 16:39:46 UTC

DynaBeans, DynaClass, DynaMen

...anyone remember DynaMen?  

Anyhow...  I got a Dynabean mechanism working that builds a DynaBean 
based on the metadata of a SQL result set, populates and array of the 
little buggers and passes it back to me.  For displaying I have a tag 
library that does not like a call to get('name') as the field name.   
What is the best way to get around this?

(A) Write a bean to encapsulate the dynabean and provide hard method 
gets and sets
(B) Modify the tag library to detect a DynaBean and access it via a get 
and set (not my library)
(C) Don't use dynabeans for this sort of thing
(D) None of the above you dufus

I can do any of the above - I just want to make sure that there is not 
an obvious way I am missing.

Thanks and happy monday



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


Re: DynaBeans, DynaClass, DynaMen

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

On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:

> Date: Fri, 12 Jul 2002 07:02:57 +0200
> From: Thorbjoern Ravn Andersen <tr...@biobase.dk>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> wbchmura@Ensign-BickfordInd.com skrev:
>
> >...anyone remember DynaMen?
> >
> >Anyhow...  I got a Dynabean mechanism working that builds a DynaBean
> >based on the metadata of a SQL result set, populates and array of the
> >little buggers and passes it back to me.  For displaying I have a tag
> >library that does not like a call to get('name') as the field name.
> >What is the best way to get around this?
> >
> I wrote an AnonyBeans package which uses BCEL to generate beans on the
> fly based on a ResultSet.  It is alpha code but works for me, and is
> usable anywhere where you need a real traditional bean, but where you do
> not want to serialize it or  use its type in Java source.
>
> Is this interesting?
>

I think it would be  interestesting, even though it might not be
universally useful (some containers won't let you introduce new classes at
runtime).

I'd also be interested in a mechanism that converted a ResultSet into a
custom DynaClass, with a corresponding DynaBean for each row.  This would
be trivially simple to do -- so simple that it probably makes a worthwhile
addition to commons-beanutils itself if someone wanted to take this on.

This wouldn't help you create dynamic input forms, but it would make a
completely flexible bean-like wrapper around a result set so you can use
Struts tags to display stuff.

> --
>   Thorbjørn Ravn Andersen                 http://biobase.dk/~tra

Craig


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


Re: DynaBeans, DynaClass, DynaMen

Posted by Thorbjoern Ravn Andersen <tr...@biobase.dk>.
wbchmura@Ensign-BickfordInd.com skrev:

>...anyone remember DynaMen?  
>
>Anyhow...  I got a Dynabean mechanism working that builds a DynaBean 
>based on the metadata of a SQL result set, populates and array of the 
>little buggers and passes it back to me.  For displaying I have a tag 
>library that does not like a call to get('name') as the field name.   
>What is the best way to get around this?
>
I wrote an AnonyBeans package which uses BCEL to generate beans on the 
fly based on a ResultSet.  It is alpha code but works for me, and is 
usable anywhere where you need a real traditional bean, but where you do 
not want to serialize it or  use its type in Java source.

Is this interesting?

-- 
  Thorbjørn Ravn Andersen                 http://biobase.dk/~tra
  Scandiatransplant, Skejby Hospital
  Brendstrupgaardsvej, Entrance 3
  DK-8200 Århus N                         +45 89 49 53 01




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


Re: DynaBeans, DynaClass, DynaMen

Posted by Cliff Rowley <cl...@onsea.net>.
wbchmura@Ensign-BickfordInd.com wrote:

> Anyhow...  I got a Dynabean mechanism working that builds a DynaBean 
> based on the metadata of a SQL result set, populates and array of the 
> little buggers and passes it back to me.  For displaying I have a tag 
> library that does not like a call to get('name') as the field name.   
> What is the best way to get around this?

I presume you mean a non struts-aware tag library?

> (A) Write a bean to encapsulate the dynabean and provide hard method 
> gets and sets
> (B) Modify the tag library to detect a DynaBean and access it via a get 
> and set (not my library)
> (C) Don't use dynabeans for this sort of thing
> (D) None of the above you dufus

Another approach (I've not tried it, so I can't comment on 
success/failure) could be to use a proxy class (reflection) and a proxy 
interface for the dynabeans you want to access.  It's not much different 
from option (A), but if you were to meet the same requirement in several 
different places it would save you some time.  You can see this kind of 
approach in CMP EJB, where the interface declares the methods that may 
be called and the proxy takes care of the implementation.

> Thanks and happy monday

Bah. ;)

Cliff Rowley


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


Re: DynaBeans, DynaClass, DynaMen

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

On Mon, 1 Jul 2002, Cliff Rowley wrote:

> Date: Mon, 01 Jul 2002 18:42:24 +0100
> From: Cliff Rowley <cl...@onsea.net>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> Craig R. McClanahan wrote:
>
> > The standard methods in BeanUtils and PropertyUtils know how to deal with
> > DynaBeans already (essentially your option (B)).  That is why all of the
> > Struts tags can deal with DynaBeans or standard JavaBeans with no changes.
> > Is there a reason you can't use things like <bean:write> directly on your
> > DynaBeans as well?
>
> Cheers Craig, I've not had a chance to look at BeanUtils and
> PropertyUtils in depth yet - its on my list, along with another million
> things.  I was under the impression that the Struts tags had 'special
> support' for the dyna elements - I learned something new today :)
>

They do have special support ... BeanUtils and PropertyUtils :-).

Of course, we're talking about Struts 1.1, which is based on
commons-beanutils.  None of this applies to Struts 1.0, which had the
previous versions of these classes built in.

Craig


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


Re: DynaBeans, DynaClass, DynaMen

Posted by Cliff Rowley <cl...@onsea.net>.
Craig R. McClanahan wrote:

> The standard methods in BeanUtils and PropertyUtils know how to deal with
> DynaBeans already (essentially your option (B)).  That is why all of the
> Struts tags can deal with DynaBeans or standard JavaBeans with no changes.
> Is there a reason you can't use things like <bean:write> directly on your
> DynaBeans as well?

Cheers Craig, I've not had a chance to look at BeanUtils and 
PropertyUtils in depth yet - its on my list, along with another million 
things.  I was under the impression that the Struts tags had 'special 
support' for the dyna elements - I learned something new today :)


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


Re: DynaBeans, DynaClass, DynaMen

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

On Mon, 1 Jul 2002 wbchmura@Ensign-BickfordInd.com wrote:

> Date: Mon, 1 Jul 2002 10:39:46 -0400
> From: wbchmura@Ensign-BickfordInd.com
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: struts-user@jakarta.apache.org
> Subject: DynaBeans, DynaClass, DynaMen
>
>
> ...anyone remember DynaMen?
>
> Anyhow...  I got a Dynabean mechanism working that builds a DynaBean
> based on the metadata of a SQL result set, populates and array of the
> little buggers and passes it back to me.  For displaying I have a tag
> library that does not like a call to get('name') as the field name.
> What is the best way to get around this?
>
> (A) Write a bean to encapsulate the dynabean and provide hard method
> gets and sets
> (B) Modify the tag library to detect a DynaBean and access it via a get
> and set (not my library)
> (C) Don't use dynabeans for this sort of thing
> (D) None of the above you dufus
>

The standard methods in BeanUtils and PropertyUtils know how to deal with
DynaBeans already (essentially your option (B)).  That is why all of the
Struts tags can deal with DynaBeans or standard JavaBeans with no changes.
Is there a reason you can't use things like <bean:write> directly on your
DynaBeans as well?

> I can do any of the above - I just want to make sure that there is not
> an obvious way I am missing.
>
> Thanks and happy monday
>

Craig


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