I have a dropdown, the value of which I am generating in my controller and passing that value to my jsp page. I am getting the following exception in the "itemValue" attribute of my "form:options" tag. Why do I need a getter setter for the itemValue because however I am having value for my "typeCode". But to avoid any confusion, I added getter setter for idValue also, but still getting the same error. Kindly help.
JSP:
<%
Map LCCLSTypeCode = (Map) request.getAttribute("LCCLSTypeCode");
System.out.println("LCCLSTypeCode:"+LCCLSTypeCode);
%>
<form:form action="/tradelc/ClsSave" method="POST" onsubmit="return CheckPassword()">
.
.
.
.
.
<form:select path="typeCode">
<form:options items="<%=LCCLSTypeCode%>" itemValue="idValue" itemLabel="displayValue"/>
</form:select>
.
.
.
<a href="javascript:submitPageX();">Create</a>
<script>
function submitPageX()
{
document.forms[0].submit();
return false;
}
Controller:
@Controller
@SessionAttributes("clsData")
public class InformLoginAction{
@ModelAttribute("clsData")
public ClauseData createBean() {
return new ClauseData();
}
@RequestMapping(value = "/informlogin", method = RequestMethod.GET)
public ModelAndView execute( HttpServletRequest request,
HttpServletResponse response,
@ModelAttribute("clsData") ClauseData clauseData,
BindingResult bindingResult)
throws Exception {
.
.
.
.
Map newMap = new HashMap();
while(enu!=null && enu.hasMoreElements())
{
newMap.put(omxComboBean.assignId(item.trim()),omxComboBean.assignValue(text));
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("menu1");
modelAndView.addObject("command", new ClauseData());//Specifying the bean
modelAndView.addObject("LCCLSTypeCode", newMap);//Specifying the value for the dropdown
return modelAndView;
}
}
OmxComboBean.java:
public String assignId(String id)
{
idValue = id;
return id;
}
public String assignValue(String value)
{
displayValue = value;
return value;
}
Bean class ClauseData.java:
public class ClauseData {
private String typeDesc;
private String idValue;
public String getTypeCode(){return typeCode;}
public void setTypeCode(String typeCode){this.typeCode = typeCode;}
public String getIdValue(){return idValue;}
public void setIdValue(String idValue){this.idValue = idValue;}
}
Exception:
org.springframework.beans.NotReadablePropertyException: Invalid property 'idValue' of bean class [java.lang.String]: Bean property 'idValue' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:723)
org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:714)
org.springframework.web.servlet.tags.form.OptionWriter.renderFromMap(OptionWriter.java:166)
org.springframework.web.servlet.tags.form.OptionWriter.writeOptions(OptionWriter.java:136)
org.springframework.web.servlet.tags.form.OptionsTag.writeTagContent(OptionsTag.java:155)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)