You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Igor Vaynberg (JIRA)" <ji...@apache.org> on 2010/08/31 02:14:02 UTC

[jira] Resolved: (WICKET-1733) WicketTester doesn't include form submitting component id in form submissions

     [ https://issues.apache.org/jira/browse/WICKET-1733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Igor Vaynberg resolved WICKET-1733.
-----------------------------------

         Assignee: Igor Vaynberg
    Fix Version/s: 1.4.11
                   1.5-M2
       Resolution: Fixed

> WicketTester doesn't include form submitting component id in form submissions
> -----------------------------------------------------------------------------
>
>                 Key: WICKET-1733
>                 URL: https://issues.apache.org/jira/browse/WICKET-1733
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.3
>            Reporter: David Shepherdson
>            Assignee: Igor Vaynberg
>            Priority: Minor
>             Fix For: 1.4.11, 1.5-M2
>
>
> When submitting a form with an AJAX link (or other AJAX-based control), WicketTester doesn't include the id of the component that 'submitted' the form, meaning that in situations with nested forms, the wrong form's onSubmit() method may be called.
> We're working around this problem by overriding the clickLink() and executeAjaxEvent() methods as follows:
>     @Override
>     public void clickLink(String path, boolean isAjax) {
>         Component linkComponent = getComponentFromLastRenderedPage(path);
>         if (linkComponent instanceof AjaxSubmitLink) {
>             AjaxSubmitLink link = (AjaxSubmitLink) linkComponent;
>             Map<String, Object> requestParams = getParametersForNextRequest();
>             requestParams.put(link.getInputName(), "x");
>         }
>         super.clickLink(path, isAjax);
>     }
>     @Override
>     public void executeAjaxEvent(Component component, String event) {
>         // Code borrowed from BaseWicketTester.
>         // Run through all the behavior and select the LAST ADDED behavior which
>         // matches the event parameter.
>         AjaxEventBehavior ajaxEventBehavior = null;
>         List behaviors = component.getBehaviors();
>         for (Iterator iter = behaviors.iterator(); iter.hasNext();) {
>             IBehavior behavior = (IBehavior) iter.next();
>             // AjaxEventBehavior is the one to look for
>             if (behavior instanceof AjaxEventBehavior) {
>                 AjaxEventBehavior tmp = (AjaxEventBehavior) behavior;
>                 if (event.equals(tmp.getEvent())) {
>                     ajaxEventBehavior = tmp;
>                 }
>             }
>         }
>         // Workaround: If the behaviour is an AjaxFormSubmitBehavior then add the
>         // component's input name.
>         if (ajaxEventBehavior instanceof AjaxFormSubmitBehavior
>                 && component instanceof FormComponent) {
>             String inputName = ((FormComponent) component).getInputName();
>             Map<String, Object> requestParams = getParametersForNextRequest();
>             requestParams.put(inputName, "x");
>         }
>         super.executeAjaxEvent(component, event);
>     }

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