Updated Branches: refs/heads/master e73fdcc58 -> 9ff32f61f
WICKET-4876 aligned CheckBoxMultipleChoice with RadioChoice with getAdditionalAttributes() and renderOptionHtml() Minor performance improvements: - Use characters where possible, instead of Strings. - Use Strings.replaceAll instead of String.replace() which uses Regex. Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/9ff32f61 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/9ff32f61 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/9ff32f61 Branch: refs/heads/master Commit: 9ff32f61fd4db03d5671d8459593d6feaa8b7a1b Parents: e73fdcc Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Fri Nov 23 10:04:27 2012 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Fri Nov 23 10:04:27 2012 +0200 ---------------------------------------------------------------------- .../markup/html/form/CheckBoxMultipleChoice.java | 20 +++++++------- .../wicket/markup/html/form/RadioChoice.java | 20 +++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/9ff32f61/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 0cd678b..c8ff1f6 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 @@ -396,7 +396,7 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T> // Add checkbox element buffer.append("<input name=\""); buffer.append(getInputName()); - buffer.append("\""); + buffer.append('"'); buffer.append(" type=\"checkbox\""); if (isSelected(choice, index, selected)) { @@ -410,7 +410,7 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T> buffer.append(id); buffer.append("\" id=\""); buffer.append(idAttr); - buffer.append("\""); + buffer.append('"'); // Allows user to add attributes to the <input..> tag { @@ -419,25 +419,25 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T> { for (Map.Entry<String, Object> attr : attrs.entrySet()) { - buffer.append(" ") + buffer.append(' ') .append(attr.getKey()) .append("=\"") .append(attr.getValue()) - .append("\""); + .append('"'); } } } if (getApplication().getDebugSettings().isOutputComponentPath()) { - String path = getPageRelativePath(); - path = path.replace("_", "__"); - path = path.replace(":", "_"); + CharSequence path = getPageRelativePath(); + path = Strings.replaceAll(path, "_", "__"); + path = Strings.replaceAll(path, ":", "_"); buffer.append(" wicketpath=\"") .append(path) .append("_input_") .append(index) - .append("\""); + .append('"'); } buffer.append("/>"); @@ -477,7 +477,7 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T> * Creates markup id for the input tag used to generate the checkbox for the element with the * specified {@code id}. * <p> - * NOTE It is useful to override this method if the contract for the genreated ids should be + * NOTE It is useful to override this method if the contract for the generated ids should be * fixed, for example in cases when the id generation pattern in this method is used to predict * ids by some external javascript. If the contract is fixed in the user's code then upgrading * wicket versions will guarantee not to break it should the default contract be changed at a @@ -489,6 +489,6 @@ public class CheckBoxMultipleChoice<T> extends ListMultipleChoice<T> */ protected String getCheckBoxMarkupId(String id) { - return getMarkupId() + "-" + getInputName() + "_" + id; + return getMarkupId() + '-' + getInputName() + '_' + id; } } http://git-wip-us.apache.org/repos/asf/wicket/blob/9ff32f61/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 c5f60af..e684186 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 @@ -440,7 +440,7 @@ public class RadioChoice<T> extends AbstractSingleSelectChoice<T> implements IOn // Add radio tag buffer.append("<input name=\"") .append(getInputName()) - .append("\"") + .append('"') .append(" type=\"radio\"") .append((isSelected(choice, index, selected) ? " checked=\"checked\"" : "")) .append((enabled ? "" : " disabled=\"disabled\"")) @@ -448,7 +448,7 @@ public class RadioChoice<T> extends AbstractSingleSelectChoice<T> implements IOn .append(id) .append("\" id=\"") .append(idAttr) - .append("\""); + .append('"'); // Should a roundtrip be made (have onSelectionChanged called) // when the option is clicked? @@ -469,8 +469,8 @@ public class RadioChoice<T> extends AbstractSingleSelectChoice<T> implements IOn // invalid JavaScript buffer.append(" onclick=\"window.location.href='") .append(url) - .append((url.toString().indexOf('?') > -1 ? "&" : "?") + getInputName()) - .append("=") + .append((url.toString().indexOf('?') > -1 ? '&' : '?') + getInputName()) + .append('=') .append(id) .append("';\""); } @@ -483,25 +483,25 @@ public class RadioChoice<T> extends AbstractSingleSelectChoice<T> implements IOn { for (Map.Entry<String, Object> attr : attrs.entrySet()) { - buffer.append(" ") + buffer.append(' ') .append(attr.getKey()) .append("=\"") .append(attr.getValue()) - .append("\""); + .append('"'); } } } if (getApplication().getDebugSettings().isOutputComponentPath()) { - String path = getPageRelativePath(); - path = path.replace("_", "__"); - path = path.replace(":", "_"); + CharSequence path = getPageRelativePath(); + path = Strings.replaceAll(path, "_", "__"); + path = Strings.replaceAll(path, ":", "_"); buffer.append(" wicketpath=\"") .append(path) .append("_input_") .append(index) - .append("\""); + .append('"'); } buffer.append("/>");
