Author: nbelaevski
Date: 2008-06-03 18:45:33 -0400 (Tue, 03 Jun 2008)
New Revision: 8897
Modified:
trunk/ui/functions/src/main/config/component/functions.xml
trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
Log:
http://jira.jboss.com/jira/browse/RF-3627
Modified: trunk/ui/functions/src/main/config/component/functions.xml
===================================================================
--- trunk/ui/functions/src/main/config/component/functions.xml 2008-06-03 22:44:44 UTC
(rev 8896)
+++ trunk/ui/functions/src/main/config/component/functions.xml 2008-06-03 22:45:33 UTC
(rev 8897)
@@ -18,4 +18,9 @@
<name>element</name>
<method>org.richfaces.function.RichFunction.element(String)</method>
</function>
+
+ <function>
+ <name>findComponent</name>
+
<method>org.richfaces.function.RichFunction.findComponent(String)</method>
+ </function>
</components>
Modified: trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java
===================================================================
--- trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java 2008-06-03
22:44:44 UTC (rev 8896)
+++ trunk/ui/functions/src/main/java/org/richfaces/function/RichFunction.java 2008-06-03
22:45:33 UTC (rev 8897)
@@ -35,41 +35,49 @@
public class RichFunction {
- public static String clientId(String id) {
- if (id != null) {
- FacesContext context = FacesContext.getCurrentInstance();
- if (context != null) {
- UIViewRoot root = context.getViewRoot();
+ private static UIComponent findComponent(FacesContext context, String id) {
+ if (id != null) {
+ if (context != null) {
+ UIViewRoot root = context.getViewRoot();
- if (root != null) {
- UIComponent component = RendererUtils.getInstance().findComponentFor(root, id);
+ if (root != null) {
+ UIComponent component = RendererUtils.getInstance().findComponentFor(root, id);
- if (component != null) {
- return component.getClientId(context);
- }
- }
- }
+ if (component != null) {
+ return component;
+ }
+ }
+ }
+ }
+
+ return null;
}
- return null;
+ public static String clientId(String id) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ UIComponent component = findComponent(context, id);
+ return component != null ? component.getClientId(context) : null;
}
public static String component(String id) {
- String element = element(id);
- if (element != null) {
- return element + ".component";
- }
-
- return null;
+ String element = element(id);
+ if (element != null) {
+ return element + ".component";
+ }
+
+ return null;
}
-
+
public static String element(String id) {
- String clientId = clientId(id);
- if (clientId != null) {
- return "document.getElementById('" + clientId + "')";
- }
-
- return null;
+ String clientId = clientId(id);
+ if (clientId != null) {
+ return "document.getElementById('" + clientId + "')";
+ }
+
+ return null;
}
+ public static UIComponent findComponent(String id) {
+ return findComponent(FacesContext.getCurrentInstance(), id);
+ }
}