Wicket
  1. Wicket
  2. WICKET-4259

Using an IValidator on an AjaxEditableLabel causes ClassCastException

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.3
    • Fix Version/s: 1.5.4, 6.0.0-beta1
    • Component/s: wicket-extensions
    • Labels:
      None

      Description

      AjaxEditableLabel<Integer> label = new AjaxEditableLabel<Integer>("label", new PropertyModel<Integer>(this, "value"));
      form.add(label);
      label.setRequired(true);
      label.add(new RangeValidator<Integer>(1, 10));

      Using a RangeValidator<Integer> on an AjaxEditableLabel<Integer> causes an ClassCastException after editing the label.

      java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

      This can be avoided by setting the type explicit on the AjaxEditableLabel.

      label.setType(Integer.class);

      But this wasn't necessary in Wicket 1.4.19. In this version all works fine without setting the type explicit.

      I found out, that AbstractTextComponent.resolveType() is not able to get the type of the DefaultModel of the AjaxEditableLabel in Wicket 1.5.3.

      I will attach two QuickStarts to demonstrate the bug. One with wicket 1.4.19 and the other with Wicket 1.5.3

      1. WICKET-4259.patch
        2 kB
        Pedro Santos
      2. myproject1_4_19.zip
        18 kB
        Stefan Schulte
      3. myproject1_5_3.zip
        52 kB
        Stefan Schulte

        Activity

        Stefan Schulte created issue -
        Stefan Schulte made changes -
        Field Original Value New Value
        Attachment myproject1_5_3.zip [ 12505093 ]
        Attachment myproject1_4_19.zip [ 12505094 ]
        Pedro Santos made changes -
        Attachment WICKET-4259.patch [ 12505160 ]
        Pedro Santos made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Pedro Santos [ pedrosans ]
        Fix Version/s 1.5.4 [ 12319051 ]
        Fix Version/s 6.0.0 [ 12315431 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Pedro Santos
            Reporter:
            Stefan Schulte
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development