• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Problem with IndexId attribute

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All..
I am new to struts and having a problem with IndexId attribute of iterate..
I have to edit the marks of courses of some students..
so first i have to display the marks and courses and then submit new marks..


----my jsp code(editMarks.jsp)--------



---------my Form Bean(StudentMarksFrom.java)---------



------------my Action Form(StudentMarksAction.java)---------



-----Struts-confix.xml--------



I m getting an error "javax.servlet.ServletException: Exception thrown by getter for property course[0] of bean org.apache.struts.taglib.html.BEAN"

can anyone help me..
thanks in advance..
 
Ranch Hand
Posts: 471
Mac OS X Hibernate Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Vivek,

You have some mistakes in your JSP. Let's just explain the logic:iterate first. First of all, the id attribute is a name given to the current element of the collection you are iterating on. This means that if you are iterating on a collection named collection and you put the value of the id attribute as element, then at the first iteration, element will have the value of collection[0], and so on.

The indexId attribute is just a name of a variable that will act as a counter variable so that you can use it in your JSP for several reasons (for example if you are displaying results in rows, you can give a style to even rows, and another to odd ones), but not to get the element from the collection, since it's already there.

Now, your collection is in the action form, and that's a little tricky. Here, the name attribute should be the name of your form (I guess as defined in the struts config file), and the property attribute should be the name of the collection property in that form. I usually prefer putting my collections in a request attribute rather than in the form class.

I hope this helps. Please try and tell me the result
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic