wood burning stoves 2.0*
The moose likes Struts and the fly likes about logic:iterate and bean:write tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "about logic:iterate and bean:write tag" Watch "about logic:iterate and bean:write tag" New topic
Author

about logic:iterate and bean:write tag

surendar prabu
Ranch Hand

Joined: Jul 24, 2006
Posts: 102
I am using logic iterate tag to loop around a collection and using bean write tag to present the data.

the logic:iterate iterates a collection 'mycollection', which contains objects of mybean class.

In 'mybean' class i have three string objects which are presented through bean:write

logic:iterate name = myform property = mycollection id=mycollection
bean:write name=mycollection property=string1
bean:write name=mycollection property=string2
bean:write name=mycollection property=string3
/logic:iterate

this part of my JSP works very fine.
after using the bean:write tag, which reads the data from 'mybean' class
and after end of logic:iterate tag, when i try to point to a property of myform again, i get an exception- no getter method for property...

like
after the logic iterate tag when i write
html:hidden name=myform property=mystring
i get the exception.

my string property is present in my ActionForm and not specified in MyBean class. In this case i get the Exception. If i use the same tag before using bean:Write tag then it is working fine.

i dont know whether this is because of bean:write or logic:iterate tag, where i point to a collection which contains object of some other class.

why is this exception coming?help me.

regards
Surendar.


SCJP 1.4
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If the tag is correctly coded it will work either before or after the <logic:iterate>, so there has to be something wrong with the tag or the corresponding ActionForm bean.

If you want help debugging it, please show us:
  • The full text of the exception
  • Relevant portions of your struts-config.xml file
  • Relevant portions of your JSP file, including the <html:form> tag
  • Relevant portions of your ActionForm class

  • ;
    [ October 27, 2006: Message edited by: Merrill Higginson ]

    Merrill
    Consultant, Sima Solutions
    surendar prabu
    Ranch Hand

    Joined: Jul 24, 2006
    Posts: 102
    Merill,
    Yes, its working fine. I made some mistake in naming the beanclass which is referred by the Id attribute. given the same name to Id attribute and name attribute in logic:iterate tag. I have changed id attribute and its working fine.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: about logic:iterate and bean:write tag
     
    Similar Threads
    logic:iterate and objects containing objects
    Get Hashmap value based on bean value.
    logic:iterate & DTO Problem
    How to use logic:iterate tag
    Cannot find bean in any scope...