You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2008/04/02 15:59:27 UTC
svn commit: r643910 - in
/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat:
FacesUtils.java FacesUtils12.java
Author: bommel
Date: Wed Apr 2 06:59:26 2008
New Revision: 643910
URL: http://svn.apache.org/viewvc?rev=643910&view=rev
Log:
(TOBAGO-637) Generate Components, JSP Tags from annotations
Added:
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java (with props)
Modified:
myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=643910&r1=643909&r2=643910&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils.java Wed Apr 2 06:59:26 2008
@@ -26,8 +26,6 @@
import javax.faces.component.NamingContainer;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
-import javax.el.ValueExpression;
-
public class FacesUtils {
@@ -100,11 +98,21 @@
return false;
}
+
+ public static Object getValueFromValueBindingOrValueExpression(FacesContext context, UIComponent component, String name) {
+ if (facesVersion == 11) {
+ return component.getValueBinding(name).getValue(context);
+ } else {
+ return FacesUtils12.getValueFromValueBindingOrValueExpression(context, component, name);
+ }
+ }
+
+
public static boolean hasValueBindingOrValueExpression(UIComponent component, String name) {
if (facesVersion == 11) {
return component.getValueBinding(name) != null;
} else {
- return component.getValueExpression(name) != null;
+ return FacesUtils12.hasValueBindingOrValueExpression(component, name);
}
}
@@ -113,7 +121,7 @@
if (facesVersion == 11) {
return component.getValueBinding(name).isReadOnly(context);
} else {
- return component.getValueExpression(name).isReadOnly(context.getELContext());
+ return FacesUtils12.isReadonlyValueBindingOrValueExpression(context, component, name);
}
}
@@ -122,7 +130,7 @@
if (facesVersion == 11) {
return component.getValueBinding(name).getExpressionString();
} else {
- return component.getValueExpression(name).getExpressionString();
+ return FacesUtils12.getExpressionString(component, name);
}
}
@@ -134,10 +142,7 @@
vb.setValue(context, value);
}
} else {
- ValueExpression ve = component.getValueExpression(bindingName);
- if (ve != null) {
- ve.setValue(context.getELContext(), value);
- }
+ FacesUtils12.setValueOfBindingOrExpression(context, value, component, bindingName);
}
}
@@ -149,10 +154,7 @@
toComponent.setValueBinding(toName, vb);
}
} else {
- ValueExpression ve = fromComponent.getValueExpression(fromName);
- if (ve != null) {
- toComponent.setValueExpression(toName, ve);
- }
+ FacesUtils12.copyValueBindingOrValueExpression(fromComponent, fromName, toComponent, toName);
}
}
}
Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java?rev=643910&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java Wed Apr 2 06:59:26 2008
@@ -0,0 +1,42 @@
+package org.apache.myfaces.tobago.compat;
+
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+import javax.el.ValueExpression;
+
+
+public class FacesUtils12 {
+
+ public static Object getValueFromValueBindingOrValueExpression(FacesContext context, UIComponent component, String name) {
+ return component.getValueExpression(name).getValue(context.getELContext());
+ }
+
+ public static boolean hasValueBindingOrValueExpression(UIComponent component, String name) {
+ return component.getValueExpression(name) != null;
+ }
+
+ public static boolean isReadonlyValueBindingOrValueExpression(FacesContext context,
+ UIComponent component, String name) {
+ return component.getValueExpression(name).isReadOnly(context.getELContext());
+ }
+
+ public static String getExpressionString(UIComponent component, String name) {
+ return component.getValueExpression(name).getExpressionString();
+ }
+
+ public static void setValueOfBindingOrExpression(FacesContext context, Object value,
+ UIComponent component, String bindingName) {
+ ValueExpression ve = component.getValueExpression(bindingName);
+ if (ve != null) {
+ ve.setValue(context.getELContext(), value);
+ }
+ }
+
+ public static void copyValueBindingOrValueExpression(UIComponent fromComponent, String fromName,
+ UIComponent toComponent, String toName) {
+ ValueExpression ve = fromComponent.getValueExpression(fromName);
+ if (ve != null) {
+ toComponent.setValueExpression(toName, ve);
+ }
+ }
+}
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/compat/FacesUtils12.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL