JSTL Help Again

[nobr]This is what the below code is printing out.

List(1) item (1)

List(2) item (1)

List(2) item (2)

List(1) item (2)

List(2) item (1)

List(2) item (2)

But I want it to print out like so:

List(1) item (1)

List(2) item (1)

List(1) item (2)

List(2) item (2)

--

I have tried many different ways to do this but just cant get it working properly. I would appreciate any help and/or direction.

Thanks in advance.

<c:forEach var="impact" items="${displayImpact.impactList}" varStatus="status">

<c:forEach var="impactKeys" items="${impact}" varStatus="status">

<tr>

<td class="reportTable" valign="top" align="center" colspan="6">Quality Owner Acknowlegement - <c:out value="${status.count}"/></td>

</tr>

<c:forEach var="impactValue" items="${impactKeys.value}" varStatus="s">

<c:choose>

<c:when test="${(s.count == 1)}">

<tr>

<c:choose>

<c:when test='${(impactValue) == "military"}'>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="military" checked readonly>Military</td>

</c:when>

<c:otherwise>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="military" readonly disabled>Military</td>

</c:otherwise>

</c:choose>

<c:choose>

<c:when test='${(impactValue) == "commercial"}'>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="commercial" checked readonly>Commercial</td>

</c:when>

<c:otherwise>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="commercial" readonly disabled>Commercial</td>

</c:otherwise>

</c:choose>

<c:choose>

<c:when test='${(impactValue) == "common"}'>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="common" checked readonly>Common</td>

</c:when>

<c:otherwise>

<td valign="top" colspan="2"><input type="radio" NAME="impactClass<c:out value="${status.count}"/>" VALUE="common" readonly disabled>Common</td>

</c:otherwise>

</c:choose>

</tr>

</c:when>

<c:when test="${(s.count == 2)}">

<tr>

<c:choose>

<c:when test='${(impactValue) == "no"}'>

<td valign="top" colspan="3"><input type="radio" NAME="impactAffect<c:out value="${status.count}"/>" VALUE="no" checked readonly>The condition of the measuring Equipment has been determined to NOT have an adverse affect on any engineering/production component.</td>

</c:when>

<c:otherwise>

<td valign="top" colspan="3"><input type="radio" NAME="impactAffect<c:out value="${status.count}"/>" VALUE="no" disabled>The condition of the measuring Equipment has been determined to NOT have an adverse affect on any engineering/production component.</td>

</c:otherwise>

</c:choose>

<c:choose>

<c:when test='${(impactValue) == "yes"}'>

<td valign="top" colspan="3"><input type="radio" NAME="impactAffect" VALUE="yes" checked readonly>The conditions of the Measuring Equipment has been determined to HAVE AN ADVERSE AFFECT on engineering/production component.</td>

</c:when>

<c:otherwise>

<td valign="top" colspan="3"><input type="radio" NAME="impactAffect" VALUE="yes" disabled>The conditions of the Measuring Equipment has been determined to HAVE AN ADVERSE AFFECT on engineering/production component.</td>

</c:otherwise>

</c:choose>

</tr>

</c:when>

<c:when test="${(s.count == 3)}">

<tr>

<td valign="top"><a href>Comments:</a></td>

<td valign="top" colspan="5"><TEXTAREA NAME="comment" ROWS=5 COLS=75% readonly><c:out value='${impactValue}'/></TEXTAREA>?lt;/td>

</tr>

</c:when>

<c:when test="${(s.count == 4)}">

<tr>

<td valign="top"><a href>Recommendationfor Tool:</a></td>

<td valign="top" colspan="5"><span class="reportInstruction">* Without further instruction tool will be repaired and returned to production.</span>

<br><TEXTAREA NAME="comment" ROWS=5 COLS=75% readonly><c:out value='${impactValue}'/></TEXTAREA>?lt;/td>

</tr>

</c:when>

<c:when test="${(s.count == 5)}">

<tr>

