AjaxEventBehavior not working on feedback message components
------------------------------------------------------------

                 Key: WICKET-2438
                 URL: https://issues.apache.org/jira/browse/WICKET-2438
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4.1, 1.4.0
         Environment: N/A
            Reporter: Ian MacLarty


If you add an onclick AjaxEventBehavior to a component that is used to display 
a message in a FeedbackPanel, then when you click the feedback message Wicket 
throws an exception.  The exception looks like the following:

WicketMessage: org.apache.wicket.WicketRuntimeException: component 
feedback:feedbackul:messages:0:message not found on page bug.HomePage[id = 0], 
listener interface = [RequestListenerInterface name=IBehaviorListener, 
method=public abstract void 
org.apache.wicket.behavior.IBehaviorListener.onRequest()]

The problem seems to be caused by the change made in revision 796389, which 
removes all the child elements of the feedback panel when it is detached.

The bug can be reproduced by creating a wicket-1.4.1 quickstart app and 
modifying HomePage.html to be:

<html 
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.3-strict.dtd"; >
    <head>  
        <title>Wicket Quickstart Archetype Homepage</title>
    </head>
    <body>
        <form wicket:id="form"> 
            <input wicket:id="field" type="text" />
            <input type="submit" />
        </form>
        <div wicket:id="feedback" />
    </body>
</html>

and HomePage.java to be:

package bug;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.*;
import org.apache.wicket.model.*;
import org.apache.wicket.*;
import org.apache.wicket.markup.html.panel.*;
import org.apache.wicket.feedback.*;
import org.apache.wicket.ajax.*;

/**
 * Homepage
 */
public class HomePage extends WebPage {
    private Double value;

    public HomePage(final PageParameters parameters) {
        Form form = new Form("form", new CompoundPropertyModel(this));
        add(form);
        form.add(new TextField<Double>("field", Double.class));
        add(new FeedbackPanel("feedback") {
            @Override
            protected Component newMessageDisplayComponent(String id, 
FeedbackMessage message) {
                Label label;
                label = new Label(id, "click me");
                label.add(new AjaxEventBehavior("onclick") {
                    @Override               
                    protected void onEvent(AjaxRequestTarget target) {
                        System.out.println("error message clicked");
                    }
                });
                return label;
            }
        });
    }

    public void setField(Double field) {
        value = field;
    }

    public Double getField() {
        return value;
    }
}

Launch the app and enter an invalid number (e.g. "xxx").  Submit the form and 
then click the "click me" message.

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