You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Carlos Pita (JIRA)" <ji...@apache.org> on 2007/04/14 15:50:15 UTC

[jira] Created: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

AjaxFormComponentUpdatingBehavior won't work for RadioChoices
-------------------------------------------------------------

                 Key: WICKET-470
                 URL: https://issues.apache.org/jira/browse/WICKET-470
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3
            Reporter: Carlos Pita


Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.

<span wicket:id="sex" id="sex5" onblur="var
wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
wicketSerialize(document.getElementById('sex5')), function() { },
function() { });">

<input name="sex" type="radio" value="0" id="sex_0"/><label
for="sex_0">M</label><br />
<input name="sex" type="radio" value="1" id="sex_1"/><label
for="sex_1">F</label><br />

</span>

wicketSerialize = Wicket.Form.serializeElement;

Wicket.Form.serializeElement = function(e) {
var tag = e.tagName.toLowerCase();
if (tag == "select") {
return Wicket.Form.serializeSelect(e);
} else if (tag == "input" || tag == "textarea") {
return Wicket.Form.serializeInput(e);
} else {
return "";

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


[jira] Commented: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495395 ] 

Johan Compagner commented on WICKET-470:
----------------------------------------

yes we already have a (partial maybe) working thing now AjaxFormChoiceComponentUpdatingBehavior
that works for the most basic once.

We should integrate this into AjaxFormComponentUpdatingBehavior so that it behaves as one.

> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Johan Compagner
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Updated: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner updated WICKET-470:
-----------------------------------

    Attachment: AjaxFormChoiceComponentUpdatingBehavior.java

I already wrote such a thing, don't know if it does take all kinds of radio choices or checkbox choices
because  of this:

                asb.append("function attachChoiceHandlers(markupid, callbackscript) {\n");
		asb.append(" var choiceElement = document.getElementById(markupid);\n");
		asb.append(" for( var x = 0; x < choiceElement.childNodes.length; x++ ) {\n");
		asb.append("   if (choiceElement.childNodes[x] && choiceElement.childNodes[x].tagName) {\n");
		asb.append("     var tag = choiceElement.childNodes[x].tagName.toLowerCase();\n");
		asb.append("     if (tag == 'input') {\n");
		asb.append("       Wicket.Event.add(choiceElement.childNodes[x],'click', callbackscript);");
		asb.append("     }\n");		
		asb.append("   }\n");
		asb.append(" }\n");
		asb.append("}\n");

I am not going deeper then just the child nodes of a radiochoice or group
But for the default CheckboxMultiplyChoice or RadioChoice it should work fine.
I am still thinking about integrating this into AjaxFormComponentUpdatingBehavior so that it checks for the type
and then does different things depending on this.



> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Commented: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489690 ] 

Johan Compagner commented on WICKET-470:
----------------------------------------

what do you mean with that invasive javascript?
(that asb.append() stufff?)
that has nothing to do with serialization!
That is handled in the event handler that does this:

return getCallbackScript(new AppendingStringBuffer("wicketAjaxPost('").append(
				getCallbackUrl()).append(
				"', wicketSerializeForm(document.getElementById('" + getComponent().getMarkupId()
						+ "',false))"), null, null);

You see i use the boolean false ^^ so that it doesn't try to find a parent form..

that script i have here above does nothing more then on every input (that should be a radio or check)
add an onclick event handler. That again calls the above event handler code.

So that Wicket.Form.serializeElementOrChildren we already have, That is that boolean you added for me!


> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Matej Knopp
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Commented: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489686 ] 

Matej Knopp commented on WICKET-470:
------------------------------------

I think this approach is wrong. Sorry :)

What we should do have method Wicket.Form.serializeElementOrChildren, which would act like this:
if the give element is a form element, return Wicket.Form.serializeElement(element);
otherwise traverse children recursively and serialize them.

This should work for both RadioChoice and CheckboxMultiplyChoice without the invasive javascript you suggested. Unless I'm wrong of course :)  

> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Matej Knopp
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Assigned: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Matej Knopp (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matej Knopp reassigned WICKET-470:
----------------------------------

    Assignee: Johan Compagner  (was: Matej Knopp)

I believe you are working on this now?

> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Johan Compagner
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Assigned: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Johan Compagner (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Johan Compagner reassigned WICKET-470:
--------------------------------------

    Assignee: Matej Knopp

Matej can you also do a quick look on this class?
and maybe add the js functioni now build up in the javacode into wicket-ajax.js
improving it so that it walks recursivly through the childs of the radio or check container.

If this all pretty much work we could integrate it into AjaxFormComponentUpdatingBehavior

> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Matej Knopp
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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


[jira] Commented: (WICKET-470) AjaxFormComponentUpdatingBehavior won't work for RadioChoices

Posted by "Carlos Pita (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12495411 ] 

Carlos Pita commented on WICKET-470:
------------------------------------

Just for the record, I'm successfuly using AjaxFormChoiceComponentUpdatingBehavior since a month ago. For me it's more than enough.

> AjaxFormComponentUpdatingBehavior won't work for RadioChoices
> -------------------------------------------------------------
>
>                 Key: WICKET-470
>                 URL: https://issues.apache.org/jira/browse/WICKET-470
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.3
>            Reporter: Carlos Pita
>         Assigned To: Johan Compagner
>         Attachments: AjaxFormChoiceComponentUpdatingBehavior.java
>
>
> Below is the generated html and js for a simple RadioChoice("sex", Arrays.asList("M", "F")) with an attached behavior. Notice how wicketSerialize will take the else branch for span elements, so it will always return "". Maybe the behavior should be patched, maybe the js, maybe there is a need for another behavior, I don't know.
> <span wicket:id="sex" id="sex5" onblur="var
> wcall=wicketAjaxPost('test?wicket:interface=:2:testForm:sex::IBehaviorListener:0',
> wicketSerialize(document.getElementById('sex5')), function() { },
> function() { });">
> <input name="sex" type="radio" value="0" id="sex_0"/><label
> for="sex_0">M</label><br />
> <input name="sex" type="radio" value="1" id="sex_1"/><label
> for="sex_1">F</label><br />
> </span>
> wicketSerialize = Wicket.Form.serializeElement;
> Wicket.Form.serializeElement = function(e) {
> var tag = e.tagName.toLowerCase();
> if (tag == "select") {
> return Wicket.Form.serializeSelect(e);
> } else if (tag == "input" || tag == "textarea") {
> return Wicket.Form.serializeInput(e);
> } else {
> return "";

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