tomcat-taglibs-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karr, David" <david.k...@wamu.net>
Subject RE: JSTL Question
Date Mon, 11 Apr 2005 21:26:51 GMT
If you want to save the result of an evaluation into another variable,
then just use "c:set" to set a variable from a value.

> -----Original Message-----
> From: Jack Lauman [mailto:jlauman@nwcascades.com] 
> Sent: Monday, April 11, 2005 9:32 AM
> To: Tag Libraries Users List
> Subject: Re: JSTL Question
> 
> 
> David:
> 
> The 'field'(s) are defined in RestaurantBean.java if they're 
> not there 
> nothing happens.  cuisine and city field's are exact matches. 
>  The name 
> field is user input and is case insensitive and will any 
> partial part of 
> a matching name.
> 
> What I want to do is to have param.field or 
> ${restaurant[param.field]} 
> evaluated only once at the beginning of the table.  param.field only 
> needs to be evaluated once as it becomes the name of the table.
> 
> Thanks,
> 
> Jack
> 
> Karr, David wrote:
> 
> > 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:jlauman@nwcascades.com]
> >>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: taglibs-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: 
> taglibs-user-help@jakarta.apache.org
> >>
> >>
> > 
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> taglibs-user-help@jakarta.apache.org
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Mime
View raw message