views:

44

answers:

0

hi, I have simple spring mvc web application.I want to bind list into drop down.In this case list items are normally bind into drop down; but If I select item and click submit button it is always passing "0" instead of value.

This is my controller.

public EditEmployeeController() {
        setCommandClass(Employee.class);
        setCommandName("employee");
}

@Override
protected Map referenceData(HttpServletRequest request) throws Exception {
    Map referenceData = new HashMap();        
    List roleList = roleService.listRoles();
    referenceData.put("roleList", roleList);
    return referenceData;
}

@Override
protected ModelAndView onSubmit(HttpServletRequest request,
        HttpServletResponse response,
        Object command,
        BindException errors) throws Exception {
    Employee employee = (Employee) command;
    employeeService.updateEmployee(employee);
    return new ModelAndView(getSuccessView());
}

This is my view(jsp)

<c:nestedPath path="employee">
            <form method="post" action="./EditEmployee.htm">
........
.......

Select Role :                
<c:bind path="roleID">
 <select name="roleLists">
   <s:forEach items="${roleList}" var="role" >
       <option value="<s:out value="${role.roleID}"/>" <s:if test="${role.roleID == status.value}"> selected="selected"</s:if>><s:out value="${role.title}"/></option>
        </s:forEach>
  </select>
</c:bind>
<input type="submit" value="Update employee"/
</form>
</c:nestedPath>

Any idea for solve my problem..??

Thank in advance!