Discussions

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{
         setAttributeName()
         getAttributeName();
         setAttributeVal();
         getAttributeVal();
     }
    }


    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:(
    MaRu.
  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"/>
    </logic:iterate>


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

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

    Regards,
    MaRu.
  4. No,

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

    thanq very much ..

    :)

    Regards,
    MaRu.