Take the 2-minute tour ×

The following jstl code is showing strange behaviour:


<sf:select path="bedrooms[0]" multiple="multiple" items="${property.bedrooms[0].beds}" />


The output is:

Bedroom{id=4, beds=[KING, QUEEN], enSuite=false} 

| KING        |

Bedroom{id=4, beds=[KING], enSuite=false}

Bedroom.toString() contains:

public String toString()
    return "Bedroom{" + "id=" + id + ", beds=" + beds + ", enSuite=" + enSuite + '}';

property.bedrooms[0].beds is a List<Enum>, and it seems that accessing it in the items attribute is cutting out all but the first element!! Any idea what could be causing this?

Cheers! NFV

share|improve this question
Why is the second rendering of the bedroom instance different? –  Kyle Dec 30 '12 at 16:48
Thats what i cannot understand, it's beds list should not be modified by sf:select but it seems that it is? –  nfvindaloo Dec 30 '12 at 17:37
What does the toString method on the bedroom class look like? Does it call remove? –  Kyle Dec 30 '12 at 21:22
No, just standard - ive added it above –  nfvindaloo Dec 31 '12 at 11:53
see my answer. It may help –  Kyle Dec 31 '12 at 17:29
add comment

1 Answer

up vote 1 down vote accepted


<sf:form modelAttribute="property">
    <sf:select path="bedrooms[0].beds" multiple="true">
        <sf:options />

According to the spring-form(3.0.x) tld documentation and the source code java doc: http://static.springsource.org/spring/docs/3.0.x/reference/spring-form.tld.html#spring-form.tld.options

If the bound value on the select is an enum spring will automatically use the list of all enum values for that class.

The itemLabel and itemValue properties of the options tag may be used to display a more user friendly label.

<sf:options itemLabel="friendlyName" />
share|improve this answer
I'll give that a try... –  nfvindaloo Dec 31 '12 at 22:33
Works perfectly, and makes sense now I think about it, Thanks! –  nfvindaloo Jan 2 '13 at 18:02
add comment

Your Answer


