Tapestry 5
  1. Tapestry 5
  2. TAP5-1895

ValidationDecorator.insideLabel(...) is called after the removal of PropertyContext in PropertyEditor

    Details

      Description

      I want to add css class to label if field is required in my custom ValidationDecorator:

      @Override
      public void insideLabel(Field field, Element labelElement) {

      if(field == null) return;

      if(field.isRequired())

      { labelElement.addClassName("required-label"); }

      if(inError(field))

      { labelElement.addClassName(CSSClassConstants.ERROR); }

      }

      It does not work with BeanEditForm component. The problem arises because method ValidationDecorator.insideLabel(...) is called in Label component after removal of PropertyContext from Environment (PropertyContext is needed for get the validator and call isRequired() method):

      @HeartbeatDeferred
      private void updateAttributes()

      { String fieldId = field.getClientId(); labelElement.forceAttributes("for", fieldId); decorator.insideLabel(field, labelElement); }

      The solution for this problem would be to move the call to decorator.insideLabel (field, labelElement) to the beginRender method in Label component. Label decorating does not need to wait for rendering field element and only needs a label element.

      1. TAP5-1895.patch
        0.7 kB
        Vladimir Velikiy

        Activity

        Vladimir Velikiy created issue -
        Vladimir Velikiy made changes -
        Field Original Value New Value
        Fix Version/s 5.3.3 [ 12320045 ]
        Fix Version/s 5.4 [ 12316401 ]
        Hide
        Vladimir Velikiy added a comment -

        The patch is attached

        Show
        Vladimir Velikiy added a comment - The patch is attached
        Vladimir Velikiy made changes -
        Attachment TAP5-1895.patch [ 12521295 ]
        Hide
        Howard M. Lewis Ship added a comment -

        ValidationDecorator is deprecated in 5.4 and will soon be removed.

        Show
        Howard M. Lewis Ship added a comment - ValidationDecorator is deprecated in 5.4 and will soon be removed.
        Howard M. Lewis Ship made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Howard M. Lewis Ship [ hlship ]
        Fix Version/s 5.4 [ 12316401 ]
        Fix Version/s 5.3.3 [ 12320045 ]
        Resolution Won't Fix [ 2 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        476d 15h 49m 1 Howard M. Lewis Ship 25/Jul/13 00:48

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Vladimir Velikiy
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development