Displaying dropdown list depends on selected value from other list

I am working on a project in spring mvc 4 and which should display three dropdown lists where the second list depends on the selected value from the first list and the third on the selected value in the second list.

I have defined enum:

public enum Type{
    a{
         getListOfSubTypes(){...};
         getListOfObjectsBySubType(ObjectList subType){...};
    },
    b{
         getListOfSubTypes(){...};
         getListOfObjectsBySubType(ObjectList subType){...};
    c{
         getListOfSubTypes(){...};
         getListOfObjectsBySubType(ObjectList subType){...};
     }
};

getListOfSubTypes produce a list of sub types.
getListOfObjectsBySubType produce a list of objects by sub types.

Is there a way to fetch directly in the jsp file the subtypes and the objects type accordingly to the chosen type? or should I have to perform conversions in the model?

The first dropdown displays “a,b,c” list as expected by:

 <form:select class="form-control input-sm" path="task.type">
     <form:options items="${types}"/>
 </form:select>

Means, the page will have three dropdons:
Type: a,b,c -> the user will choose type b.
SubTypes: in case of type ‘b’, the list is 4,5,6
Objects: in case of sub type ‘6’, the list is O7,O8.

Thanks in advance,
Mike


Source: New Questions

Leave a Reply