fred muhlenberg wrote:
> While developmening, I stumbled across an unexpected situation with respect
> to nested properties. After thinking about it, the behavior is probably
> correct but I though I'd toss it out discussion anyway.
>
> I have a bean with a method getResults() that returns a Vector.
>
> class MyBean
> {
> ...
> public Vector getResults() { ... return( vec ); }
> ....
> }
>
> The vector returned contains objects, all of the type CustomerInfo. The
> CustomerInfo class has a method getCustomerId() which returns an integer.
>
> class CustomerInfo
> {
> ...
> public int getCustomerId() { return( this.id ); }
> ...
> }
>
> The JSP code that caused me problems is this:
>
> <USEBEAN NAME="MyBean:bean">
> ...
> </USEBEAN>
> [snip]
>
> <LOOP PROPERTY="bean:Results" PROPERTY="x">
> <li><DISPLAY PROPERTY="x:CustomerId"></li>
> </LOOP>
>
> My naive belief was that the CustomerId property value of object "x" would
> be (magically -> introspection) retreived. This didn't happen. [you may
> laugh now]
>
> Upon review, my Bean class should return an array, not a Vector. Obscure
> notes in the 0.92 spec confirm this.
You don't necessarily have to return an array. I have vector based properties that
used the 'indexed property' api. In your case, you could set it up as follows:
class MyBean
{
...
public CustomerInfo getCustomerInfo(int index) {return( vec.get(index) );}
public int getCustomerInfoSize() {return( vec.size() ); }
....
}
The CustomerInfo class would be directly LOOP-able from the MyBean class. There is no
need to translate into an array.
cc
begin:vcard
n:Cobb;Christopher
tel;cell:703-909-7550
tel;fax:703-648-7475
tel;work:703-648-6725
x-mozilla-html:TRUE
org:Powerhouse Technologies, Inc.
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
title:SW Architect
fn:Christopher Cobb
end:vcard