Spring MVC 3 - custom labels in <form: select>

I create a form in which the user can select (among others) the factory of the product.

Each factory is identified by an identifier and an identifier and has a specific address.

I want to use a custom label in the following code:

<form:select items="${factories}" path="factory" itemValue="id" itemLabel="..."/>

At first I tried to use the Spring functionality of Formatter (org.springframework.format.Formatter interface), but when I did this and when I removed the itemLabel attribute so that it displays automatically through Formatter):

<form:select items="${factories}" path="factory" itemValue="id"/>

But then he did not select the correct value if it was installed (in case of editing).

Then I tried:

<form:select path="factory" itemValue="id">
    <c:forEach ...>
         <form:option value="${factory.id}" label="${factory.address.city} ${factory.address.street}"
    </c:foreach>
</form:select>

But as in the previous Spring solution, the correct value that was set in the model was not selected.

My question is:

, : select , .

+5
2

, , : , jstl.

, html - :

<select name="factory">
    <c:forEach var="factory" items="${factories}" >
        <option value="${factory.id}" label="${factory.address.city} ${factory.address.street}"/>
    </c:forEach>
</select>

Spring "" ( "factory" ), , .

- . @Entity @Transient.

+5

toString() Factory

 @Override
    public String toString() {
        return "desired string"; 
}

jsp

<form:select items="${factories}" itemValue="id" path="factory"/>
-1

All Articles