I have a bean that is a wrapper around 2 beans. How can access the inner beans ? I want to do it using struts tag library if possible!
Thanks in advance
Sam
-
bean within a bean (3 messages)
- Posted by: exp sam
- Posted on: April 11 2005 23:20 EDT
Threaded Messages (3)
- Use JSTL if you can by Duncan Mills on April 13 2005 07:59 EDT
- bean within a bean by Paul Morie on April 13 2005 17:27 EDT
-
Use JSTL if you can[ Go to top ]
- Posted by: Duncan Mills
- Posted on: April 13 2005 07:59 EDT
- in response to exp sam
If your wrapper bean has a getChild1() type method to access the nested bean then JSTL will make it simple to access this e.g) <c:out value="${parent.child1.attrib}"/>. -
bean within a bean[ Go to top ]
- Posted by: Paul Morie
- Posted on: April 13 2005 17:27 EDT
- in response to exp sam
Hi Samer-
Say that you have the following setup:
class A {
...
}
class B {
...
}
class C {
private A myA;
private B myB;
public A getMyA() { ... }
public B getMyB() { ... }
}
Typically, with the struts tag libraries, you use the name attribute to define the top-level bean and then access nested beans with the property attribute. For example, say you want to use the bean:define tag on a page-scope variable of type C called 'myC' to define myC's A bean as a bean / scripting element:
<bean:define id="myABean" name="myC" property="myA"/>
this will call the getMyA method on the variable myC, and create a bean called "myABean".
HTH,
P -
Thanks[ Go to top ]
- Posted by: exp sam
- Posted on: April 14 2005 10:27 EDT
- in response to Paul Morie
Thanks Paul. Thats what I was looking for :)