Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple level logic:iterate

 
andrea casini
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all.

This is my first message in this forum, please sorry for the english..:P

I have this two classes:


And the other one:


What I have to do is display the collection of "Spettacolo" mapped in the database with hibernate. So I create an action wich loads the collection in the session and then in the jsp I do this:


I can display the property "nome" "descrizione" but when I have to deal with the collection property everything goes wrong, it gives me a jasperexeception in the second iterate and I can't find a solution.

Please someone help me, I'm desperate, is being two days that I'm stuck here.
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error message?
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried out your code and it worked. Hawever if dateRappresentazione is null I get the following errror:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: No collection found
 
andrea casini
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Golebiowski wrote:I tried out your code and it worked. Hawever if dateRappresentazione is null I get the following errror:

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: No collection found


LOL..Thanks for your reply..
So the problem may be in the action anyway I get this error:

The code of the action is the following:


And the method "getAll":

 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are getting to the JSP page then the error is somewhere on the page. When I've gotten errors similar to what you are displaying, the error is usually somewhere else on the page, not in the lines displayed on the error message. Try removing everything from the JSP so that the JSP page loads and then adding things it back piece by piece until the error occurs.
 
andrea casini
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Golebiowski wrote:If you are getting to the JSP page then the error is somewhere on the page. When I've gotten errors similar to what you are displaying, the error is usually somewhere else on the page, not in the lines displayed on the error message. Try removing everything from the JSP so that the JSP page loads and then adding things it back piece by piece until the error occurs.


It seems that the error is actually a lazyinitialition and struts could'nt see the list "dateRappresentazione". So I set "fetch = FetchType.EAGER" in the "Spettacolo" beans and it WORKED. How do you get this working without setting the fethtype?

Anyway now I have another problem..
It display in the jsp as many object as many are contained in the list "dateRappresentazione". I don't know why, maybe because of the syntax of logic iterate.
 
Richard Golebiowski
Ranch Hand
Posts: 213
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It seems that the error is actually a lazyinitialition and struts could'nt see the list "dateRappresentazione". So I set "fetch = FetchType.EAGER" in the "Spettacolo" beans and it WORKED. How do you get this working without setting the fethtype?


Good catch on the problem. FetchType is a Hibernate setting, and I'm not that experienced with Hibernate so I can't answer your question. Any questions about that setting should be posted in the Object Relational Mapping forum.



It display in the jsp as many object as many are contained in the list "dateRappresentazione". I don't know why, maybe because of the syntax of logic iterate.

If you are saying that it is displaying everything in the list then the iterate is working correctly. If you only want to display a certain part of the list you will need to change the logic.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic