struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <ml...@officinedigitali.it>
Subject Re: problem converting resultset to RowsetDynaClass
Date Wed, 19 Mar 2003 13:44:12 GMT

Okay You'll have to switch to ResultSetDynaBEan and copy values from 
your rs bean and you new one.. The types will have been set in 
rowsetdynaclass whuch is why you cant set a value of a different type.


ResultsSetDynaClass rsdc = new ResultSetDynaClass(rs);

Iterator it = rsdc.iterator();
//get old props
DynaProperty oldProperties[] = rsdc.getDynaProperties();

//create new props array
DynaProperty newProperties[] = new DynaProperty[oldProperties.length];


for(int i = 0;i < oldProperties.length;i++) {
//use constructor without type lets you use any type thereafter	
	newProperties[i] = new DynaProperty(oldProperties[i].getName());

}


BasicDynaClass bdc = new 
BasicDynaClass("MyBEan",BasicDynaBean.class,newProperties);

while(it.hasNext()) {
	DynaBean row = (DynaBean) it.next()

	DynaBean newBean = bdc.newInstance();

	// now you can copy and insert the types you like into newBean

}

hope this help
mark



On Mercoledì, mar 19, 2003, at 13:47 Europe/Rome, VAN DEN BROEK, Johan 
wrote:

> Mark,
>
> Sorry, i don't understand.
>
> This is what I do:
>
> ...
> RowSetDynaClass rsdc = new RowSetDynaClass(rs,false);
> return rsdc.getRows();
> ..
>
> The collection returned by this method, I'm using in my jsp.
>
> Johan
>
> -----Original Message-----
> From: Mark Lowe [mailto:mlowe@officinedigitali.it]
> Sent: woensdag 19 maart 2003 12:11
> To: Struts Users Mailing List
> Subject: Re: problem converting resultset to RowsetDynaClass
>
> I might have a way to fix this how are you dening your BasicDynaClass
> before instantiating it?
>
>
>
>
>
> On Mercoledì, mar 19, 2003, at 11:46 Europe/Rome, VAN DEN BROEK, Johan
> wrote:
>
>> Hello,
>>
>> I 'm experiencing problems with RowSetDynaClass. When I try to convert
>
>> a
>> resultset containing a tinyint, I get the following errormessage:
>>
>> org.apache.jasper.JasperException: Cannot assign value of type
>> 'java.lang.Short' to property 'btTaal_ID' of type 'java.lang.Integer'
>>
>> Everything else is working fine.
>>
>> I'm using Struts 1.1 rc1, tomcat 4.18, mysql jdbc 3.06, mysql 3.23.52
>>
>> Johan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message