Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1160

AjaxEditableLabel#setModel() is broken

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.3.0-rc2
    • wicket-extensions
    • None

    Description

      The following code

      AjaxEditableLabel label = new AjaxEditableLabel("someid");
      label.setModel(...);

      will throw an NullPointerException.

      The reason is...

      public final Component setModel(IModel model)

      { super.setModel(model); *** getLabel().setModel(model); **** getEditor().setModel(model); return this; }

      getLabel() returns null because the label is not initialized.

      I suggest the following fix:

      protected final Component getLabel()

      { return label; }

      should be changed to

      protected final Component getLabel()
      {
      if (label == null)

      { initLabelAndEditor(getParentModel()); }

      return label;
      }

      this is similar to getEditor() which already initializes the component if it is null...

      Attachments

        1. AjaxEditableLabel.patch
          0.7 kB
          Peter Ertl

        Activity

          People

            jcompagner Johan Compagner
            pete Peter Ertl
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: