aspose file tools*
The moose likes Struts and the fly likes Multiple level logic:iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Multiple level logic:iterate" Watch "Multiple level logic:iterate" New topic
Author

Multiple level logic:iterate

andrea casini
Greenhorn

Joined: Jul 27, 2010
Posts: 13
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

Joined: May 05, 2010
Posts: 213

What is the error message?
Richard Golebiowski
Ranch Hand

Joined: May 05, 2010
Posts: 213

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

Joined: Jul 27, 2010
Posts: 13
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

Joined: May 05, 2010
Posts: 213

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

Joined: Jul 27, 2010
Posts: 13
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

Joined: May 05, 2010
Posts: 213


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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple level logic:iterate