How to populate an Object with Collection of Objects to jsp???


Web tier: servlets, JSP, Web frameworks: How to populate an Object with Collection of Objects to jsp???

  1. Hi,

      I have a formbean in that one getter methode returns an Object of type "PropertyVO", which in turn contains a Collection of Objects of type "PropertyAttributeVO" with a pair of values.

      How can i display the values in jsp..

      In clear

      form1 extends ActionForm{
         private PropertyVO pVO;
         private Strng address;
         void setPVO(PropertyVO pVO){this.pVO=pVO;}
         PropertyVO getPVO(){ return pVO};

    class PropertyVO{
         private Collection p;
         void setPropertyAttributes(Collection p){}
         Collection getPropertyAttributes(){}

     Here Colleciton p is collection of PropertyAttributeVO objects.

     Class PropertyAttributeVO{

    Now I am populateing the form bean to a jsp page.. how can i display the attribute name and its value in the page..

    Thanx in advance:(
  2. Can you try this?

    <logic:iterate id="attList" name="formName" property="pVO.propertyAttributes" type="PropertyAttributeVO" >
    Attribute Name: <bean:write name="name" property="attributeName"/>
    Attribute Value: <bean:write name="name" property="attributeVal"/>

    I think the property element of iterate tag will be replaced by getPVO().getPropertyAttributes(), but I am not sure.

  3. Thanq very much
    Mr.Senthil Chinnaiyan,

    It is perfectly working. But the problem now is i am ble to getting only the last values of the collection.

     that is only the attribcode and attribvalue of the last object in the collection.

    How can i get the remaining ones

  4. No,

    It is problem with my code.. It is perfectly working..

    thanq very much ..