Spring MVC form:radiobuttons tag nicht die Einstellung value-Attribut

Hier ist der relevante code von meinem controller:

@ModelAttribute("store_location_types")
public StoreLocationType[] getStoreLocationTypes() {
    return StoreLocationType.values();
}

Hier ist die definition von StoreLocationType, definiert in der gleichen Steuerung:

private enum StoreLocationType {
    PHYSICAL("Physical"),
    ONLINE("Online");

    private String displayName;
    private String value;

    private StoreLocationType(String displayName) {
        this.displayName = displayName;
        this.value = this.name();
    }

    public String getDisplayName() {
        return this.displayName;
    }

    public String getValue() {
        return this.value;
    }
}

Hier ist die entsprechende JSP-code:

        <li>
            <label>Location Type:</label>
            <form:radiobuttons path="StoreLocationType" items="${store_location_types}" itemLabel="displayName" itemValue="value"/>
        </li>

Ist das, was hier generiert wird, wenn die Seite gerendert wird:

    <li>
        <label>Location Type:</label>            
        <span>
            <input id="StoreLocationType1" name="StoreLocationType" type="radio" value="">                         
            <label for="StoreLocationType1">Physical</label>
        </span>
        <span>
            <input id="StoreLocationType2" name="StoreLocationType" type="radio" value="">       
            <label for="StoreLocationType2">Online</label>
        </span>
    </li>

Die value-Attribute werden nicht aufgefüllt, mit dem "Wert" - Feld meiner enum. Was mache ich hier falsch? Was ich erwarten würde, zu sehen, ist diese:

        <span>
            <input id="StoreLocationType1" name="StoreLocationType" type="radio" value="PHYSICAL">                         
            <label for="StoreLocationType1">Physical</label>
        </span>
        <span>
            <input id="StoreLocationType2" name="StoreLocationType" type="radio" value="ONLINE">       
            <label for="StoreLocationType2">Online</label>
        </span>

Dem value-Attribut des input-Tags sollte der Wert StorLocationType.ONLINE.getValue()

InformationsquelleAutor aamiri | 2013-06-22

Schreibe einen Kommentar