• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSTL nesting values?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the below code in a jsp page -- what I am trying to do is very common in that based on what a user previous selected in a menu(select) widget I need to then show that selected value in the menu again if the user submits the page and then is returned to the same page if there is an error condition(save the state) - my problem is I do not know how to achieve this as essentially I think I need to nest user.id within the test"${} condition - the below code does not work as user.id is not evaluating correctly? I am sure you must be able to do this somehow in jstl - I am just not familiar enough with jstl syntax -- I am using <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> tablib.

<select name="objectName" id="objectId>
<c:forEach var="user"items="${users}">

<option value="${user.id}"
<c:if test="${formBean.userId == user.id }">selected</c:if> > ${user.name}
</option>

</c:forEach>
</select>

Thanks very much
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on HTML and JavaScript.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic