Announcement Announcement Module
Collapse
No announcement yet.
Possible Databinding Issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Possible Databinding Issue

    Hi all,

    It is not a big problem for my development but I would like to confirm if it is an issue or bug of Spring Framework or whether it is the normal behavior. By the way, if it isn't the most proper place for this post, whoever please make me know and I will move it.

    I have a bean with this the next property and respective getters and setters:

    Code:
    	@Column(name = "C_TO_Q_INDICATOR")
    	private String cToQIndicator = null;
    	
    	public String getcToQIndicator() {
    		return cToQIndicator;
    	}
    	public void setcToQIndicator(String cToQIndicator) {
    		this.cToQIndicator = cToQIndicator;
    	}
    Note that the generated getter and setter starts with "c" instead of "C", as I understand it should be.

    When I use have a list of that bean and I print it in a JSP page using <c:forEach>, surprisingly it works perfect. However, if I use that bean as model in a JSP rendered by Spring Webflow, I get the next error:

    Code:
    org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'cToQIndicator' cannot be found on object of type 'ie.i2e2.greenmode.dal.entity.ProjectTestingDetails'
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:208)
    	at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72)
    	at org.springframework.expression.spel.standard.SpelExpression.getValueType(SpelExpression.java:117)
    	at org.springframework.binding.expression.spel.SpringELExpression.getValueType(SpringELExpression.java:100)
    	at org.springframework.webflow.mvc.view.BindingModel.getFormattedValue(BindingModel.java:228)
    	at org.springframework.webflow.mvc.view.BindingModel.getFieldValue(BindingModel.java:142)
    	at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:120)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:198)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:164)
    	at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:127)
    	at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
    	at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
    	at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
    	at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
    [...]
    It seems that JSTL classes are using a different mechanism for building the proper getter method dynamically. The question would be, which one is correct?

    I hope anybody is able to explain what is happening, just for curiosity and for reporting a bug whether it really is a bug.

    Thanks in advance.

    Regards.

  • #2
    I would think that the proper Java Bean naming convention should be to use a upper case "C".

    What do you base your naming convention on ?

    Comment


    • #3
      Originally posted by ullgren View Post
      I would think that the proper Java Bean naming convention should be to use a upper case "C".

      What do you base your naming convention on ?
      Exactly, I think that should be to use a upper case "C" but if I change to upper case, works with SWF but doesn´t work with JSTlL... very strange, I know. I have based the named convention on Eclipse, I mean, getters and setters were autogenerated by Eclipse which I guess it follows the proper Java Bean naming convention.

      Thanks for your answer.

      Regards.

      Comment


      • #4
        What version of Spring, Eclipse, Java and what container (Tomcat, Jetty or other) are you using ?

        Comment


        • #5
          I'm using Java 1.6.0_32, Spring 3.1, Spring Webflow 2.3 and Tomcat 6.0... everything on Eclipse Indigo R2.

          By the way, did you try to create a bean with the same attribute and generate getters and setters? Whatever the environment...

          Thanks.

          Comment


          • #6
            No I have not yet recreated the problem. My initial answer was just a hunch. I will see if I have time to create a test case to recreate it.
            Do you happen to have a small proof of concept project for this issue ?

            From what I can tell it will probably only happen when the property has a name that starts with a single lowercase letter. If the property is ccToQIndicator I assume it will work (the getter will be getCcToQIndicator()).
            Potential workarounds would of course be to rename the property in your java classes.

            Comment


            • #7
              Originally posted by ullgren View Post
              From what I can tell it will probably only happen when the property has a name that starts with a single lowercase letter. If the property is ccToQIndicator I assume it will work (the getter will be getCcToQIndicator()).
              Potential workarounds would of course be to rename the property in your java classes.
              Exactly, that's the same I think. In fact, I renamed the attribute from "cToQIndicator" (getcToQIndicator() getter) to "ctoqIndicator" (getCtoqIndicator() getter) for continuing working. As you well say, it seems that this issue only occurs when the first character of the attribute is a single lowercase, I got the same conclusion.

              Originally posted by ullgren View Post
              Do you happen to have a small proof of concept project for this issue ?
              I'm sorry, I currently don't have. I discovered this issue while working with my company's project. Anyway, if you are really interested on this issue I could build it...

              Thanks again for your answers.

              Good weekend.

              Comment

              Working...
              X