RE: DynaBeans, DynaClass, DynaMen
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 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
FW: DynaBeans, DynaClass, DynaMen
(java.sql.Types.DECIMAL) : object = resultSet.getBigDecimal(column); break; case (java.sql.Types.NUMERIC) : object = resultSet.getBigDecimal(column); break; case (java.sql.Types.DATE) : object = resultSet.getDate(column); break; case (java.sql.Types.TIME) : object = resultSet.getTime(column); break; case (java.sql.Types.TIMESTAMP) : object = resultSet.getTimestamp(column); break; case (java.sql.Types.CLOB) : object = resultSet.getClob(column); break; case (java.sql.Types.BLOB) : object = resultSet.getBlob(column); break; case (java.sql.Types.REF) : object = resultSet.getRef(column); break; case (java.sql.Types.JAVA_OBJECT) : object = resultSet.getObject(column); break; case (java.sql.Types.OTHER ) : object = resultSet.getObject(column); break; case (java.sql.Types.VARCHAR) : object = resultSet.getString(column); break; case (java.sql.Types.LONGVARCHAR) : object = resultSet.getString(column); break; // the rest of these are primitives, they are handled differently case (java.sql.Types.BIT) : object = new Boolean (resultSet.getBoolean(column)); break; case (java.sql.Types.TINYINT) : object = new Byte (resultSet.getByte(column)); break; case (java.sql.Types.SMALLINT) : object = new Short (resultSet.getShort(column)); break; case (java.sql.Types.INTEGER) : object = new Integer (resultSet.getInt(column)); break; case (java.sql.Types.REAL) : object = new Float (resultSet.getFloat(column)); break; case (java.sql.Types.DOUBLE) : object = new Double (resultSet.getDouble(column)); break; default : throw new Exception (SQL Type : + type + not supported); } if ( resultSet.wasNull() ) object = null; return object; } -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 6: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
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. I have seen examples which go like this bean:write name=dynabean property=property1/ 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: FW: DynaBeans, DynaClass, DynaMen
I know a different approach which is leaving the driver to make the casting to the database type for itself, and get/set everything with a get/setObject(). It works for me. I do not think it damages the performance since the delay in casting the driver, I guess is comparable with the delay in finding and handling the rigth type in the code below. However, this one is a point that I have wondered before with no successful results. Any kind of feedback is welcome, and sorry if it get out of Struts scope. Adolfo. From: Michael Connor [EMAIL PROTECTED] Reply-To: Struts Users Mailing List [EMAIL PROTECTED] To: '[EMAIL PROTECTED]' [EMAIL PROTECTED] Subject: FW: DynaBeans, DynaClass, DynaMen Date: Mon, 15 Jul 2002 10:06:50 -0400 Hello All - I've been following this thread and have been doing some similar work. In the code that was given here, there is really no regard for type. I've put together a couple of methods that would enable us to build the dynabean with the appropriate type. These methods work well in the tests that I've done but it would be great if others would use them so that we could perfect them. The code in the two methods is a little redundant and I'm open to suggestions on the appropriate way to reduce that. Enjoy! Michael Connor /** * This method will return an appropriate java class for a given * sql type. This method really should check the size and precision * for numerics and return an appropriate number. For now, it pretty * much always returns BigDecimal's for numbers. That isn't bad though * because BigDecimal covers any possible number without loss of precision * or worry about space to hold the number. by [EMAIL PROTECTED] * * @param sqlType The sql type of the ResultSet column as defined by Types.java * @return Class The appropriate Java Class to use for the column * @throws Exception If the sqlType is not supported by this method */ public static Class getJavaType (int sqlType) throws Exception { Class javaType = null; switch (sqlType) { case (java.sql.Types.CHAR) : javaType = java.lang.String.class; break; case (java.sql.Types.BIGINT) : javaType = BigDecimal.class; break; case (java.sql.Types.DECIMAL) : javaType = BigDecimal.class; break; case (java.sql.Types.NUMERIC) : javaType = BigDecimal.class; break; case (java.sql.Types.DATE) : javaType = java.sql.Date.class; break; case (java.sql.Types.TIME) : javaType = java.sql.Time.class; break; case (java.sql.Types.TIMESTAMP) : javaType = java.sql.Timestamp.class; break; case (java.sql.Types.CLOB) : javaType = java.sql.Clob.class; break; case (java.sql.Types.BLOB) : javaType = java.sql.Blob.class; break; case (java.sql.Types.REF) : javaType = java.sql.Ref.class; break; case (java.sql.Types.JAVA_OBJECT) : javaType = Object.class; break; case (java.sql.Types.OTHER ) : javaType = Object.class; break; case (java.sql.Types.VARCHAR) : javaType = String.class; break; case (java.sql.Types.LONGVARCHAR) : javaType = String.class; break; case (java.sql.Types.BIT) : javaType = Boolean.class; break; case (java.sql.Types.TINYINT) : javaType = Byte.class; break; case (java.sql.Types.SMALLINT) : javaType = Short.class; break; case (java.sql.Types.INTEGER) : javaType = Integer.class; break; case (java.sql.Types.REAL) : javaType = Float.class; break; case (java.sql.Types.DOUBLE) : javaType = Double.class; break; default : throw new Exception (SQL Type : + sqlType + not supported); } return javaType; } /** * This method will return an appropriate java object from a ResultSet * sql type. This method really should check the size and precision * for numerics and return an appropriate number type. For now it * always returns BigDecimal's for numbers. That isn't bad though * because BigDecimal covers any possible number without loss of precision * or worry about space to hold the number. by [EMAIL
RE: DynaBeans, DynaClass, DynaMen
I use to run in the same issue quite often, and use to solve it by: logic:iterate id=datum name=data bean:write name=dynabean property=%=datum%/ /logic:iterate 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 bean:write name=dynabean property=property1/ 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] HTML HEAD TITLEAdolfo's signature/TITLE /HEAD BODY centerbemAdolfo Rodriguez Miguelez/emb/center /BODY /HTML _ Join the worlds 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
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 bean:write 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 logic:iterate loop to display the corresponding values, as long as you obey the programming restrictions. Craig I have seen examples which go like this bean:write name=dynabean property=property1/ 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
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
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
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
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. 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] -- To unsubscribe, e-mail: mailto:[EMAIL
RE: DynaBeans, DynaClass, DynaMen
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 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
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. 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 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
Re: DynaBeans, DynaClass, DynaMen
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(); 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
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. 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: + 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
Re: DynaBeans, DynaClass, DynaMen
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.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
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? 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 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
Re: DynaBeans, DynaClass, DynaMen
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]; 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
Re: DynaBeans, DynaClass, DynaMen
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)); } 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
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.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
RE: DynaBeans, DynaClass, DynaMen
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.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
Re: DynaBeans, DynaClass, DynaMen
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 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
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]
RE: DynaBeans, DynaClass, DynaMen - Display Tags
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]
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: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
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 worlds 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
[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]
RE: DynaBeans, DynaClass, DynaMen
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
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 worlds 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
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]
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]
RE: DynaBeans, DynaClass, DynaMen
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 worlds 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] HTML HEAD TITLEAdolfo's signature/TITLE /HEAD BODY centerbemAdolfo Rodriguez Miguelez/emb/center /BODY /HTML _ 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
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 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: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
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 :) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: DynaBeans, DynaClass, DynaMen
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 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: 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
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 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: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]