[ 
https://issues.apache.org/jira/browse/WICKET-1332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567378#action_12567378
 ] 

Carlos Pita commented on WICKET-1332:
-------------------------------------

Igor, here is a version not dependant on prototype, it worked for me but i 
can't ensure it's bullet proof.

    @Override
    public void renderHead(IHeaderResponse response) {
        super.renderHead(response);
        AppendingStringBuffer asb = new AppendingStringBuffer();
        asb.append("function attachChoiceHandlers(markupId, callbackScript) 
{\n");
        asb.append("  function attachToDescendants(node) {\n");
        asb.append("    var childNodes = node.childNodes;\n");
        asb.append("    if (!childNodes) return;\n");
        asb.append("    for (var i = 0 ; i < childNodes.length ; i ++) {\n");   
     
        asb.append("      var childNode = childNodes[i];\n");        
        asb.append("      if (childNode.tagName) {\n");
        asb.append("        if (childNode.tagName.toLowerCase() == 'input') 
{\n");
        asb.append("          Wicket.Event.add(childNode, 'click', 
callbackScript);\n");
        asb.append("        }\n");
        asb.append("        attachToDescendants(childNode);\n");
        asb.append("      }\n");
        asb.append("    }\n");
        asb.append("  }\n");
        asb.append("  attachToDescendants(wicketGet(markupId));\n");
        asb.append("}\n");
        response.renderJavascript(asb, "attachChoice");
        response.renderOnLoadJavascript("attachChoiceHandlers('" + 
getComponent().getMarkupId() +
                "', function() {" + getEventHandler() + "});");
    }


> AjaxFormChoiceComponentUpdatingBehavior just updates the group "grandchildren"
> ------------------------------------------------------------------------------
>
>                 Key: WICKET-1332
>                 URL: https://issues.apache.org/jira/browse/WICKET-1332
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3.1
>            Reporter: Carlos Pita
>            Assignee: Matej Knopp
>
> Up to 1.3.0, there was a bug in that AjaxFormChoiceComponentUpdatingBehavior 
> updated just the group's direct children. Now it generates the header script 
> quoted below, that iterates over the direct children and then over the 
> children of these, triggering the event for the input grandchildren only. So 
> the situation is even worse. I think that attachChoiceHandlers should descend 
> recursively and search for input elements along all the group descendants, 
> not just one arbitrarily chosen level.
> function attachChoiceHandlers(markupid, callbackscript) {
>  var choiceElementGroup = document.getElementById(markupid);
>  for( var x = 0; x < choiceElementGroup.childNodes.length; x++ ) {
>    var choiceElementList = choiceElementGroup.childNodes[x];   for( var y = 
> 0; y < choiceElementList.childNodes.length; y++ ) {
>      if (choiceElementList.childNodes[y] && 
> choiceElementList.childNodes[y].tagName) {
>        var tag = choiceElementList.childNodes[y].tagName.toLowerCase();
>        if (tag == 'input') {
>          Wicket.Event.add(choiceElementList.childNodes[y],'click', 
> callbackscript);       }
>      }
>    }
>  }
> }

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