wood burning stoves 2.0*
The moose likes Struts and the fly likes how to break from logic:iterate tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to break from logic:iterate tag" Watch "how to break from logic:iterate tag" New topic
Author

how to break from logic:iterate tag

pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
I have this code


Which I want the value Y and N to be displayed according to the value conditioned in <logic:equal> however when i run the website, it displayed
both Y and N.
Is there any struts tag library that enable to break from <loop:iteration> cause I've tried to put <%break;%> inside it but it result and error
Please give me some feedbacks, i'm in the middle of deadline
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
No, it is not possible to break from a <logic:iterate> loop.

Since you already have a lot of scriptlet code in this loop, I'd recommend that you dispense with the <logic:iterate> tags and <logic:equals> tags entirely and just write java code. Then you will have no problem breaking from the loop if you need to.

just get the variable from the request like this:

java.util.List fromKPI = (java.util.List)request.getAttribute("ListSmkKpi");

Then just iterate through the list as you would in any Java code.


Merrill
Consultant, Sima Solutions
pingkan paula
Ranch Hand

Joined: Sep 03, 2004
Posts: 117
I use java code as shown below

However, when i run the web it never reach condition of value "Y", it always
entering the condition of value "N"
The result of the debug is always "false" but when i checked the database it has several "Y" value
How am i going to solve this?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It seems pretty clear to me that if you find that the contents ListSmkKpi does not match what you know to be in the database, whatever process populated ListSmkKpi did not do so correctly. You'd do well to look at that process.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to break from logic:iterate tag