You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Per Newgro (JIRA)" <ji...@apache.org> on 2010/03/26 11:28:27 UTC

[jira] Created: (WICKET-2806) Javascript looking for related radio in group is not working if css class is already assigned to radio

Javascript looking for related radio in group is not working if css class is already assigned to radio
------------------------------------------------------------------------------------------------------

                 Key: WICKET-2806
                 URL: https://issues.apache.org/jira/browse/WICKET-2806
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.4.7
         Environment: Windows XP
            Reporter: Per Newgro
             Fix For: 1.4.8


We added a RadioGroup and two Radios. We often use multiple css classes for a component. Everything is working, until we add the class attribute to the radios. Then the click on radio is ignored.

The sad thing is that the tests for behavior with WicketTester are working. This problem is only related to the browsers. So we can't provide a testcase. 
Sorry you have to check it manually.

We traced it to the line 73 in AjaxFormChoiceComponentUpdatingBehavior

<code>
asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)===0)&&!(inputNode.id.indexOf(markupId+'-')===0)) continue;\n");
</code>

That means that the className has to start with the appropriate "wicket-markupId" value. But it will be added to the end of the class attribute value in
line 226 of Radio. So we get "abc wicket-markupId".

It is working with
asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)>=0 || inputNode.id.indexOf(markupId+'-')>=0)) continue;\n");

Alternatively the class for identifying in script has to be added at beginning
Radio line 226:
clazz = marker + " " + clazz;

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


[jira] Resolved: (WICKET-2806) Javascript looking for related radio in group is not working if css class is already assigned to radio

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

Igor Vaynberg resolved WICKET-2806.
-----------------------------------

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

> Javascript looking for related radio in group is not working if css class is already assigned to radio
> ------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2806
>                 URL: https://issues.apache.org/jira/browse/WICKET-2806
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.7
>         Environment: Windows XP
>            Reporter: Per Newgro
>            Assignee: Igor Vaynberg
>             Fix For: 1.4.8, 1.5-M1
>
>
> We added a RadioGroup and two Radios. We often use multiple css classes for a component. Everything is working, until we add the class attribute to the radios. Then the click on radio is ignored.
> The sad thing is that the tests for behavior with WicketTester are working. This problem is only related to the browsers. So we can't provide a testcase. 
> Sorry you have to check it manually.
> We traced it to the line 73 in AjaxFormChoiceComponentUpdatingBehavior
> <code>
> asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)===0)&&!(inputNode.id.indexOf(markupId+'-')===0)) continue;\n");
> </code>
> That means that the className has to start with the appropriate "wicket-markupId" value. But it will be added to the end of the class attribute value in
> line 226 of Radio. So we get "abc wicket-markupId".
> It is working with
> asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)>=0 || inputNode.id.indexOf(markupId+'-')>=0)) continue;\n");
> Alternatively the class for identifying in script has to be added at beginning
> Radio line 226:
> clazz = marker + " " + clazz;

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


[jira] Commented: (WICKET-2806) Javascript looking for related radio in group is not working if css class is already assigned to radio

Posted by "James McIntosh (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WICKET-2806?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850750#action_12850750 ] 

James McIntosh commented on WICKET-2806:
----------------------------------------

The check above does not cover all cases, what is missing is a function to check if a string has a CSS class in it.

For the above case the likelihood of a problem occurring is pretty close to zero because of the 'wicket-' prefix but the function might be a nice one to have available if CSS classes are used similarly elsewhere.

What the function does:
 - check if the value equals the class
 - check if the value starts with or ends with the class
 - check if the value contains the class with a space before and after

This will avoid the case where you have added a css attribute which contains the same value as 'wicket-'+markupId

Example / test code

<html>
<head><title></title></head>
<body>
<script type="text/javascript">

function hasCSSClass(value, clazz) {
  return clazz != null && value != null && (
     clazz === value
     || value.match('^'+clazz) != null
     || value.match(clazz+'$') != null
     || value.indexOf(' '+clazz+' ') > 0
  );
}

function assert(value, expectedValue) {
   return value === expectedValue ? "SUCCESS" : "FAILURE";
}

var clazz = "testclass";
var i = 1;
// check nulls
document.write(i++ + ": " + assert(hasCSSClass(null, clazz), false) + "<br />");
document.write(i++ + ": " + assert(hasCSSClass(clazz, null), false) + "<br />");
document.write(i++ + ": " + assert(hasCSSClass(null, null), false) + "<br />");
// equals
document.write(i++ + ": " + assert(hasCSSClass(clazz, clazz), true) + "<br />");
// starts with
document.write(i++ + ": " + assert(hasCSSClass(clazz + " blah", clazz), true) + "<br />");
// ends with
document.write(i++ + ": " + assert(hasCSSClass("blah " + clazz, clazz), true) + "<br />");
// contains
document.write(i++ + ": " + assert(hasCSSClass("blah " + clazz + " blah", clazz), true) + "<br />");
// contains as part of other value
document.write(i++ + ": " + assert(hasCSSClass("blah" + clazz + "blah", clazz), false) + "<br />");

</script>

</body>
</html>

> Javascript looking for related radio in group is not working if css class is already assigned to radio
> ------------------------------------------------------------------------------------------------------
>
>                 Key: WICKET-2806
>                 URL: https://issues.apache.org/jira/browse/WICKET-2806
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.7
>         Environment: Windows XP
>            Reporter: Per Newgro
>            Assignee: Igor Vaynberg
>             Fix For: 1.4.8, 1.5-M1
>
>
> We added a RadioGroup and two Radios. We often use multiple css classes for a component. Everything is working, until we add the class attribute to the radios. Then the click on radio is ignored.
> The sad thing is that the tests for behavior with WicketTester are working. This problem is only related to the browsers. So we can't provide a testcase. 
> Sorry you have to check it manually.
> We traced it to the line 73 in AjaxFormChoiceComponentUpdatingBehavior
> <code>
> asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)===0)&&!(inputNode.id.indexOf(markupId+'-')===0)) continue;\n");
> </code>
> That means that the className has to start with the appropriate "wicket-markupId" value. But it will be added to the end of the class attribute value in
> line 226 of Radio. So we get "abc wicket-markupId".
> It is working with
> asb.append(" if (!(inputNode.className.indexOf('wicket-'+markupId)>=0 || inputNode.id.indexOf(markupId+'-')>=0)) continue;\n");
> Alternatively the class for identifying in script has to be added at beginning
> Radio line 226:
> clazz = marker + " " + clazz;

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