bean within a bean


Web tier: servlets, JSP, Web frameworks: bean within a bean

  1. bean within a bean (3 messages)

    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

    Threaded Messages (3)

  2. Use JSTL if you can[ Go to top ]

    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}"/>.
  3. bean within a bean[ Go to top ]

    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".


  4. Thanks[ Go to top ]

    Thanks Paul. Thats what I was looking for :)