Author: maksimkaszynski
Date: 2007-10-15 12:47:31 -0400 (Mon, 15 Oct 2007)
New Revision: 3377
Removed:
trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java
Log:
http://jira.jboss.com/jira/browse/RF-1096
added logic to renderer
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
16:20:48 UTC (rev 3376)
+++
trunk/framework/impl/src/main/java/org/richfaces/component/util/HtmlUtil.java 2007-10-15
16:47:31 UTC (rev 3377)
@@ -25,12 +25,12 @@
import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
import org.ajax4jsf.util.HtmlDimensions;
/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 09.02.2007
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 09.02.2007
*
*/
public class HtmlUtil {
@@ -45,32 +45,39 @@
return sizeDeclaration;
}
-
+
public static String addToSize(String declaration, String delta) {
Double doubleDelta = HtmlDimensions.decode(delta);
Double decoded = HtmlDimensions.decode(declaration);
-
- return HtmlDimensions.formatPx(
- new Double(decoded.doubleValue() + doubleDelta.doubleValue()));
+
+ 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();
+ public static final Pattern idSelectorPattern = Pattern
+ .compile("#((:|_|[a-z,A-Z])[a-z,A-Z,0-9,_,-,:]+)");
- 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();
- }
+ public static String expandIdSelector(String selector,
+ UIComponent component, FacesContext context) {
+ 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)
+
+ UIComponent target = component.findComponent(matcher.group(1));
+
+ if (target != null) {
+ matcher.appendReplacement(sb, "#"
+ + target.getClientId(context));
+ }
+ }
+ }
+ matcher.appendTail(sb);
+ String result = sb.toString();
+ if (result.length() == 0)
+ result = selector;
+ return sb.toString();
+ }
}
Deleted:
trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java
===================================================================
---
trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java 2007-10-15
16:20:48 UTC (rev 3376)
+++
trunk/framework/impl/src/test/java/org/richfaces/component/util/HtmlUnitTest.java 2007-10-15
16:47:31 UTC (rev 3377)
@@ -1,30 +0,0 @@
-package org.richfaces.component.util;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-
-import junit.framework.TestCase;
-
-//Initial draft
-
-public class HtmlUnitTest extends TestCase {
-
- public void testExpandIdSelector()throws Exception {
-
- UIComponent comp = new UIInput();
- String str = HtmlUtil.expandIdSelector(".class_form+#:Test .class2
#_1aaaa:",comp);
- //System.out.println(str);
- assertEquals(str,".class_form+#new-value .class2 #new-value");
- try {
- str = HtmlUtil.expandIdSelector(null, comp);
- } catch (NullPointerException e) {
- assertTrue(true);
- }
-
-
-
-
-
- }
-
-}