Repository: wicket
Updated Branches:
  refs/heads/master b5874d796 -> 7f159404c


WICKET-5498 OutputComponentPath Html5 compliance

Fix CheckBoxMultipleChoice and RadioChoice to support setting custom 
'wicketpath' attribute name.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/847bff72
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/847bff72
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/847bff72

Branch: refs/heads/master
Commit: 847bff720eed8a779accb2d51ac34f446d5ab7db
Parents: b5874d7
Author: Martin Tzvetanov Grigorov <[email protected]>
Authored: Sun Apr 27 20:40:34 2014 +0200
Committer: Martin Tzvetanov Grigorov <[email protected]>
Committed: Sun Apr 27 20:40:34 2014 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/Component.java      | 12 +++++-------
 .../wicket/markup/html/form/CheckBoxMultipleChoice.java | 12 ++++++++++--
 .../org/apache/wicket/markup/html/form/RadioChoice.java | 12 ++++++++++--
 3 files changed, 25 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/847bff72/wicket-core/src/main/java/org/apache/wicket/Component.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Component.java 
b/wicket-core/src/main/java/org/apache/wicket/Component.java
index 3ac6f59..0e91438 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Component.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Component.java
@@ -3928,19 +3928,17 @@ public abstract class Component
 
                DebugSettings debugSettings = 
getApplication().getDebugSettings();
                String componentPathAttributeName = 
debugSettings.getComponentPathAttributeName();
-               if (Strings.isEmpty(componentPathAttributeName) == false)
+               if (Strings.isEmpty(componentPathAttributeName) && 
debugSettings.isOutputComponentPath())
                {
-                       String path = getPageRelativePath();
-                       path = path.replace("_", "__");
-                       path = path.replace(':', '_');
-                       tag.put(componentPathAttributeName, path);
+                       // fallback to the old 'wicketpath'
+                       componentPathAttributeName = "wicketpath";
                }
-               else if (debugSettings.isOutputComponentPath())
+               if (Strings.isEmpty(componentPathAttributeName) == false)
                {
                        String path = getPageRelativePath();
                        path = path.replace("_", "__");
                        path = path.replace(':', '_');
-                       tag.put("wicketpath", path);
+                       tag.put(componentPathAttributeName, path);
                }
 
                // The markup sourcing strategy may also want to work on the tag

http://git-wip-us.apache.org/repos/asf/wicket/blob/847bff72/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
index c8ff1f6..bca4908 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckBoxMultipleChoice.java
@@ -24,6 +24,7 @@ import org.apache.wicket.Page;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.settings.DebugSettings;
 import org.apache.wicket.util.convert.IConverter;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
@@ -428,12 +429,19 @@ public class CheckBoxMultipleChoice<T> extends 
ListMultipleChoice<T>
                                }
                        }
 
-                       if 
(getApplication().getDebugSettings().isOutputComponentPath())
+                       DebugSettings debugSettings = 
getApplication().getDebugSettings();
+                       String componentPathAttributeName = 
debugSettings.getComponentPathAttributeName();
+                       if (Strings.isEmpty(componentPathAttributeName) && 
debugSettings.isOutputComponentPath())
+                       {
+                               // fallback to the old 'wicketpath'
+                               componentPathAttributeName = "wicketpath";
+                       }
+                       if (Strings.isEmpty(componentPathAttributeName) == 
false)
                        {
                                CharSequence path = getPageRelativePath();
                                path = Strings.replaceAll(path, "_", "__");
                                path = Strings.replaceAll(path, ":", "_");
-                               buffer.append(" wicketpath=\"")
+                               buffer.append(' 
').append(componentPathAttributeName).append("=\"")
                                        .append(path)
                                        .append("_input_")
                                        .append(index)

http://git-wip-us.apache.org/repos/asf/wicket/blob/847bff72/wicket-core/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
index 3078729..20a0cfb 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/RadioChoice.java
@@ -23,6 +23,7 @@ import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.MarkupStream;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.request.mapper.parameter.PageParameters;
+import org.apache.wicket.settings.DebugSettings;
 import org.apache.wicket.util.convert.IConverter;
 import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.Strings;
@@ -493,12 +494,19 @@ public class RadioChoice<T> extends 
AbstractSingleSelectChoice<T> implements IOn
                                }
                        }
 
-                       if 
(getApplication().getDebugSettings().isOutputComponentPath())
+                       DebugSettings debugSettings = 
getApplication().getDebugSettings();
+                       String componentPathAttributeName = 
debugSettings.getComponentPathAttributeName();
+                       if (Strings.isEmpty(componentPathAttributeName) && 
debugSettings.isOutputComponentPath())
+                       {
+                               // fallback to the old 'wicketpath'
+                               componentPathAttributeName = "wicketpath";
+                       }
+                       if (Strings.isEmpty(componentPathAttributeName) == 
false)
                        {
                                CharSequence path = getPageRelativePath();
                                path = Strings.replaceAll(path, "_", "__");
                                path = Strings.replaceAll(path, ":", "_");
-                               buffer.append(" wicketpath=\"")
+                               buffer.append(' 
').append(componentPathAttributeName).append("=\"")
                                        .append(path)
                                        .append("_input_")
                                        .append(index)

Reply via email to