Author: maksimkaszynski
Date: 2008-03-03 02:47:02 -0500 (Mon, 03 Mar 2008)
New Revision: 6481
Modified:
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
Log:
added jdk1.4 compatibility
Modified:
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
---
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2008-03-03
03:58:09 UTC (rev 6480)
+++
branches/3.1.x/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2008-03-03
07:47:02 UTC (rev 6481)
@@ -5,6 +5,8 @@
package org.richfaces.component;
import java.util.Iterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
@@ -35,6 +37,8 @@
private static final Log log = LogFactory.getLog(UIComponentControl.class);
+ private static final Pattern BACKSLASHES = Pattern.compile("\\\\",
Pattern.LITERAL);
+ private static final String QUOTED_REPLACEMENT = "\\\\";
/**
* @return JavaScript eventString. Rebuild on every call, since
@@ -45,12 +49,11 @@
String targetId = HtmlUtil.idsToIdSelector(getFor());
targetId = HtmlUtil.expandIdSelector(targetId, this,
FacesContext.getCurrentInstance());
-
JSFunction invocation = new
JSFunction("Richfaces.componentControl.performOperation");
invocation.addParameter(new JSReference("event"));
//FIXME: Maksim
//Replacement looks ugly - move that functionality to HtmlUtil
- invocation.addParameter(targetId.replace("\\\\", "\\"));
+ invocation.addParameter(replaceBackSlashes(targetId));
invocation.addParameter(getOperation());
invocation.addParameter(new JSReference("{" + getEncodedParametersMap() +
"}"));
invocation.addParameter(Boolean.valueOf(isDisableDefault()));
@@ -60,6 +63,10 @@
}
+ protected String replaceBackSlashes(String src) {
+ return BACKSLASHES.matcher(src).replaceAll(QUOTED_REPLACEMENT);
+ }
+
public String getEncodedParametersMap() {
StringBuffer result = new StringBuffer();
Modified:
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
===================================================================
---
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java 2008-03-03
03:58:09 UTC (rev 6480)
+++
branches/3.1.x/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java 2008-03-03
07:47:02 UTC (rev 6481)
@@ -174,4 +174,9 @@
}
}
+
+ public void testReplaceBackSlashes() {
+ String s = "\\\\A\\B\\\\C";
+ assertEquals(s.replace("\\\\", "\\"),
componentControl.replaceBackSlashes(s));
+ }
}
Show replies by date