RE: DynaBeans, DynaClass, DynaMen

2002-07-15 Thread Craig R. McClanahan



On Mon, 15 Jul 2002, Anjana Wijayaweera wrote:

> Date: Mon, 15 Jul 2002 20:14:33 +0600
> From: Anjana Wijayaweera <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: RE: DynaBeans, DynaClass, DynaMen
>
> Hi All,
>
>   I need to know if there is any Struts Tag being developed for 1.1
> whiich supports Dynabeans in a
> truely dynamic way.
>

For form beans, there is no support for "completely dynamic" beans in the
sense that you are talking about, and such support is very unlikely to get
added before 1.1 final is released (we need to get it out the door).
There are some interesting complications to designing such a thing,
because Struts needs to know what the properties are *before* it can
populate the form bean.

For displaying information, the existing tags like  already
fully support DynaBean instances, and don't care where they came from.
Remember that org.apache.commons.beanutils.DynaBean is an *interface*, so
you can create your own custom implementations -- for example, the
ResultSetDynaClass implementation discussed earlier in this message thread
is an example of creating "completely dynamic" DynaBeans from a result
set.  The iterator returned by this class could easily be used, for
example, inside a  loop to display the corresponding
values, as long as you obey the programming restrictions.

Craig



> I have seen examples which go like this
>   BUT this doesn't answer
> my requirement since I need to have a really
> dynamic page and won't be knowing  what the name of the property is which is
> a requirement to use the bean :write tag.
>
> My requirement is to read from a database table a list of custom fields
> which may vary from zero, one to many
> and I have no way of knowing the names of the fields since its dynamic. I
> want to handle this within the
> Struts framework therfore if you have any ideas let me know. I am open to
> any suggestions.
>
>
>
> Regards,
> Anjana
>
>
>
>
> From: Adolfo Miguelez
> Subject: RE: DynaBeans, DynaClass, DynaMen
> Date: Mon, 01 Jul 2002 09:54:52 -0700
>
> 
> 
>
>
> By using dynabeans should not need to modify the custom tags at all.
> BeansUtils package is able to inspect dynabeans itself.
>
> The advantage is that you have not to worry about making your modified
> custom tags for each new release.
>
> Adolfo
>
> >From: [EMAIL PROTECTED]
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: RE: DynaBeans, DynaClass, DynaMen
> >Date: Mon, 1 Jul 2002 12:10:51 -0400
> >
> >
> >Yep, the display tag library...
> >
> >I spent some time looking at the source last night, and modifying it
> >should not be that bad...
> >
> >Thanks for the feedback!
> >
> >-Original Message-
> >From: pelly69 [mailto:[EMAIL PROTECTED]]
> >Sent: Monday, July 01, 2002 11:05 AM
> >To: struts-user
> >Subject: Re: DynaBeans, DynaClass, DynaMen
> >
> >
> >I have implemented the same approach: getting results from a database
> >query
> >and wrap them in an ArrayList of dynabeans. In that way I can use the
> >Struts
> >Customs tags in order to render the dynabeans content in the JSP.
> >
> >Custom Tags rely on Commons BeanUtils package which is able to inspect
> >any
> >Java Bean or Dynabean to pick up the information.
> >
> >I think your approach is correct,
> >
> >Adolfo.
> >
> >
> > >From: [EMAIL PROTECTED]
> > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: DynaBeans, DynaClass, DynaMen
> > >Date: Mon, 1 Jul 2002 10:39:46 -0400
> > >
> > >
> > >...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:   <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]>




RE: DynaBeans, DynaClass, DynaMen

2002-07-15 Thread Adolfo Miguelez

I use to run in the same issue quite often, and use to solve it by:


 


where data is a collection e.g. of Strings, with the parameter names, and 
the properties of the dynabean match exactly this parameter names.

Works for me but, actually a hate to use the scriplet. It is necessary, 
AFAIK, since Custom tags in JSP 1.1  does not handle embedded tags.

More suggestion are welcome also for me,

regards,

Adolfo

>From: Anjana Wijayaweera <[EMAIL PROTECTED]>
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: Struts Users Mailing List <[EMAIL PROTECTED]>
>Subject: RE: DynaBeans, DynaClass, DynaMen
>Date: Mon, 15 Jul 2002 20:14:33 +0600
>
>Hi All,
>
>   I need to know if there is any Struts Tag being developed for 1.1
>whiich supports Dynabeans in a
>truely dynamic way.
>
>I have seen examples which go like this
>  BUT this doesn't answer
>my requirement since I need to have a really
>dynamic page and won't be knowing  what the name of the property is which 
>is
>a requirement to use the bean :write tag.
>
>My requirement is to read from a database table a list of custom fields
>which may vary from zero, one to many
>and I have no way of knowing the names of the fields since its dynamic. I
>want to handle this within the
>Struts framework therfore if you have any ideas let me know. I am open to
>any suggestions.
>
>
>
>Regards,
>Anjana
>
>
>
>
>From: Adolfo Miguelez
>Subject: RE: DynaBeans, DynaClass, DynaMen
>Date: Mon, 01 Jul 2002 09:54:52 -0700
>
>
>
>
>
>By using dynabeans should not need to modify the custom tags at all.
>BeansUtils package is able to inspect dynabeans itself.
>
>The advantage is that you have not to worry about making your modified
>custom tags for each new release.
>
>Adolfo
>
> >From: [EMAIL PROTECTED]
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: RE: DynaBeans, DynaClass, DynaMen
> >Date: Mon, 1 Jul 2002 12:10:51 -0400
> >
> >
> >Yep, the display tag library...
> >
> >I spent some time looking at the source last night, and modifying it
> >should not be that bad...
> >
> >Thanks for the feedback!
> >
> >-Original Message-
> >From: pelly69 [mailto:[EMAIL PROTECTED]]
> >Sent: Monday, July 01, 2002 11:05 AM
> >To: struts-user
> >Subject: Re: DynaBeans, DynaClass, DynaMen
> >
> >
> >I have implemented the same approach: getting results from a database
> >query
> >and wrap them in an ArrayList of dynabeans. In that way I can use the
> >Struts
> >Customs tags in order to render the dynabeans content in the JSP.
> >
> >Custom Tags rely on Commons BeanUtils package which is able to inspect
> >any
> >Java Bean or Dynabean to pick up the information.
> >
> >I think your approach is correct,
> >
> >Adolfo.
> >
> >
> > >From: [EMAIL PROTECTED]
> > >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: DynaBeans, DynaClass, DynaMen
> > >Date: Mon, 1 Jul 2002 10:39:46 -0400
> > >
> > >
> > >...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:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>





  
 Adolfo's signature
  
  
 Adolfo Rodriguez Miguelez

  
  





_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




RE: DynaBeans, DynaClass, DynaMen

2002-07-15 Thread Anjana Wijayaweera

Hi All,

I need to know if there is any Struts Tag being developed for 1.1
whiich supports Dynabeans in a 
truely dynamic way. 

I have seen examples which go like this 
  BUT this doesn't answer
my requirement since I need to have a really 
dynamic page and won't be knowing  what the name of the property is which is
a requirement to use the bean :write tag. 

My requirement is to read from a database table a list of custom fields
which may vary from zero, one to many
and I have no way of knowing the names of the fields since its dynamic. I
want to handle this within the 
Struts framework therfore if you have any ideas let me know. I am open to
any suggestions.  



Regards,
Anjana




From: Adolfo Miguelez 
Subject: RE: DynaBeans, DynaClass, DynaMen 
Date: Mon, 01 Jul 2002 09:54:52 -0700 





By using dynabeans should not need to modify the custom tags at all. 
BeansUtils package is able to inspect dynabeans itself.

The advantage is that you have not to worry about making your modified 
custom tags for each new release.

Adolfo

>From: [EMAIL PROTECTED]
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: RE: DynaBeans, DynaClass, DynaMen
>Date: Mon, 1 Jul 2002 12:10:51 -0400
>
>
>Yep, the display tag library...
>
>I spent some time looking at the source last night, and modifying it
>should not be that bad...
>
>Thanks for the feedback!
>
>-Original Message-
>From: pelly69 [mailto:[EMAIL PROTECTED]]
>Sent: Monday, July 01, 2002 11:05 AM
>To: struts-user
>Subject: Re: DynaBeans, DynaClass, DynaMen
>
>
>I have implemented the same approach: getting results from a database
>query
>and wrap them in an ArrayList of dynabeans. In that way I can use the
>Struts
>Customs tags in order to render the dynabeans content in the JSP.
>
>Custom Tags rely on Commons BeanUtils package which is able to inspect
>any
>Java Bean or Dynabean to pick up the information.
>
>I think your approach is correct,
>
>Adolfo.
>
>
> >From: [EMAIL PROTECTED]
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: DynaBeans, DynaClass, DynaMen
> >Date: Mon, 1 Jul 2002 10:39:46 -0400
> >
> >
> >...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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: DynaBeans, DynaClass, DynaMen

