Announcement Announcement Module
Collapse
No announcement yet.
Exception binding to command in Wizard Form JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception binding to command in Wizard Form JSP

    Hi all,

    I'm getting an exception when I try to bind to my command object on the first page of my AbstractFormWizard controller. I'm hoping someone can shed some light on it for me, as I've been stepping through the debugger and am stumped. I would really appreciate any help. Here are the relevant snippets:

    The JSP (note the command name is "model" in my spring config):

    <spring:bind path="model.listingType"><input type="radio" name="${status.expression}" id="premium" value="premium" <c:if test="${status.value == 'premium'}">checked</c:if>/></spring:bind>

    The AbstractWizardFormController snippets:

    protected Object formBackingObject(HttpServletRequest request) {
    Map<String, Object> model = new HashMap<String, Object>();

    // <"listing", Listing> is the other value in this structure
    model.put("listingType", PremiumListing.getTypeName()); // getTypeName returns a String
    return model;
    }

    The stack trace:
    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'listingType' of bean class [java.util.HashMap]: Bean property 'listingType' 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.getPrope rtyValue(BeanWrapperImpl.java:584)
    org.springframework.beans.BeanWrapperImpl.getPrope rtyValue(BeanWrapperImpl.java:576)
    org.springframework.validation.BindException.getFi eldValue(BindException.java:295)
    org.springframework.web.servlet.support.BindStatus .<init>(BindStatus.java:114)
    org.springframework.web.servlet.tags.BindStatus.<i nit>(BindStatus.java:38)
    org.springframework.web.servlet.tags.BindTag.doSta rtTagInternal(BindTag.java:105)
    org.springframework.web.servlet.tags.RequestContex tAwareTag.doStartTag(RequestContextAwareTag.java:7 3)
    org.apache.jsp.WEB_002dINF.jsp.add_002dlisting_002 dselect_jsp._jspService(org.apache.jsp.WEB_002dINF .jsp.add_002dlisting_002dselect_jsp:135)
    org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:99)

    System Specs
    Tomcat 5.5.4
    Spring 1.1.3

  • #2
    I've found the problem. For some reason, I was thinking Bind would use listingType as a key to do a lookup on HashMap. Instead, it was looking for listingType the property. Anyhow, I've adjusted my data structure and am fine now. If anyone knows the rt expression syntax for a key lookup, it would be cool to hear it for academic purposes.

    Comment


    • #3
      did you try <spring:bind path="model["listingType"]">?

      Comment

      Working...
      X