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:[EMAIL PROTECTED] > 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:[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] > > > > > > > --------------------------------------------------------------------- > 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]