Author: pyaschenko
Date: 2007-10-15 07:53:08 -0400 (Mon, 15 Oct 2007)
New Revision: 3365
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
Log:
RF-1096
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-15
11:18:11 UTC (rev 3364)
+++
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15
11:53:08 UTC (rev 3365)
@@ -21,6 +21,11 @@
package org.richfaces.component.util;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+
import org.ajax4jsf.util.HtmlDimensions;
/**
@@ -48,4 +53,24 @@
return HtmlDimensions.formatPx(
new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
}
+
+ public static final Pattern idSelectorPattern =
Pattern.compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
+
+ public static String expandIdSelector(String selector, UIComponent component) {
+ Matcher matcher = idSelectorPattern.matcher(selector);
+ StringBuffer sb = new StringBuffer();
+
+ while (matcher.find())
+ {
+ if (matcher.group(1).indexOf("::")==-1)
+ {
+ // make new id selector here using matcher.group(1)
+ matcher.appendReplacement(sb, "#new value");
+ }
+ }
+ matcher.appendTail(sb);
+ String result = sb.toString();
+ if (result.length()==0) result = selector;
+ return sb.toString();
+ }
}