You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Matt Clark (JIRA)" <ji...@apache.org> on 2008/01/03 22:40:34 UTC
[jira] Commented: (WICKET-1258)
AjaxFormChoiceComponentUpdatingBehavior assumes Radio/Choice items are a
direct child of the group in the client-side DOM
[ https://issues.apache.org/jira/browse/WICKET-1258?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12555683#action_12555683 ]
Matt Clark commented on WICKET-1258:
------------------------------------
FYI - I think we figured out why it's done on the server-side, and that might be because of the interactions with ListView and other MarkupContainers who might be modifying the structure of the component hierarchy after the behavior's renderHead method. So the remaining problem is just that the client-side javscript referenced above does not recurse through all descendants, it's just looking at immediate children.
> AjaxFormChoiceComponentUpdatingBehavior assumes Radio/Choice items are a direct child of the group in the client-side DOM
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-1258
> URL: https://issues.apache.org/jira/browse/WICKET-1258
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.3.0-final
> Reporter: Matt Clark
>
> 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(" }\n");
> 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?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.