• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Want to use a jstl value in another expression  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I try to create a table that includes a unit in the first column. In the second column I want to create a drow down list with managers, and the manager for the specific unit should be selected. Everything works fine except for the selection of the correct manager.

Here is my code:

<table width="500" cellspacing="0" cellpadding="0" border="1">
<tr>
<td> <b>Unit</b></td>
<td>nbsp;<b>Manager</b></td>
</tr>
<c:forEach items="${UnitList}" var="unitrow">
<c:set var="unitManagerField" value="${UnitManager${unitrow.unitId}
}"/>
<tr>
<td class="inputcell">
<cut value="${unitrow.UnitName}" />
</td>
<td> 
<select>
<c:forEach items="${managerList}" var="manrow">
<option value='<cut value="${manrow.userId}" />'

//Test wanted

>
<cut value="${manrow.userName}" />
</option>
</c:forEach>
</select>
</td>
</tr>
</c:forEach>
</table>

In the "Test wanted" part above, I want to check if manrow.userId is equals to the value that is stored in the request attribute that has the same name as the string stored in variable unitManagerField. But when I have set the variable unitManagerField above, then the value "UnitManager10" for example, is stored as a string. And when I put the variable in <cut value="${unitManagerField}" /> I just get the string, not the value from the field.

I do not know how to solve this. Please help.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the fact that I difficulties to understand the meaning of the first forEach loop ;), did you try to use the c:if tag ?
 
Author and ninkuma
Marshal
Posts: 66820
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!