Link to home
Start Free TrialLog in
Avatar of tmonteit
tmonteitFlag for Afghanistan

asked on

JSTL Scope problem


I have 3 Beans:  A, B, and C

// Assume getters and setters exist for all element.
// Class A wraps B and C.
public class ABean{
  private B b;

  // ArrayList of C's
  private ArrayList cList;
}

class BBean{
  private String name;
  private String id;
}

class CBean{
   private String name;
   private String id;
   private String color;
}

////  Now we have some JSTL Code

<nested:iterate iproperty="cList" >
    Color = <nested:write property="color" />
   
   Now I want to write the value of another bean in this iterate loop.
     How do I write?  the value of BBean.id here?
</nested:iterate>


How do I get the value of a seperate bean inside an iterate loop.
ASKER CERTIFIED SOLUTION
Avatar of bloodredsun
bloodredsun
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tmonteit

ASKER



So, using Struts nested tags, how do I write the contents of an element from the parent array being iterated?
I found a solution that makes this work.  I didn't know you could walk nested properties like a directory.

<nested:iterate property="cList" >
  <nested:write property="../../b.id" />
</nested:iterate>

points awarded for explaining JSTL example.