It's a little hard to tell exactly what you're trying to do here, but it
might be helpful to know that '${restaurant.cuisine}' is the same as
'${restaurant[param.field]}' if "param.field" is equal to "cuisine".
With this, you would need only the single case.  This strategy is only
useful if you really can guarantee that you know all the possible values
of "param.field".  If you can't be certain, then this could produce
unexpected problems down the road.

> -----Original Message-----
> From: Jack Lauman [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, April 10, 2005 1:37 PM
> To: Tag Libraries Users List
> Subject: JSTL Question
> 
> 
> I have the following 'working' code to produce a table.  The value of 
> ${param.field} determines which field will be displayed in column 3. 
> Can I move this out of the c:forEach loop and assign a temp 
> variable to 
> it using c:if/c:set so that I only need to evaluate the value of 
> ${param.field} once and not on every line?  ${param.field} 
> will always 
> equal city, cuisine or name.
> 
> Thanks,
> 
> Jack
> 
> <c:forEach items="${restaurantInfo.restaurants}"
>    var="restaurant">
> 
> <c:set target="${restaurant}"
>    property="filterField" value="${param.field}" />
> <c:if
>    test="${fn:containsIgnoreCase(restaurant.filterValue, 
> param.value)}">
> 
> ......
> <c:choose>
>    <c:when
>      test="${param.field eq 'city'}">
> 
>      <td width="79">
>      <div align="left"><font size="1"
>        face="Verdana, Arial, Helvetica, sans-serif">
>      <c:out value="${restaurant.cuisine}" /> </font></div>
>      </td>
>    </c:when>
> 
>    <c:otherwise>
>      <td width="79">
>      <div align="left"><font size="1"
>        face="Verdana, Arial, Helvetica, sans-serif">
>      <c:out value="${restaurant.city}" /> </font></div>
>      </td>
>    </c:otherwise>
> </c:choose>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to