2002-07-15 Thread wbchmura


Yeah, the type conversions were a know deficency in my code. 


-Original Message-
From: craigmcc [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 6:45 PM
To: struts-user
Subject: RE: DynaBeans, DynaClass, DynaMen


I implemented something a little more memory-efficient than this 
(doesn't
require the entire result set to be in memory) in tonight's nightly 
build
of commons-beanutils, which will therefore be available in the 20020713
nightly build of Struts.  You use it something like this:

  Connection conn = ...;
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery("select * from customers");
  Iterator rows = (new ResultSetDynaClass(rs)).iterator();
  while (rows.hasNext()) {
DynaBean row = (DynaBean) rows.next();
System.out.println("Processing customer " + row.get("account_id"));
... access this row as a DynaBean ...
  }
  rs.close();
  stmt.close();

I elected to avoid doing the type conversions, so the properties you get
back will correspond to their types in the database.

Craig


On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:

> Date: Fri, 12 Jul 2002 13:56:38 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: RE: DynaBeans, DynaClass, DynaMen
>
>
>
> Here is what I am using...  Very simple and only returns strings...
>
>
>   /**
> * Converts a resultset into an ArrayList of DynaBeans
> *
> * @param resultSet SQL result set to be converted
> * @return ArrayList of DynaBeans with all columnnames converted to
> * lowercase
> * @throws SQLException DOCUMENT ME!
> */
>private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>   throws SQLException {
>
>   ResultSetMetaData metaData = resultSet.getMetaData();
>   int cols = metaData.getColumnCount();
>   ArrayList list = new ArrayList();
>   DynaProperty[] props = new DynaProperty[cols];
>   BasicDynaClass dClass = null;
>
>   for (int i = 1; i <= cols; i++) {
>  props[i - 1] = new
> DynaProperty(metaData.getColumnName(i).toLowerCase());
>   }
>
>   try {
>  dClass = new BasicDynaClass("test",
>  Class.forName(
>
> "org.apache.commons.beanutils.BasicDynaBean"),
>  props);
>   } catch (Exception e) {
>  e.printStackTrace();
>   }
>
>   while (resultSet.next()) {
>
>  HashMap map = new HashMap(cols, 1);
>
>  for (int i = 1; i <= cols; i++) {
> map.put(metaData.getColumnName(i).toLowerCase(),
> resultSet.getString(i));
>  }
>
>  try {
>
> DynaBean dbean = dClass.newInstance();
> BeanUtils.populate(dbean, map);
> list.add(dbean);
>  } catch (Exception e) {
> e.printStackTrace();
> throw new SQLException("RequestUtils.getArrayList: "
>                + e.toString());
>  }
>   } // End While
>
>   return (list);
>}
>
>
> -Original Message-
> From: craigmcc [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 12, 2002 12:07 PM
> To: struts-user
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
>
>
>
> On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:
>
> > Date: Fri, 12 Jul 2002 07:02:57 +0200
> > From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > Subject: Re: DynaBeans, DynaClass, DynaMen
> >
> > [EMAIL PROTECTED] 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 use

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: "Vic C." <[EMAIL PROTECTED]>
 ===
But... if it does not copy... what happens to RowSet connection while 
the data is on the page?
RowSet has to be disconnected while the use sees it on the page, so I am 
not keeping the connection open.
And then if the users does sets, I have to create a prepared statment 
and use MetaData (getTableName, etc.) to create a SQL string and create 
a new connection.
Let me wait and see it tmrw. I want to use it instead of CacheRowSet if 
I can but it has to be disconnected, etc.
Thanks much,
Vic


Craig R. McClanahan wrote:
> 
> On Fri, 12 Jul 2002, Struts Newsgroup wrote:
> 
> 
>>Date: Fri, 12 Jul 2002 18:55:02 -0700
>>From: Struts Newsgroup <[EMAIL PROTECTED]>
>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>
>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>From: "Vic C." <[EMAIL PROTECTED]>
>> ===
>>Sorry, excited: I see:
>>DynaProperty.getType() ;
>>So based on it I can get the type, and create an "UPDATE TABLE SET X = Y
>>  WHERE Z=K" in a base class. Cool.
>>I wonder about original values for a reset, etc.
>>
> 
> 
> The iterator that is returned by ResultSetDynaClass doesn't actually copy
> the data or create new objects -- it's mapped directly to the values in
> the underlying ResultSet.  In other words, calling get() on the DynaBean
> actually does a getObject() call on the ResultSet.  Likewise, calling
> set() on the DynaBean actually calls updateObject() on the ResultSet,
> meaining you have live updates just as if you had done them directly.
> 
> Right now, the code assumes a one-forward-pass result set that doesn't
> support scrolling.  It wouldn't be too hard to make it deal with
> scrollable result sets as well -- for example, add a method to return a
> DynaBean for an arbitrary row number (triggering a call to absolute() to
> set the position first).  Lots of interesting stuff becomes possible.
> 
> 
>>Vic
>>
> 
> 
> Craig
> 
> 
> 
>>Vic C. wrote:
>>
>>>And... can we give it a datasource argument (instead of con) and use
>>>RowSet instead of ResultSet?
>>>
>>>Vic
>>>
>>>Vic C. wrote:
>>>
>>>
>>>>Looks a bit like
>>>>http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
>>>>listing #3  of disconnected row set.
>>>>
>>>>Can we get metaData out of it so I can write "auto" updates?
>>>>So a DAO that has a Iterator of DynaBeans.
>>>>Where is DynaBean? Commons?
>>>>
>>>>Vic
>>>>
>>>>Craig R. McClanahan wrote:
>>>>
>>>>
>>>>>I implemented something a little more memory-efficient than this
>>>>>(doesn't
>>>>>require the entire result set to be in memory) in tonight's nightly
>>>>>build
>>>>>of commons-beanutils, which will therefore be available in the 20020713
>>>>>nightly build of Struts.  You use it something like this:
>>>>>
>>>>>  Connection conn = ...;
>>>>>  Statement stmt = conn.createStatement();
>>>>>  ResultSet rs = stmt.executeQuery("select * from customers");
>>>>>  Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>>>>>  while (rows.hasNext()) {
>>>>>DynaBean row = (DynaBean) rows.next();
>>>>>System.out.println("Processing customer " + row.get("account_id"));
>>>>>... access this row as a DynaBean ...
>>>>>  }
>>>>>  rs.close();
>>>>>  stmt.close();
>>>>>
>>>>>I elected to avoid doing the type conversions, so the properties you get
>>>>>back will correspond to their types in the database.
>>>>>
>>>>>Craig
>>>>>
>>>>>
>>>>>On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Date: Fri, 12 Jul 2002 13:56:38 -0400
>>>>>>From: [EMAIL PROTECTED]
>>>>>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>>>>>To: [EMAIL PROTECTED]
>>>>>>Subject: RE: DynaBeans, DynaClass, DynaMen
>>>>>>
>>>>>>
>>>>>>
>>>>>>Here is what I am using...  Very simple and onl

RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Martin Cooper

But this stuff is so cool, it's got me thinking about using it deep in my
model code too. Simplify and generalise at the same time - I like that!

--
Martin Cooper


> -Original Message-
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 12, 2002 7:24 PM
> To: Struts Users Mailing List
> Cc: [EMAIL PROTECTED]
> Subject: RE: DynaBeans, DynaClass, DynaMen
> 
> 
> 
> 
> On Fri, 12 Jul 2002, Martin Cooper wrote:
> 
> > Date: Fri, 12 Jul 2002 17:03:24 -0700
> > From: Martin Cooper <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> > Subject: RE: DynaBeans, DynaClass, DynaMen
> >
> > Cool beans! (Yes, pun intended - it's Friday, right? :)
> >
> 
> Yep -- DynaBeans are dyna enough for all sorts of stuff :-).
> 
> I just finished working on one more refinement to help Struts 
> folks copy
> properties from a form bean to a model bean (complete with type
> conversion) without the strange things that 
> BeanUtils.populate() does).
> Check out the new BeanUtils.copyProperties() method in tonight's
> (20020713) nightly build.
> 
> > --
> > Martin Cooper
> >
> 
> Craig
> 
> >
> > > -----Original Message-
> > > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, July 12, 2002 3:45 PM
> > > To: Struts Users Mailing List
> > > Subject: RE: DynaBeans, DynaClass, DynaMen
> > >
> > >
> > > I implemented something a little more memory-efficient than
> > > this (doesn't
> > > require the entire result set to be in memory) in tonight's
> > > nightly build
> > > of commons-beanutils, which will therefore be available in
> > > the 20020713
> > > nightly build of Struts.  You use it something like this:
> > >
> > >   Connection conn = ...;
> > >   Statement stmt = conn.createStatement();
> > >   ResultSet rs = stmt.executeQuery("select * from customers");
> > >   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
> > >   while (rows.hasNext()) {
> > > DynaBean row = (DynaBean) rows.next();
> > > System.out.println("Processing customer " +
> > > row.get("account_id"));
> > > ... access this row as a DynaBean ...
> > >   }
> > >   rs.close();
> > >   stmt.close();
> > >
> > > I elected to avoid doing the type conversions, so the
> > > properties you get
> > > back will correspond to their types in the database.
> > >
> > > Craig
> > >
> > >
> > > On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> > >
> > > > Date: Fri, 12 Jul 2002 13:56:38 -0400
> > > > From: [EMAIL PROTECTED]
> > > > Reply-To: Struts Users Mailing List 
> <[EMAIL PROTECTED]>
> > > > To: [EMAIL PROTECTED]
> > > > Subject: RE: DynaBeans, DynaClass, DynaMen
> > > >
> > > >
> > > >
> > > > Here is what I am using...  Very simple and only 
> returns strings...
> > > >
> > > >
> > > >   /**
> > > > * Converts a resultset into an ArrayList of DynaBeans
> > > > *
> > > > * @param resultSet SQL result set to be converted
> > > > * @return ArrayList of DynaBeans with all columnnames
> > > converted to
> > > > * lowercase
> > > > * @throws SQLException DOCUMENT ME!
> > > > */
> > > >private static ArrayList getDynaBeanArrayList(ResultSet
> > > resultSet)
> > > >   throws SQLException {
> > > >
> > > >   ResultSetMetaData metaData = resultSet.getMetaData();
> > > >   int cols = metaData.getColumnCount();
> > > >   ArrayList list = new ArrayList();
> > > >   DynaProperty[] props = new DynaProperty[cols];
> > > >   BasicDynaClass dClass = null;
> > > >
> > > >   for (int i = 1; i <= cols; i++) {
> > > >  props[i - 1] = new
> > > > DynaProperty(metaData.getColumnName(i).toLowerCase());
> > > >   }
> > > >
> > > >   try {
> > > >  dClass = new BasicDynaClass("test",
> > > >  Class.forName(
> > > >
> > > > "org.

RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan



On Fri, 12 Jul 2002, Martin Cooper wrote:

> Date: Fri, 12 Jul 2002 17:03:24 -0700
> From: Martin Cooper <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: 'Struts Users Mailing List' <[EMAIL PROTECTED]>
> Subject: RE: DynaBeans, DynaClass, DynaMen
>
> Cool beans! (Yes, pun intended - it's Friday, right? :)
>

Yep -- DynaBeans are dyna enough for all sorts of stuff :-).

I just finished working on one more refinement to help Struts folks copy
properties from a form bean to a model bean (complete with type
conversion) without the strange things that BeanUtils.populate() does).
Check out the new BeanUtils.copyProperties() method in tonight's
(20020713) nightly build.

> --
> Martin Cooper
>

Craig

>
> > -Original Message-
> > From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, July 12, 2002 3:45 PM
> > To: Struts Users Mailing List
> > Subject: RE: DynaBeans, DynaClass, DynaMen
> >
> >
> > I implemented something a little more memory-efficient than
> > this (doesn't
> > require the entire result set to be in memory) in tonight's
> > nightly build
> > of commons-beanutils, which will therefore be available in
> > the 20020713
> > nightly build of Struts.  You use it something like this:
> >
> >   Connection conn = ...;
> >   Statement stmt = conn.createStatement();
> >   ResultSet rs = stmt.executeQuery("select * from customers");
> >   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
> >   while (rows.hasNext()) {
> > DynaBean row = (DynaBean) rows.next();
> > System.out.println("Processing customer " +
> > row.get("account_id"));
> > ... access this row as a DynaBean ...
> >   }
> >   rs.close();
> >   stmt.close();
> >
> > I elected to avoid doing the type conversions, so the
> > properties you get
> > back will correspond to their types in the database.
> >
> > Craig
> >
> >
> > On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> >
> > > Date: Fri, 12 Jul 2002 13:56:38 -0400
> > > From: [EMAIL PROTECTED]
> > > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > > To: [EMAIL PROTECTED]
> > > Subject: RE: DynaBeans, DynaClass, DynaMen
> > >
> > >
> > >
> > > Here is what I am using...  Very simple and only returns strings...
> > >
> > >
> > >   /**
> > > * Converts a resultset into an ArrayList of DynaBeans
> > > *
> > > * @param resultSet SQL result set to be converted
> > > * @return ArrayList of DynaBeans with all columnnames
> > converted to
> > > * lowercase
> > > * @throws SQLException DOCUMENT ME!
> > > */
> > >private static ArrayList getDynaBeanArrayList(ResultSet
> > resultSet)
> > >   throws SQLException {
> > >
> > >   ResultSetMetaData metaData = resultSet.getMetaData();
> > >   int cols = metaData.getColumnCount();
> > >   ArrayList list = new ArrayList();
> > >   DynaProperty[] props = new DynaProperty[cols];
> > >   BasicDynaClass dClass = null;
> > >
> > >   for (int i = 1; i <= cols; i++) {
> > >  props[i - 1] = new
> > > DynaProperty(metaData.getColumnName(i).toLowerCase());
> > >   }
> > >
> > >   try {
> > >  dClass = new BasicDynaClass("test",
> > >  Class.forName(
> > >
> > > "org.apache.commons.beanutils.BasicDynaBean"),
> > >  props);
> > >   } catch (Exception e) {
> > >  e.printStackTrace();
> > >   }
> > >
> > >   while (resultSet.next()) {
> > >
> > >  HashMap map = new HashMap(cols, 1);
> > >
> > >  for (int i = 1; i <= cols; i++) {
> > > map.put(metaData.getColumnName(i).toLowerCase(),
> > > resultSet.getString(i));
> > >  }
> > >
> > >  try {
> > >
> > > DynaBean dbean = dClass.newInstance();
> > > BeanUtils.populate(dbean, map);
> > >     list.add(dbean);
> > >  } catch (Exception e) {
> > > e.printStackTrace();
> > > throw new SQLException(&q

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan



On Fri, 12 Jul 2002, Struts Newsgroup wrote:

> Date: Fri, 12 Jul 2002 18:55:01 -0700
> From: Struts Newsgroup <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> Subject: Re: DynaBeans, DynaClass, DynaMen
> From: "Vic C." <[EMAIL PROTECTED]>
>  ===
> And... can we give it a datasource argument (instead of con) and use
> RowSet instead of ResultSet?
>

A RowSet is a subclass of a ResultSet, so you can definitely use that.

ResultSetDynaClass doesn't care where the ResultSet (or RowSet) you gave
it comes from -- it could even be one of the disconnected RowSet
implementations.  So, you could certainly start from a DataSource to
acquire the Connection you are using.

> Vic

Craig


>
> Vic C. wrote:
> > Looks a bit like
> > http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
> > listing #3  of disconnected row set.
> >
> > Can we get metaData out of it so I can write "auto" updates?
> > So a DAO that has a Iterator of DynaBeans.
> > Where is DynaBean? Commons?
> >
> > Vic
> >
> > Craig R. McClanahan wrote:
> >
> >> I implemented something a little more memory-efficient than this (doesn't
> >> require the entire result set to be in memory) in tonight's nightly build
> >> of commons-beanutils, which will therefore be available in the 20020713
> >> nightly build of Struts.  You use it something like this:
> >>
> >>   Connection conn = ...;
> >>   Statement stmt = conn.createStatement();
> >>   ResultSet rs = stmt.executeQuery("select * from customers");
> >>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
> >>   while (rows.hasNext()) {
> >> DynaBean row = (DynaBean) rows.next();
> >> System.out.println("Processing customer " + row.get("account_id"));
> >> ... access this row as a DynaBean ...
> >>   }
> >>   rs.close();
> >>   stmt.close();
> >>
> >> I elected to avoid doing the type conversions, so the properties you get
> >> back will correspond to their types in the database.
> >>
> >> Craig
> >>
> >>
> >> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> >>
> >>
> >>> Date: Fri, 12 Jul 2002 13:56:38 -0400
> >>> From: [EMAIL PROTECTED]
> >>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> >>> To: [EMAIL PROTECTED]
> >>> Subject: RE: DynaBeans, DynaClass, DynaMen
> >>>
> >>>
> >>>
> >>> Here is what I am using...  Very simple and only returns strings...
> >>>
> >>>
> >>>  /**
> >>>* Converts a resultset into an ArrayList of DynaBeans
> >>>*
> >>>* @param resultSet SQL result set to be converted
> >>>* @return ArrayList of DynaBeans with all columnnames converted to
> >>>* lowercase
> >>>* @throws SQLException DOCUMENT ME!
> >>>*/
> >>>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
> >>>  throws SQLException {
> >>>
> >>>  ResultSetMetaData metaData = resultSet.getMetaData();
> >>>  int cols = metaData.getColumnCount();
> >>>  ArrayList list = new ArrayList();
> >>>  DynaProperty[] props = new DynaProperty[cols];
> >>>  BasicDynaClass dClass = null;
> >>>
> >>>  for (int i = 1; i <= cols; i++) {
> >>> props[i - 1] = new
> >>> DynaProperty(metaData.getColumnName(i).toLowerCase());
> >>>  }
> >>>
> >>>  try {
> >>> dClass = new BasicDynaClass("test",
> >>> Class.forName(
> >>>
> >>> "org.apache.commons.beanutils.BasicDynaBean"),
> >>> props);
> >>>  } catch (Exception e) {
> >>>     e.printStackTrace();
> >>>  }
> >>>
> >>>  while (resultSet.next()) {
> >>>
> >>> HashMap map = new HashMap(cols, 1);
> >>>
> >>> for (int i = 1; i <= cols; i++) {
> >>>map.put(metaData.getColumnName(i).toLowerCase(),
> >>>        resultSet.getString(i));
> >>

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan



On Fri, 12 Jul 2002, Struts Newsgroup wrote:

> Date: Fri, 12 Jul 2002 18:55:02 -0700
> From: Struts Newsgroup <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> Subject: Re: DynaBeans, DynaClass, DynaMen
> From: "Vic C." <[EMAIL PROTECTED]>
>  ===
> Sorry, excited: I see:
> DynaProperty.getType() ;
> So based on it I can get the type, and create an "UPDATE TABLE SET X = Y
>   WHERE Z=K" in a base class. Cool.
> I wonder about original values for a reset, etc.
>

The iterator that is returned by ResultSetDynaClass doesn't actually copy
the data or create new objects -- it's mapped directly to the values in
the underlying ResultSet.  In other words, calling get() on the DynaBean
actually does a getObject() call on the ResultSet.  Likewise, calling
set() on the DynaBean actually calls updateObject() on the ResultSet,
meaining you have live updates just as if you had done them directly.

Right now, the code assumes a one-forward-pass result set that doesn't
support scrolling.  It wouldn't be too hard to make it deal with
scrollable result sets as well -- for example, add a method to return a
DynaBean for an arbitrary row number (triggering a call to absolute() to
set the position first).  Lots of interesting stuff becomes possible.

> Vic
>

Craig


> Vic C. wrote:
> > And... can we give it a datasource argument (instead of con) and use
> > RowSet instead of ResultSet?
> >
> > Vic
> >
> > Vic C. wrote:
> >
> >> Looks a bit like
> >> http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
> >> listing #3  of disconnected row set.
> >>
> >> Can we get metaData out of it so I can write "auto" updates?
> >> So a DAO that has a Iterator of DynaBeans.
> >> Where is DynaBean? Commons?
> >>
> >> Vic
> >>
> >> Craig R. McClanahan wrote:
> >>
> >>> I implemented something a little more memory-efficient than this
> >>> (doesn't
> >>> require the entire result set to be in memory) in tonight's nightly
> >>> build
> >>> of commons-beanutils, which will therefore be available in the 20020713
> >>> nightly build of Struts.  You use it something like this:
> >>>
> >>>   Connection conn = ...;
> >>>   Statement stmt = conn.createStatement();
> >>>   ResultSet rs = stmt.executeQuery("select * from customers");
> >>>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
> >>>   while (rows.hasNext()) {
> >>> DynaBean row = (DynaBean) rows.next();
> >>> System.out.println("Processing customer " + row.get("account_id"));
> >>> ... access this row as a DynaBean ...
> >>>   }
> >>>   rs.close();
> >>>   stmt.close();
> >>>
> >>> I elected to avoid doing the type conversions, so the properties you get
> >>> back will correspond to their types in the database.
> >>>
> >>> Craig
> >>>
> >>>
> >>> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> >>>
> >>>
> >>>> Date: Fri, 12 Jul 2002 13:56:38 -0400
> >>>> From: [EMAIL PROTECTED]
> >>>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> >>>> To: [EMAIL PROTECTED]
> >>>> Subject: RE: DynaBeans, DynaClass, DynaMen
> >>>>
> >>>>
> >>>>
> >>>> Here is what I am using...  Very simple and only returns strings...
> >>>>
> >>>>
> >>>>  /**
> >>>>* Converts a resultset into an ArrayList of DynaBeans
> >>>>*
> >>>>* @param resultSet SQL result set to be converted
> >>>>* @return ArrayList of DynaBeans with all columnnames converted to
> >>>>* lowercase
> >>>>* @throws SQLException DOCUMENT ME!
> >>>>*/
> >>>>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
> >>>>  throws SQLException {
> >>>>
> >>>>  ResultSetMetaData metaData = resultSet.getMetaData();
> >>>>  int cols = metaData.getColumnCount();
> >>>>  ArrayList list = new ArrayList();
> >>>>  DynaProperty[] props = new DynaProperty[cols];

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: "Vic C." <[EMAIL PROTECTED]>
 ===
And... can we give it a datasource argument (instead of con) and use 
RowSet instead of ResultSet?

Vic

Vic C. wrote:
> Looks a bit like 
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html 
> listing #3  of disconnected row set.
> 
> Can we get metaData out of it so I can write "auto" updates?
> So a DAO that has a Iterator of DynaBeans.
> Where is DynaBean? Commons?
> 
> Vic
> 
> Craig R. McClanahan wrote:
> 
>> I implemented something a little more memory-efficient than this (doesn't
>> require the entire result set to be in memory) in tonight's nightly build
>> of commons-beanutils, which will therefore be available in the 20020713
>> nightly build of Struts.  You use it something like this:
>>
>>   Connection conn = ...;
>>   Statement stmt = conn.createStatement();
>>   ResultSet rs = stmt.executeQuery("select * from customers");
>>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>>   while (rows.hasNext()) {
>> DynaBean row = (DynaBean) rows.next();
>> System.out.println("Processing customer " + row.get("account_id"));
>> ... access this row as a DynaBean ...
>>   }
>>   rs.close();
>>   stmt.close();
>>
>> I elected to avoid doing the type conversions, so the properties you get
>> back will correspond to their types in the database.
>>
>> Craig
>>
>>
>> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
>>
>>
>>> Date: Fri, 12 Jul 2002 13:56:38 -0400
>>> From: [EMAIL PROTECTED]
>>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>> To: [EMAIL PROTECTED]
>>> Subject: RE: DynaBeans, DynaClass, DynaMen
>>>
>>>
>>>
>>> Here is what I am using...  Very simple and only returns strings...
>>>
>>>
>>>  /**
>>>* Converts a resultset into an ArrayList of DynaBeans
>>>*
>>>* @param resultSet SQL result set to be converted
>>>* @return ArrayList of DynaBeans with all columnnames converted to
>>>* lowercase
>>>* @throws SQLException DOCUMENT ME!
>>>*/
>>>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>>>  throws SQLException {
>>>
>>>  ResultSetMetaData metaData = resultSet.getMetaData();
>>>  int cols = metaData.getColumnCount();
>>>  ArrayList list = new ArrayList();
>>>  DynaProperty[] props = new DynaProperty[cols];
>>>  BasicDynaClass dClass = null;
>>>
>>>  for (int i = 1; i <= cols; i++) {
>>> props[i - 1] = new
>>> DynaProperty(metaData.getColumnName(i).toLowerCase());
>>>  }
>>>
>>>  try {
>>> dClass = new BasicDynaClass("test",
>>> Class.forName(
>>>
>>> "org.apache.commons.beanutils.BasicDynaBean"),
>>> props);
>>>  } catch (Exception e) {
>>> e.printStackTrace();
>>>  }
>>>
>>>  while (resultSet.next()) {
>>>
>>> HashMap map = new HashMap(cols, 1);
>>>
>>> for (int i = 1; i <= cols; i++) {
>>>        map.put(metaData.getColumnName(i).toLowerCase(),
>>>resultSet.getString(i));
>>> }
>>>
>>> try {
>>>
>>>DynaBean dbean = dClass.newInstance();
>>>BeanUtils.populate(dbean, map);
>>>    list.add(dbean);
>>> } catch (Exception e) {
>>>e.printStackTrace();
>>>throw new SQLException("RequestUtils.getArrayList: "
>>>   + e.toString());
>>> }
>>>  } // End While
>>>
>>>  return (list);
>>>   }
>>>
>>>
>>> -Original Message-
>>> From: craigmcc [mailto:[EMAIL PROTECTED]]
>>> Sent: Friday, July 12, 2002 12:07 PM
>>> To: struts-user
>>> Subject: Re: DynaBeans, DynaClass, DynaMen
>>>
>>>
>>>
>>>
>>> On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:
>>>
>>>
>>>> Date: Fri, 12 Jul 2002 07:02:57 +0200
>>>> From: Thorbjoern Ravn Andersen <[EMAIL PROT

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: "Vic C." <[EMAIL PROTECTED]>
 ===
I am so over all this. (I have a basejDAO project on SourceForge... that 
will take a SQL string and expose CRUD methods, that might use this).
Very Cool.

Vic

Craig R. McClanahan wrote:
> 
> On Fri, 12 Jul 2002, Struts Newsgroup wrote:
> 
> 
>>Date: Fri, 12 Jul 2002 18:40:02 -0700
>>From: Struts Newsgroup <[EMAIL PROTECTED]>
>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>
>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>From: "Vic C." <[EMAIL PROTECTED]>
>> ===
>>Looks a bit like
>>http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
>>listing #3  of disconnected row set.
>>
>>Can we get metaData out of it so I can write "auto" updates?
>>So a DAO that has a Iterator of DynaBeans.
> 
> 
> All DynaBean implementations support metadata.  From a particular DynaBean
> instance you can say something like:
> 
>   DynaProperty descriptors[] = dynaBean.getDynaClass().getDynaProperties();
> 
> and iterate through the descriptors to see what is there, very similar to
> what you can do with standard JavaBeans by calling:
> 
>   PropertyDescriptor descriptors[] =
> PropertyUtils.getPropertyDescriptors(javabean);
> 
> 
>>Where is DynaBean? Commons?
> 
> 
> Yep.  It's part of the commons-beanutils package.  Most recent nightly
> builds (which are also packaged with nightly builds of Struts) are at:
> 
>   http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-beanutils/
> 
> The new feature discussed below will be in tomorrow's (20020713) build.
> 
> 
>>Vic
>>
> 
> 
> Craig
> 
> 
> 
>>Craig R. McClanahan wrote:
>>
>>>I implemented something a little more memory-efficient than this (doesn't
>>>require the entire result set to be in memory) in tonight's nightly build
>>>of commons-beanutils, which will therefore be available in the 20020713
>>>nightly build of Struts.  You use it something like this:
>>>
>>>  Connection conn = ...;
>>>  Statement stmt = conn.createStatement();
>>>  ResultSet rs = stmt.executeQuery("select * from customers");
>>>  Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>>>  while (rows.hasNext()) {
>>>DynaBean row = (DynaBean) rows.next();
>>>System.out.println("Processing customer " + row.get("account_id"));
>>>... access this row as a DynaBean ...
>>>  }
>>>  rs.close();
>>>  stmt.close();
>>>
>>>I elected to avoid doing the type conversions, so the properties you get
>>>back will correspond to their types in the database.
>>>
>>>Craig
>>>
>>>
>>>On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
>>>
>>>
>>>
>>>>Date: Fri, 12 Jul 2002 13:56:38 -0400
>>>>From: [EMAIL PROTECTED]
>>>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>>>To: [EMAIL PROTECTED]
>>>>Subject: RE: DynaBeans, DynaClass, DynaMen
>>>>
>>>>
>>>>
>>>>Here is what I am using...  Very simple and only returns strings...
>>>>
>>>>
>>>> /**
>>>>   * Converts a resultset into an ArrayList of DynaBeans
>>>>   *
>>>>   * @param resultSet SQL result set to be converted
>>>>   * @return ArrayList of DynaBeans with all columnnames converted to
>>>>   * lowercase
>>>>   * @throws SQLException DOCUMENT ME!
>>>>   */
>>>>  private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>>>> throws SQLException {
>>>>
>>>> ResultSetMetaData metaData = resultSet.getMetaData();
>>>> int cols = metaData.getColumnCount();
>>>> ArrayList list = new ArrayList();
>>>> DynaProperty[] props = new DynaProperty[cols];
>>>> BasicDynaClass dClass = null;
>>>>
>>>> for (int i = 1; i <= cols; i++) {
>>>>props[i - 1] = new
>>>>DynaProperty(metaData.getColumnName(i).toLowerCase());
>>>> }
>>>>
>>>> try {
>>>>dClass = new BasicDynaClass("test",
>>>>Class.forName(
>>>>
>>>>"org.apach

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: "Vic C." <[EMAIL PROTECTED]>
 ===
Sorry, excited: I see:
DynaProperty.getType() ;
So based on it I can get the type, and create an "UPDATE TABLE SET X = Y 
  WHERE Z=K" in a base class. Cool.
I wonder about original values for a reset, etc.

Vic

Vic C. wrote:
> And... can we give it a datasource argument (instead of con) and use 
> RowSet instead of ResultSet?
> 
> Vic
> 
> Vic C. wrote:
> 
>> Looks a bit like 
>> http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html 
>> listing #3  of disconnected row set.
>>
>> Can we get metaData out of it so I can write "auto" updates?
>> So a DAO that has a Iterator of DynaBeans.
>> Where is DynaBean? Commons?
>>
>> Vic
>>
>> Craig R. McClanahan wrote:
>>
>>> I implemented something a little more memory-efficient than this 
>>> (doesn't
>>> require the entire result set to be in memory) in tonight's nightly 
>>> build
>>> of commons-beanutils, which will therefore be available in the 20020713
>>> nightly build of Struts.  You use it something like this:
>>>
>>>   Connection conn = ...;
>>>   Statement stmt = conn.createStatement();
>>>   ResultSet rs = stmt.executeQuery("select * from customers");
>>>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>>>   while (rows.hasNext()) {
>>> DynaBean row = (DynaBean) rows.next();
>>> System.out.println("Processing customer " + row.get("account_id"));
>>> ... access this row as a DynaBean ...
>>>   }
>>>   rs.close();
>>>   stmt.close();
>>>
>>> I elected to avoid doing the type conversions, so the properties you get
>>> back will correspond to their types in the database.
>>>
>>> Craig
>>>
>>>
>>> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
>>>
>>>
>>>> Date: Fri, 12 Jul 2002 13:56:38 -0400
>>>> From: [EMAIL PROTECTED]
>>>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>>> To: [EMAIL PROTECTED]
>>>> Subject: RE: DynaBeans, DynaClass, DynaMen
>>>>
>>>>
>>>>
>>>> Here is what I am using...  Very simple and only returns strings...
>>>>
>>>>
>>>>  /**
>>>>* Converts a resultset into an ArrayList of DynaBeans
>>>>*
>>>>* @param resultSet SQL result set to be converted
>>>>* @return ArrayList of DynaBeans with all columnnames converted to
>>>>* lowercase
>>>>* @throws SQLException DOCUMENT ME!
>>>>*/
>>>>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>>>>  throws SQLException {
>>>>
>>>>  ResultSetMetaData metaData = resultSet.getMetaData();
>>>>  int cols = metaData.getColumnCount();
>>>>  ArrayList list = new ArrayList();
>>>>  DynaProperty[] props = new DynaProperty[cols];
>>>>  BasicDynaClass dClass = null;
>>>>
>>>>  for (int i = 1; i <= cols; i++) {
>>>> props[i - 1] = new
>>>> DynaProperty(metaData.getColumnName(i).toLowerCase());
>>>>  }
>>>>
>>>>  try {
>>>> dClass = new BasicDynaClass("test",
>>>> Class.forName(
>>>>
>>>> "org.apache.commons.beanutils.BasicDynaBean"),
>>>> props);
>>>>  } catch (Exception e) {
>>>> e.printStackTrace();
>>>>  }
>>>>
>>>>  while (resultSet.next()) {
>>>>
>>>> HashMap map = new HashMap(cols, 1);
>>>>
>>>> for (int i = 1; i <= cols; i++) {
>>>>map.put(metaData.getColumnName(i).toLowerCase(),
>>>>    resultSet.getString(i));
>>>> }
>>>>
>>>> try {
>>>>
>>>>DynaBean dbean = dClass.newInstance();
>>>>BeanUtils.populate(dbean, map);
>>>>list.add(dbean);
>>>> } catch (Exception e) {
>>>>e.printStackTrace();
>>>>throw new SQLException("RequestUtils.getArrayList: "
>>>

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan



On Fri, 12 Jul 2002, Struts Newsgroup wrote:

> Date: Fri, 12 Jul 2002 18:40:02 -0700
> From: Struts Newsgroup <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> Subject: Re: DynaBeans, DynaClass, DynaMen
> From: "Vic C." <[EMAIL PROTECTED]>
>  ===
> Looks a bit like
> http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html
> listing #3  of disconnected row set.
>
> Can we get metaData out of it so I can write "auto" updates?
> So a DAO that has a Iterator of DynaBeans.

All DynaBean implementations support metadata.  From a particular DynaBean
instance you can say something like:

  DynaProperty descriptors[] = dynaBean.getDynaClass().getDynaProperties();

and iterate through the descriptors to see what is there, very similar to
what you can do with standard JavaBeans by calling:

  PropertyDescriptor descriptors[] =
PropertyUtils.getPropertyDescriptors(javabean);

> Where is DynaBean? Commons?

Yep.  It's part of the commons-beanutils package.  Most recent nightly
builds (which are also packaged with nightly builds of Struts) are at:

  http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-beanutils/

The new feature discussed below will be in tomorrow's (20020713) build.

> Vic
>

Craig


> Craig R. McClanahan wrote:
> > I implemented something a little more memory-efficient than this (doesn't
> > require the entire result set to be in memory) in tonight's nightly build
> > of commons-beanutils, which will therefore be available in the 20020713
> > nightly build of Struts.  You use it something like this:
> >
> >   Connection conn = ...;
> >   Statement stmt = conn.createStatement();
> >   ResultSet rs = stmt.executeQuery("select * from customers");
> >   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
> >   while (rows.hasNext()) {
> > DynaBean row = (DynaBean) rows.next();
> > System.out.println("Processing customer " + row.get("account_id"));
> > ... access this row as a DynaBean ...
> >   }
> >   rs.close();
> >   stmt.close();
> >
> > I elected to avoid doing the type conversions, so the properties you get
> > back will correspond to their types in the database.
> >
> > Craig
> >
> >
> > On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> >
> >
> >>Date: Fri, 12 Jul 2002 13:56:38 -0400
> >>From: [EMAIL PROTECTED]
> >>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> >>To: [EMAIL PROTECTED]
> >>Subject: RE: DynaBeans, DynaClass, DynaMen
> >>
> >>
> >>
> >>Here is what I am using...  Very simple and only returns strings...
> >>
> >>
> >>  /**
> >>* Converts a resultset into an ArrayList of DynaBeans
> >>*
> >>* @param resultSet SQL result set to be converted
> >>* @return ArrayList of DynaBeans with all columnnames converted to
> >>* lowercase
> >>* @throws SQLException DOCUMENT ME!
> >>*/
> >>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
> >>  throws SQLException {
> >>
> >>  ResultSetMetaData metaData = resultSet.getMetaData();
> >>  int cols = metaData.getColumnCount();
> >>  ArrayList list = new ArrayList();
> >>  DynaProperty[] props = new DynaProperty[cols];
> >>  BasicDynaClass dClass = null;
> >>
> >>  for (int i = 1; i <= cols; i++) {
> >> props[i - 1] = new
> >>DynaProperty(metaData.getColumnName(i).toLowerCase());
> >>  }
> >>
> >>  try {
> >> dClass = new BasicDynaClass("test",
> >> Class.forName(
> >>
> >>"org.apache.commons.beanutils.BasicDynaBean"),
> >> props);
> >>  } catch (Exception e) {
> >> e.printStackTrace();
> >>  }
> >>
> >>  while (resultSet.next()) {
> >>
> >> HashMap map = new HashMap(cols, 1);
> >>
> >> for (int i = 1; i <= cols; i++) {
> >>map.put(metaData.getColumnName(i).toLowerCase(),
> >>resultSet.getString(i));
> >> }
> >>
> >> try {
> >>
> >>DynaBean dbean = dClass.newInstance();
> &g

Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: "Vic C." <[EMAIL PROTECTED]>
 ===
Looks a bit like 
http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html 
listing #3  of disconnected row set.

Can we get metaData out of it so I can write "auto" updates?
So a DAO that has a Iterator of DynaBeans.
Where is DynaBean? Commons?

Vic

Craig R. McClanahan wrote:
> I implemented something a little more memory-efficient than this (doesn't
> require the entire result set to be in memory) in tonight's nightly build
> of commons-beanutils, which will therefore be available in the 20020713
> nightly build of Struts.  You use it something like this:
> 
>   Connection conn = ...;
>   Statement stmt = conn.createStatement();
>   ResultSet rs = stmt.executeQuery("select * from customers");
>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>   while (rows.hasNext()) {
> DynaBean row = (DynaBean) rows.next();
> System.out.println("Processing customer " + row.get("account_id"));
> ... access this row as a DynaBean ...
>   }
>   rs.close();
>   stmt.close();
> 
> I elected to avoid doing the type conversions, so the properties you get
> back will correspond to their types in the database.
> 
> Craig
> 
> 
> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> 
> 
>>Date: Fri, 12 Jul 2002 13:56:38 -0400
>>From: [EMAIL PROTECTED]
>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: RE: DynaBeans, DynaClass, DynaMen
>>
>>
>>
>>Here is what I am using...  Very simple and only returns strings...
>>
>>
>>  /**
>>* Converts a resultset into an ArrayList of DynaBeans
>>*
>>* @param resultSet SQL result set to be converted
>>* @return ArrayList of DynaBeans with all columnnames converted to
>>* lowercase
>>* @throws SQLException DOCUMENT ME!
>>*/
>>   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>>  throws SQLException {
>>
>>  ResultSetMetaData metaData = resultSet.getMetaData();
>>  int cols = metaData.getColumnCount();
>>  ArrayList list = new ArrayList();
>>  DynaProperty[] props = new DynaProperty[cols];
>>  BasicDynaClass dClass = null;
>>
>>  for (int i = 1; i <= cols; i++) {
>> props[i - 1] = new
>>DynaProperty(metaData.getColumnName(i).toLowerCase());
>>  }
>>
>>  try {
>> dClass = new BasicDynaClass("test",
>> Class.forName(
>>
>>"org.apache.commons.beanutils.BasicDynaBean"),
>> props);
>>  } catch (Exception e) {
>> e.printStackTrace();
>>  }
>>
>>  while (resultSet.next()) {
>>
>> HashMap map = new HashMap(cols, 1);
>>
>> for (int i = 1; i <= cols; i++) {
>>map.put(metaData.getColumnName(i).toLowerCase(),
>>resultSet.getString(i));
>> }
>>
>> try {
>>
>>DynaBean dbean = dClass.newInstance();
>>    BeanUtils.populate(dbean, map);
>>list.add(dbean);
>> } catch (Exception e) {
>>e.printStackTrace();
>>throw new SQLException("RequestUtils.getArrayList: "
>>   + e.toString());
>>     }
>>  } // End While
>>
>>  return (list);
>>   }
>>
>>
>>-Original Message-
>>From: craigmcc [mailto:[EMAIL PROTECTED]]
>>Sent: Friday, July 12, 2002 12:07 PM
>>To: struts-user
>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>
>>
>>
>>
>>On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:
>>
>>
>>>Date: Fri, 12 Jul 2002 07:02:57 +0200
>>>From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
>>>Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>>To: Struts Users Mailing List <[EMAIL PROTECTED]>
>>>Subject: Re: DynaBeans, DynaClass, DynaMen
>>>
>>>[EMAIL PROTECTED] 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
>>>>li

RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Martin Cooper

Cool beans! (Yes, pun intended - it's Friday, right? :)

--
Martin Cooper


> -Original Message-
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 12, 2002 3:45 PM
> To: Struts Users Mailing List
> Subject: RE: DynaBeans, DynaClass, DynaMen
> 
> 
> I implemented something a little more memory-efficient than 
> this (doesn't
> require the entire result set to be in memory) in tonight's 
> nightly build
> of commons-beanutils, which will therefore be available in 
> the 20020713
> nightly build of Struts.  You use it something like this:
> 
>   Connection conn = ...;
>   Statement stmt = conn.createStatement();
>   ResultSet rs = stmt.executeQuery("select * from customers");
>   Iterator rows = (new ResultSetDynaClass(rs)).iterator();
>   while (rows.hasNext()) {
> DynaBean row = (DynaBean) rows.next();
> System.out.println("Processing customer " + 
> row.get("account_id"));
> ... access this row as a DynaBean ...
>   }
>   rs.close();
>   stmt.close();
> 
> I elected to avoid doing the type conversions, so the 
> properties you get
> back will correspond to their types in the database.
> 
> Craig
> 
> 
> On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:
> 
> > Date: Fri, 12 Jul 2002 13:56:38 -0400
> > From: [EMAIL PROTECTED]
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: [EMAIL PROTECTED]
> > Subject: RE: DynaBeans, DynaClass, DynaMen
> >
> >
> >
> > Here is what I am using...  Very simple and only returns strings...
> >
> >
> >   /**
> > * Converts a resultset into an ArrayList of DynaBeans
> > *
> > * @param resultSet SQL result set to be converted
> > * @return ArrayList of DynaBeans with all columnnames 
> converted to
> > * lowercase
> > * @throws SQLException DOCUMENT ME!
> > */
> >private static ArrayList getDynaBeanArrayList(ResultSet 
> resultSet)
> >   throws SQLException {
> >
> >   ResultSetMetaData metaData = resultSet.getMetaData();
> >   int cols = metaData.getColumnCount();
> >   ArrayList list = new ArrayList();
> >   DynaProperty[] props = new DynaProperty[cols];
> >   BasicDynaClass dClass = null;
> >
> >   for (int i = 1; i <= cols; i++) {
> >  props[i - 1] = new
> > DynaProperty(metaData.getColumnName(i).toLowerCase());
> >   }
> >
> >   try {
> >  dClass = new BasicDynaClass("test",
> >  Class.forName(
> >
> > "org.apache.commons.beanutils.BasicDynaBean"),
> >  props);
> >   } catch (Exception e) {
> >  e.printStackTrace();
> >   }
> >
> >   while (resultSet.next()) {
> >
> >  HashMap map = new HashMap(cols, 1);
> >
> >  for (int i = 1; i <= cols; i++) {
> > map.put(metaData.getColumnName(i).toLowerCase(),
> > resultSet.getString(i));
> >  }
> >
> >  try {
> >
> > DynaBean dbean = dClass.newInstance();
> >     BeanUtils.populate(dbean, map);
> > list.add(dbean);
> >  } catch (Exception e) {
> > e.printStackTrace();
> > throw new SQLException("RequestUtils.getArrayList: "
> >+ e.toString());
> >      }
> >   } // End While
> >
> >   return (list);
> >}
> >
> >
> > -Original Message-
> > From: craigmcc [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, July 12, 2002 12:07 PM
> > To: struts-user
> > Subject: Re: DynaBeans, DynaClass, DynaMen
> >
> >
> >
> >
> > On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:
> >
> > > Date: Fri, 12 Jul 2002 07:02:57 +0200
> > > From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
> > > Reply-To: Struts Users Mailing List 
> <[EMAIL PROTECTED]>
> > > To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > > Subject: Re: DynaBeans, DynaClass, DynaMen
> > >
> > > [EMAIL PROTECTED] 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 
> arra

RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan

I implemented something a little more memory-efficient than this (doesn't
require the entire result set to be in memory) in tonight's nightly build
of commons-beanutils, which will therefore be available in the 20020713
nightly build of Struts.  You use it something like this:

  Connection conn = ...;
  Statement stmt = conn.createStatement();
  ResultSet rs = stmt.executeQuery("select * from customers");
  Iterator rows = (new ResultSetDynaClass(rs)).iterator();
  while (rows.hasNext()) {
DynaBean row = (DynaBean) rows.next();
System.out.println("Processing customer " + row.get("account_id"));
... access this row as a DynaBean ...
  }
  rs.close();
  stmt.close();

I elected to avoid doing the type conversions, so the properties you get
back will correspond to their types in the database.

Craig


On Fri, 12 Jul 2002 [EMAIL PROTECTED] wrote:

> Date: Fri, 12 Jul 2002 13:56:38 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: RE: DynaBeans, DynaClass, DynaMen
>
>
>
> Here is what I am using...  Very simple and only returns strings...
>
>
>   /**
> * Converts a resultset into an ArrayList of DynaBeans
> *
> * @param resultSet SQL result set to be converted
> * @return ArrayList of DynaBeans with all columnnames converted to
> * lowercase
> * @throws SQLException DOCUMENT ME!
> */
>private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
>   throws SQLException {
>
>   ResultSetMetaData metaData = resultSet.getMetaData();
>   int cols = metaData.getColumnCount();
>   ArrayList list = new ArrayList();
>   DynaProperty[] props = new DynaProperty[cols];
>   BasicDynaClass dClass = null;
>
>   for (int i = 1; i <= cols; i++) {
>  props[i - 1] = new
> DynaProperty(metaData.getColumnName(i).toLowerCase());
>   }
>
>   try {
>  dClass = new BasicDynaClass("test",
>  Class.forName(
>
> "org.apache.commons.beanutils.BasicDynaBean"),
>  props);
>   } catch (Exception e) {
>  e.printStackTrace();
>   }
>
>   while (resultSet.next()) {
>
>  HashMap map = new HashMap(cols, 1);
>
>  for (int i = 1; i <= cols; i++) {
> map.put(metaData.getColumnName(i).toLowerCase(),
> resultSet.getString(i));
>  }
>
>  try {
>
> DynaBean dbean = dClass.newInstance();
> BeanUtils.populate(dbean, map);
> list.add(dbean);
>  } catch (Exception e) {
> e.printStackTrace();
> throw new SQLException("RequestUtils.getArrayList: "
>                + e.toString());
>  }
>   } // End While
>
>   return (list);
>}
>
>
> -Original Message-
> From: craigmcc [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 12, 2002 12:07 PM
> To: struts-user
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
>
>
>
> On Fri, 12 Jul 2002, Thorbjoern Ravn Andersen wrote:
>
> > Date: Fri, 12 Jul 2002 07:02:57 +0200
> > From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > To: Struts Users Mailing List <[EMAIL PROTECTED]>
> > Subject: Re: DynaBeans, DynaClass, DynaMen
> >
> > [EMAIL PROTECTED] 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.

RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread wbchmura



Here is what I am using...  Very simple and only returns strings...


  /**
* Converts a resultset into an ArrayList of DynaBeans
* 
* @param resultSet SQL result set to be converted
* @return ArrayList of DynaBeans with all columnnames converted to
* lowercase
* @throws SQLException DOCUMENT ME!
*/
   private static ArrayList getDynaBeanArrayList(ResultSet resultSet)
  throws SQLException {

  ResultSetMetaData metaData = resultSet.getMetaData();
  int cols = metaData.getColumnCount();
  ArrayList list = new ArrayList();
  DynaProperty[] props = new DynaProperty[cols];
  BasicDynaClass dClass = null;

  for (int i = 1; i <= cols; i++) {
 props[i - 1] = new 
DynaProperty(metaData.getColumnName(i).toLowerCase());
  }

  try {
 dClass = new BasicDynaClass("test", 
 Class.forName(

"org.apache.commons.beanutils.BasicDynaBean"), 
 props);
  } catch (Exception e) {
 e.printStackTrace();
  }

  while (resultSet.next()) {

 HashMap map = new HashMap(cols, 1);

 for (int i = 1; i <= cols; i++) {
map.put(metaData.getColumnName(i).toLowerCase(), 
resultSet.getString(i));
 }

 try {

DynaBean dbean = dClass.newInstance();
BeanUtils.populate(dbean, map);
list.add(dbean);
 } catch (Exception e) {
e.printStackTrace();
throw new SQLException("RequestUtils.getArrayList: "
   + e.toString());
 }
  } // End While

  return (list);
   }


-Original Message-
From: craigmcc [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 12:07 PM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen




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

> Date: Fri, 12 Jul 2002 07:02:57 +0200
> From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> [EMAIL PROTECTED] 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:   
<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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread Craig R. McClanahan



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

> Date: Fri, 12 Jul 2002 07:02:57 +0200
> From: Thorbjoern Ravn Andersen <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> Subject: Re: DynaBeans, DynaClass, DynaMen
>
> [EMAIL PROTECTED] 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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: DynaBeans, DynaClass, DynaMen

2002-07-12 Thread wbchmura


The issue became pointless when for some reason the tag lib I was using 
started working all the sudden.  We may never know why, but it seems to 
like dynabeans now...

Thanks anyway!

-Original Message-
From: tra [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 12, 2002 1:03 AM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen


[EMAIL PROTECTED] 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:   
<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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-11 Thread Thorbjoern Ravn Andersen

[EMAIL PROTECTED] 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:   
For additional commands, e-mail: 




RE: DynaBeans, DynaClass, DynaMen - Display Tags

2002-07-02 Thread wbchmura


Apparently the Display Tags library does support Dynabeans...  I had an 
action screwed up

Works well!



-Original Message-
From: Chmura, William B. 
Sent: Monday, July 01, 2002 12:28 PM
To: struts-user
Subject: RE: DynaBeans, DynaClass, DynaMen


definatly will submit them...  Tried contacting the author but no 
response... I'll post patches or something...

I am going to take that approach methinks!


-Original Message-
From: cliff [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 12:17 PM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen


I'll answer both mails at the same time ..

[EMAIL PROTECTED] wrote:
> If I followed this approach and wanted to implement it across many 
> pages, would I just code the interface for every possible field that 
> could be returned?  I am not sure and I left my patterns book at home 
> today (seriously).

Well, for every bean that you'd want to access through a non-dyna 
interface, yes.  I wasn't saying you should take this approach - just 
throwing another bail of hail on the needle ;)

[EMAIL PROTECTED] wrote:
 > Yep, the display tag library...

Using that one myself, its very nice.  I'm not using dyna beans though.

 > I spent some time looking at the source last night, and modifying it
 > should not be that bad...

That'd be the better approach .. once you've made the mods, submit them 
to the right place and we can all enjoy them :)

 > Thanks for the feedback!

You're welcome.


--
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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-02 Thread @Basebeans.com

Subject: Re: DynaBeans, DynaClass, DynaMen
From: <[EMAIL PROTECTED]>
 ===
hello,
how to used 'nested tags' on dynamic forms? it is possible?

Tomasz Kuczerski


Uzytkownik <[EMAIL PROTECTED]> napisal w wiadomosci
news:[EMAIL PROTECTED]...
>
> ...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:
<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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Craig R. McClanahan



On Mon, 1 Jul 2002, Cliff Rowley wrote:

> Date: Mon, 01 Jul 2002 18:42:24 +0100
> From: Cliff Rowley <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: Struts Users Mailing List <[EMAIL PROTECTED]>
> 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  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:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




RE: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread wbchmura


I should be able to do bean write on them, but I would lose the pretty 
functionality I get with the taglib...




-Original Message-
From: cliff [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 1:42 PM
To: struts-user
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  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:   
<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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Cliff Rowley

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  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:   
For additional commands, e-mail: 




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Craig R. McClanahan



On Mon, 1 Jul 2002 [EMAIL PROTECTED] wrote:

> Date: Mon, 1 Jul 2002 10:39:46 -0400
> From: [EMAIL PROTECTED]
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> 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  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:   
For additional commands, e-mail: 




RE: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Adolfo Miguelez


By using dynabeans should not need to modify the custom tags at all. 
BeansUtils package is able to inspect dynabeans itself.

The advantage is that you have not to worry about making your modified 
custom tags for each new release.

Adolfo

>From: [EMAIL PROTECTED]
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: RE: DynaBeans, DynaClass, DynaMen
>Date: Mon, 1 Jul 2002 12:10:51 -0400
>
>
>Yep, the display tag library...
>
>I spent some time looking at the source last night, and modifying it
>should not be that bad...
>
>Thanks for the feedback!
>
>-Original Message-
>From: pelly69 [mailto:[EMAIL PROTECTED]]
>Sent: Monday, July 01, 2002 11:05 AM
>To: struts-user
>Subject: Re: DynaBeans, DynaClass, DynaMen
>
>
>I have implemented the same approach: getting results from a database
>query
>and wrap them in an ArrayList of dynabeans. In that way I can use the
>Struts
>Customs tags in order to render the dynabeans content in the JSP.
>
>Custom Tags rely on Commons BeanUtils package which is able to inspect
>any
>Java Bean or Dynabean to pick up the information.
>
>I think your approach is correct,
>
>Adolfo.
>
>
> >From: [EMAIL PROTECTED]
> >Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: DynaBeans, DynaClass, DynaMen
> >Date: Mon, 1 Jul 2002 10:39:46 -0400
> >
> >
> >...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:
> ><mailto:[EMAIL PROTECTED]>
> >For additional commands, e-mail:
> ><mailto:[EMAIL PROTECTED]>
> >
>
>_
>Join the world’s largest e-mail service with MSN Hotmail.
>http://www.hotmail.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]>





  
 Adolfo's signature
  
  
 Adolfo Rodriguez Miguelez

  
  





_
Chat with friends online, try MSN Messenger: http://messenger.msn.com


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




RE: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread wbchmura

definatly will submit them...  Tried contacting the author but no 
response... I'll post patches or something...

I am going to take that approach methinks!


-Original Message-
From: cliff [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 12:17 PM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen


I'll answer both mails at the same time ..

[EMAIL PROTECTED] wrote:
> If I followed this approach and wanted to implement it across many 
> pages, would I just code the interface for every possible field that 
> could be returned?  I am not sure and I left my patterns book at home 
> today (seriously).

Well, for every bean that you'd want to access through a non-dyna 
interface, yes.  I wasn't saying you should take this approach - just 
throwing another bail of hail on the needle ;)

[EMAIL PROTECTED] wrote:
 > Yep, the display tag library...

Using that one myself, its very nice.  I'm not using dyna beans though.

 > I spent some time looking at the source last night, and modifying it
 > should not be that bad...

That'd be the better approach .. once you've made the mods, submit them 
to the right place and we can all enjoy them :)

 > Thanks for the feedback!

You're welcome.


--
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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Cliff Rowley

I'll answer both mails at the same time ..

[EMAIL PROTECTED] wrote:
> If I followed this approach and wanted to implement it across many 
> pages, would I just code the interface for every possible field that 
> could be returned?  I am not sure and I left my patterns book at home 
> today (seriously).

Well, for every bean that you'd want to access through a non-dyna 
interface, yes.  I wasn't saying you should take this approach - just 
throwing another bail of hail on the needle ;)

[EMAIL PROTECTED] wrote:
 > Yep, the display tag library...

Using that one myself, its very nice.  I'm not using dyna beans though.

 > I spent some time looking at the source last night, and modifying it
 > should not be that bad...

That'd be the better approach .. once you've made the mods, submit them 
to the right place and we can all enjoy them :)

 > Thanks for the feedback!

You're welcome.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread wbchmura


Yep, the display tag library...

I spent some time looking at the source last night, and modifying it 
should not be that bad...

Thanks for the feedback!

-Original Message-
From: pelly69 [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 11:05 AM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen


I have implemented the same approach: getting results from a database 
query 
and wrap them in an ArrayList of dynabeans. In that way I can use the 
Struts 
Customs tags in order to render the dynabeans content in the JSP.

Custom Tags rely on Commons BeanUtils package which is able to inspect 
any 
Java Bean or Dynabean to pick up the information.

I think your approach is correct,

Adolfo.


>From: [EMAIL PROTECTED]
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: DynaBeans, DynaClass, DynaMen
>Date: Mon, 1 Jul 2002 10:39:46 -0400
>
>
>...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:   
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: 
><mailto:[EMAIL PROTECTED]>
>

_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.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]>




RE: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread wbchmura


If I followed this approach and wanted to implement it across many 
pages, would I just code the interface for every possible field that 
could be returned?  I am not sure and I left my patterns book at home 
today (seriously).




-Original Message-
From: cliff [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 01, 2002 11:28 AM
To: struts-user
Subject: Re: DynaBeans, DynaClass, DynaMen


[EMAIL PROTECTED] 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:   
<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]>




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Cliff Rowley

[EMAIL PROTECTED] 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:   
For additional commands, e-mail: 




Re: DynaBeans, DynaClass, DynaMen

2002-07-01 Thread Adolfo Miguelez

I have implemented the same approach: getting results from a database query 
and wrap them in an ArrayList of dynabeans. In that way I can use the Struts 
Customs tags in order to render the dynabeans content in the JSP.

Custom Tags rely on Commons BeanUtils package which is able to inspect any 
Java Bean or Dynabean to pick up the information.

I think your approach is correct,

Adolfo.


>From: [EMAIL PROTECTED]
>Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: DynaBeans, DynaClass, DynaMen
>Date: Mon, 1 Jul 2002 10:39:46 -0400
>
>
>...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:   
>
>For additional commands, e-mail: 
>
>

_
Join the world’s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: