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

AjaxFormChoiceComponentUpdatingBehavior assumes Radio/Choice items are a direct child of the group in the client-side DOM


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-final
    • Fix Version/s: 1.3.1
    • Component/s: wicket
    • Labels:


      In the reference behavior, the attachFormChoiceHandlers javascript function being rendered in onRenderHead incorrectly assumes that the individual choices we're attaching events to (the Radio or CheckBox components) are direct children of the group.

      64) asb.append("function attachChoiceHandlers(markupid, callbackscript) {\n");
      65) asb.append(" var choiceElement = document.getElementById(markupid);\n");
      66) asb.append(" for( var x = 0; x < choiceElement.childNodes.length; x++ ) {\n");
      67) asb.append(" if (choiceElement.childNodes[x] && choiceElement.childNodes[x].tagName) {\n");
      68) asb.append(" var tag = choiceElement.childNodes[x].tagName.toLowerCase();\n");
      69) asb.append(" if (tag == 'input')

      {\n"); 70) asb.append(" Wicket.Event.add(choiceElement.childNodes[x],'click', callbackscript);"); 71) asb.append(" }

      72) asb.append(" }\n");
      73) asb.append(" }\n");
      74) asb.append("}\n");

      The problem is the loop on line 66 - it only loops through direct child nodes, when in reality there could be other elements (like spans) in between the RadioGroup and the Radio in the dom, especially if for some reason the Radio was included as a part of another Component, which was actually added to the RadioGroup.

      The fix should be simple, but I don't know the appropriate Wicket-approved function of recursing through children in the client-side.

      As a side note, is there a reason this recursion is done on the client-side rather than on the server-side?


          Issue Links



              • Assignee:
                ivaynberg Igor Vaynberg
                mclark00 Matt Clark
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created: