View Full Version : ItemLabel in Selectbox
Muminek
Dec 12th, 2006, 11:10 AM
Is there a possibility to use two values for the itemLabel in a
selectbox. In my example there is the firstname as the itemLabel, but i want to
show the lastname too how can i manage that.(I want to keep first and lastname separated in my object)
<form:select path="selectedRecipient" cssClass="select"
onchange="changeRecipient()" size="10" id="recipientSelect">
<form:options items="${templateTO.recipientList}" itemValue="recipientid"
itemLabel="firstname"/>
</form:select>
THX
Darbic (Aiteq Ltd.)
Dec 14th, 2006, 06:09 AM
I solved the similar issue. I added the getFullName method to my domain object.
Muminek
Dec 14th, 2006, 07:47 AM
Thx for the solution,
its simple and its working fine.
bmargula
Jul 4th, 2008, 08:24 PM
Hi,
I came across the same situation but I don't want to add code to my domain object which is only there for being able to show in a select in the view.
Is there another way to give itemLabel two values?
Thanks,
Bruno
worker
Nov 18th, 2008, 08:59 AM
I think this is the lack in spring:checkboxes and other elemens; it is not possible to do that
jglynn
Nov 19th, 2008, 03:15 PM
I disagree -- you can solve this a number of different ways without polluting the taglibs with what I would consider fringe case functionality.
worker
Nov 19th, 2008, 05:03 PM
I disagree that you disagree :D
So give an example.
It is not possible to do that way:
itemLabel="firstName secondName";
adding method to bean, getFullName(){ return firstName + secondName; } means that is lack in Spring - but it is some kind of solution
belugabob
Nov 21st, 2008, 10:13 AM
Hi,
I came across the same situation but I don't want to add code to my domain object which is only there for being able to show in a select in the view.
Is there another way to give itemLabel two values?
Thanks,
Bruno
How about creating a wrapper object, for use in the UI, that simply wraps the domain object? This wrapper object can provide the getFullName() method, which will return the concatenation of the domain object's firstName and lastName properties.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.