Hi, I have a problem accessing beans in struts. My bean looks something like this. class Category { private int catId; private List products; .. . } The list is used to store Product objects. How can access the products in a jsp page by only using struts tags? Using iterate and bean:write will not do the trick because I need to access the objects in the list. Any ideas? Thanks. jay ------ SCJP, SCJD
(Edit: sorry about previous edition of this post. I got a couple of things mixed up -- indexed properties are a different thing. You just need a List) logic:iterate and bean:write should work.
[ December 27, 2002: Message edited by: Junilu Lacar ]
You can create a form bean that has the attributes of your Category, or some such approach to make the products list available to the tag library in some scope. The example below assumes the form bean contains a getProducts() method that returns your list of products and that the Product object has a getProductName() method:
If the Product object is more complex you can use "dot" syntax to obtain "deeper" properties. For example, property="type.name" instructs struts to call getType().getName() on the object. Hope that helps. Matthew Marquand Object Ovation, Inc.