<td valign="top"><a href>Acknowledged by:</a></td>

<td valign="top" colspan="2"><c:out value="${impactEmail.impactFirst}"/>?lt;c:out value="${impactEmail.impactLast}"/><%//<c:out value='${impactValue}'/>%>?lt;/td>

</c:when>

<c:when test="${(s.count == 6)}">

<td valign="top"><a href>Date:</a></td>

<td valign="top" colspan="2"><c:out value='${impactValue}'/>?lt;/td>

</tr>

</c:when>

</c:choose>

</c:forEach>

<c:forEach var="quality" items="${displayQuality.qualityList}" varStatus="status">

<c:forEach var="qualityKeys" items="${quality}" varStatus="status">

<tr>

<td class="reportTable" valign="top" align="center" colspan="6"> Quality Team Rep Review</td>

</tr>

<c:forEach var="qualityValue" items="${qualityKeys.value}" varStatus="s">

<c:choose>

<c:when test="${(s.count == 1)}">

<tr>

<td valign="top"><a href>Findings:</a></td>

<td valign="top" colspan="5">

<c:choose>

<c:when test='${(qualityValue) == "yes"}'>

<input type="radio" NAME="qualityFindings<c:out value="${status.count}"/>" VALUE="yes" checked readonly>Accept Findings<br>

</c:when>

<c:otherwise>

<input type="radio" NAME="qualityFindings<c:out value="${status.count}"/>" VALUE="yes" disabled>Accept Findings<br>

</c:otherwise>

</c:choose>

<c:choose>

<c:when test='${(qualityValue) == "no"}'>

<input type="radio" NAME="qualityFindings" VALUE="no" checked readonly>Reject Findings<br>

</c:when>

<c:otherwise>

<input type="radio" NAME="qualityFindings" VALUE="no" disabled>Reject Findings<br>

</c:otherwise>

</c:choose>

</tr>

</c:when>

<c:when test="${(s.count == 2)}">

<tr>

<td valign="top"><a href>Comments:</a></td>

<td valign="top" colspan="5"><TEXTAREA NAME="qualityComments" ROWS=5 COLS=75% readonly><c:out value='${qualityValue}'/></TEXTAREA></td>

</tr>

</c:when>

<c:when test="${(s.count == 3)}">

<tr>

<td valign="top"><a href>Reviewed By:</a></td>

<td valign="top" colspan="2"><c:out value="${qualityEmail.qualityFirst}"/>?lt;c:out value="${qualityEmail.qualityLast}"/></td>

</c:when>

<c:when test="${(s.count == 4)}">

<td valign="top"><a href>Date:</a></td>

<td valign="top" colspan="2"><c:out value='${qualityValue}'/>?lt;/td>

</tr>

</c:when>

</c:choose>

</c:forEach>

</c:forEach>

</c:forEach>

</c:forEach>

</c:forEach>

[/nobr]

[12778 byte] By [punnkdorka] at [2007-10-2 0:13:32]
# 1

Is there any way you can simply your view code by doing more of this logic in your action servlet? I'll admit, I didn't look over your code closely, but if there is logic that can be moved from this view into the controller, I'd do it. Make your view as simple as possible. You did step one and didn't put in a ton of scriptlet code, but it's basically the same when you use this amount of JSTL in your view. I know this isn't exactly your desired answer, but hopefully, a re-thinking of this approach might lead to a better design and less JSTL/scriptlet code in your view.

Where I work, we have a standing order to keep our JSPs as simple as possible - doing most of the prep work in the action classes. So far, it's been a very good decision. We still have JSTL in our JSPs, but nothing like what you have here. Don't be affraid to break this thing up into multiple pages with different functinality. The controller is supposed to dispatch to a view which handles a specific task. break up that conditional logic, if possible, into multiple targets.

Again, take all of this lightly since I didn't dig into your code too close. I could be way off for your needs.

st.murphya at 2007-7-15 16:14:56 > top of Java-index,Java Essentials,New To Java...