validation
  1. validation
  2. VALIDATION-21

#hasErrors not following JavaBean spec conventions

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: HEAD
    • Fix Version/s: not determined
    • Component/s: core
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      21

      Description

      In AbstractValidationResultModel, there's a 'getter' hasErrors for the bound
      property 'errors'.

      This does not conform to the javabeans spec, which recommends isErrors or getErrors.

      As a result of this, it becomes impossible to use this property with the binding
      framework's PropertyConnector.connect(), which doesn't let you specify specific
      methods (Unless I've missed something there).

      What I'd like to be able to do is:
      PropertyConnector.connect(getPresentationModel().getValidationResultModel(),
      ValidationResultModel.PROPERTYNAME_ERRORS, saveButton, "enabled");

      But this is right now impossible.

      I can understand isErrors not feeling like a right name, instead the propertie
      could possibly become hasErrors, so we'd get a getHasErrors(), or isHasErrors(),
      for example.

      Thanks for your attention!

        Activity

        Hide
        karsten added a comment -

        The JavaBean specification explicitly allows to use arbitrary names for getters
        and setters. This is useful for legacy code as well as for cases where both the
        'get' and the 'is' prefix lead to a poor getter name, such as 'isHasErrors' or
        'isErrors'. However, there's a convention and the ValidationResultModel doesn't
        follow the convention - for good reasons.

        Therefore I've change the subject and issue type. I could add a BeanInfo class
        that could specify "hasErrors" as getter name for the "errors" property. That's
        the recommended way as outlined by the bean spec, if you don't want to follow
        the naming conventions [and a bunch of other reasons].

        You can bind this property using the JGoodies Binding. You can make "hasErrors"
        adaptable using a PropertyAdapter that has a constructor where you can specify
        the name of the getter and setter.

        Anyway, since this property is read-only, the two-way PropertyConnector is
        oversized, and I'd just use a PropertyChangeListener that listens to the
        ValidationResultModel and updates whatever properties.

        Show
        karsten added a comment - The JavaBean specification explicitly allows to use arbitrary names for getters and setters. This is useful for legacy code as well as for cases where both the 'get' and the 'is' prefix lead to a poor getter name, such as 'isHasErrors' or 'isErrors'. However, there's a convention and the ValidationResultModel doesn't follow the convention - for good reasons. Therefore I've change the subject and issue type. I could add a BeanInfo class that could specify "hasErrors" as getter name for the "errors" property. That's the recommended way as outlined by the bean spec, if you don't want to follow the naming conventions [and a bunch of other reasons] . You can bind this property using the JGoodies Binding. You can make "hasErrors" adaptable using a PropertyAdapter that has a constructor where you can specify the name of the getter and setter. Anyway, since this property is read-only, the two-way PropertyConnector is oversized, and I'd just use a PropertyChangeListener that listens to the ValidationResultModel and updates whatever properties.

          People

          • Assignee:
            validation-issues
            Reporter:
            cranphin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: