Author: pyaschenko
Date: 2007-10-23 06:15:19 -0400 (Tue, 23 Oct 2007)
New Revision: 3484
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
Log:
RF-1096
regex updated
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-23
10:03:56 UTC (rev 3483)
+++
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-23
10:15:19 UTC (rev 3484)
@@ -55,7 +55,7 @@
}
public static final Pattern idSelectorPattern = Pattern
- .compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
+ .compile("#((?:-[A-Za-z_-]|[A-Za-z_]|\\\\[^A-F0-9U]|\\\\[A-F0-9]{1,6}\\s?|\\\\U[0-9A-F]{2}(?:A[1-9A-F]|[B-F][0-9A-F]))(?:\\\\[A-F0-9]{1,6}\\s|[A-Za-z0-9\\\\_-]|\\\\:)*)");
public static String expandIdSelector(String selector,
UIComponent component, FacesContext context) {
@@ -63,21 +63,15 @@
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
- if (matcher.group(1).indexOf("::") == -1) {
- // make new id selector here using matcher.group(1)
+ // make new id selector here using matcher.group(1)
+ UIComponent target = component.findComponent(matcher.group(1));
- UIComponent target = component.findComponent(matcher.group(1));
-
- if (target != null) {
- matcher.appendReplacement(sb, "#"
- + target.getClientId(context).replaceAll(":",
"\\\\\\\\\\\\\\\\:"));
- }
+ if (target != null) {
+ matcher.appendReplacement(sb, "#"
+ + target.getClientId(context).replaceAll(":",
"\\\\\\\\\\\\\\\\:"));
}
}
matcher.appendTail(sb);
- String result = sb.toString();
- if (result.length() == 0)
- result = selector;
return sb.toString();
}
}
Modified:
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java
===================================================================
---
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-23
10:03:56 UTC (rev 3483)
+++
trunk/framework/test/src/test/java/org/richfaces/component/util/HtmlUtilTest.java 2007-10-23
10:15:19 UTC (rev 3484)
@@ -71,7 +71,7 @@
}
public void testExpandIdSelector() {
- String selector = ".class_form+#:Test .class2 #_1aaaa:";
+ String selector = ".class_form+#-Test .class2 #_aaaa";
UIComponent component = new UIComponentBase() {
public String getFamily() {
@@ -79,7 +79,7 @@
return null;
}
public UIComponent findComponent(String expr) {
- if (":Test".equals(expr)) {
+ if ("-Test".equals(expr)) {
return new UIComponentBase() {
public String getClientId(FacesContext context) {
return "component1";
@@ -89,7 +89,7 @@
return null;
}
};
- } else if ("_1aaaa:".equals(expr)) {
+ } else if ("_aaaa".equals(expr)) {
return new UIComponentBase() {
public String getClientId(FacesContext context) {
return "component2";