You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Zeltser, Mark" <Ma...@lehman.com> on 2001/04/03 15:55:06 UTC

Using Tag with bean that has a collection

Hello,

I am trying to use OPTIONS tag with bean that has a collection as one of its
member variables ( the appropriate getter method is provided). 

Assuming the following scenario

==========================================================
public class Cache {
	private ArrayList productList = null;
	
	public init( ActionServlet servlet) {
		// ArrayList initialized
		servlet.getServletContext().setAttribute( "cache", this );
}

	public ArrayList getProductList() {
		return this.productList;
	}
}
==========================================================
How would you access productList? Javadoc is hard to understand.

<html:select property="system"> 
           <html:options  name="??"
                          collection="??"
                          property="??"
                          labelProperty="??"/> 
</html:select>

Thanks, Mark.


------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers Inc.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.



Re: Using Tag with bean that has a collection

Posted by Rob Leland <Ro...@freetocreate.org>.
I may be wrong but after looking over and debugging
the OptionsTag I believe that:

name="cache",property="productList"
Your productList must be a String.
At this time it can't return another Bean
which itself has properties.

If product is a Bean and it has a property
named productID that you need to access then you need 
to store the collection in a
request or session scope variable.
and access it by
collection="<%= productList %>", property="productID".

The example program has an example of this in either the
register.jsp or subscription.jsp.

-Rob

"Zeltser, Mark" wrote:
> 
> Hello,
> 
> I am trying to use OPTIONS tag with bean that has a collection as one of its
> member variables ( the appropriate getter method is provided).
> 
> Assuming the following scenario
> 
> ==========================================================
> public class Cache {
>         private ArrayList productList = null;
> 
>         public init( ActionServlet servlet) {
>                 // ArrayList initialized
>                 servlet.getServletContext().setAttribute( "cache", this );
> }
> 
>         public ArrayList getProductList() {
>                 return this.productList;
>         }
> }
> ==========================================================
> How would you access productList? Javadoc is hard to understand.
> 
> <html:select property="system">
>            <html:options  name="??"
>                           collection="??"
>                           property="??"
>                           labelProperty="??"/>
> </html:select>
> 
> Thanks, Mark.
> 
> ------------------------------------------------------------------------------
> This message is intended only for the personal and confidential use of the designated recipient(s) named above.  If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited.  This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers Inc.  Email transmission cannot be guaranteed to be secure or error-free.  Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such.  All information is subject to change without notice.