AjaxEditableLabel#setModel() is broken
--------------------------------------

                 Key: WICKET-1160
                 URL: https://issues.apache.org/jira/browse/WICKET-1160
             Project: Wicket
          Issue Type: Bug
          Components: wicket-extensions
            Reporter: Peter Ertl


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...



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to