Home » Java

Multiple Values Form:Select in Spring Java

Written By: techieDan on November 17, 2009 No Comment

Have been searching how to do multiple values in Spring.

What is Spring?

Spring Java

There are no complications when displaying only a single id or a value while using spring and form taglib by doing this.

<form:select path=”prospect.wholeSaleId” items=”${List}”
itemLabel=”wholeSaleId” itemValue=”wholeSaleId”>

Now itemLabel would display the wholeSaleId value. The problem now is how to display let’s say wholeSaleId – CustomerName in the itemLabel. One workaround is to use the <c:forEach> core taglib.

<form:select path=”prospect.wholeSaleId”>
<c:forEach items=”${List}” var=”prospect”>
<form:option value=”${prospect.wholeSaleId}”><c:out value=”${prospect.wholeSaleId}”/> – <c:out value=”${prospect.companyName}”/></form:option>
</c:forEach>
</form:select>

Now by doing so, you are now able to display two value. The HTML equivalent of such will now display like this. (Assuming it has only 3 values)

<select name=”wholeSaleId”>
<option value=”wholeSaleIdValue1″>wholeSaleIdValue1 – companyName1</option>
<option value=”wholeSaleIdValue2″>wholeSaleIdValue2 – companyName2</option>
<option value=”wholeSaleIdValue3″>wholeSaleIdValue3 – companyName3</option>
</select>

So there you have it. A workaround for the form tag in Spring Framework.

Related Posts with Thumbnails

Tags: , ,

Digg this!Add to del.icio.us!Stumble this!Add to Techorati!Share on Facebook!Seed Newsvine!Reddit!Add to Yahoo!

Trackbacks/Pingbacks

  1. Tweets that mention Multiple Values Form:Select in Spring Java | TechieDan -- Topsy.com

Leave a Reply:

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  Copyright © 2009 TechieDan, All rights reserved.| Powered by WordPress