[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Tue Oct 3 13:16:44 EDT 2006
User: gavin
Date: 06/10/03 13:16:44
Modified: src/main/org/jboss/seam/core Alias.java Init.java
Interpolator.java Pages.java
Added: src/main/org/jboss/seam/core Expressions.java
Log:
abstract JSF valuebindings / expressionbindings
Revision Changes Path
1.3 +1 -4 jboss-seam/src/main/org/jboss/seam/core/Alias.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Alias.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Alias.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- Alias.java 14 Jul 2006 03:26:12 -0000 1.2
+++ Alias.java 3 Oct 2006 17:16:44 -0000 1.3
@@ -2,8 +2,6 @@
import static org.jboss.seam.InterceptionType.NEVER;
-import javax.faces.context.FacesContext;
-
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Intercept;
@@ -35,8 +33,7 @@
}
else
{
- FacesContext facesContext = FacesContext.getCurrentInstance();
- return facesContext.getApplication().createValueBinding(expression).getValue(facesContext);
+ return Expressions.instance().createValueBinding(expression).getValue();
}
}
1.24 +3 -6 jboss-seam/src/main/org/jboss/seam/core/Init.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Init.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Init.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- Init.java 3 Jul 2006 16:57:44 -0000 1.23
+++ Init.java 3 Oct 2006 17:16:44 -0000 1.24
@@ -1,4 +1,4 @@
-//$Id: Init.java,v 1.23 2006/07/03 16:57:44 gavin Exp $
+//$Id: Init.java,v 1.24 2006/10/03 17:16:44 gavin Exp $
package org.jboss.seam.core;
@@ -10,15 +10,13 @@
import java.util.List;
import java.util.Map;
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Expressions.MethodBinding;
/**
* A Seam component that holds Seam configuration settings
@@ -106,8 +104,7 @@
public void addFactory(String variable, String methodBindingExpression, ScopeType scope)
{
- MethodBinding methodBinding = FacesContext.getCurrentInstance().getApplication()
- .createMethodBinding(methodBindingExpression, null);
+ MethodBinding methodBinding = Expressions.instance().createMethodBinding(methodBindingExpression);
factoryMethodBindings.put( variable, new FactoryMethodBinding(methodBinding, scope) );
}
1.9 +1 -1 jboss-seam/src/main/org/jboss/seam/core/Interpolator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Interpolator.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Interpolator.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- Interpolator.java 3 Aug 2006 14:52:09 -0000 1.8
+++ Interpolator.java 3 Oct 2006 17:16:44 -0000 1.9
@@ -80,7 +80,7 @@
String expression = "#{" + tokens.nextToken() + "}";
try
{
- Object value = context.getApplication().createValueBinding(expression).getValue(context);
+ Object value = Expressions.instance().createValueBinding(expression).getValue();
if (value!=null) builder.append(value);
}
catch (Exception e)
1.23 +10 -15 jboss-seam/src/main/org/jboss/seam/core/Pages.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Pages.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Pages.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- Pages.java 30 Sep 2006 01:36:14 -0000 1.22
+++ Pages.java 3 Oct 2006 17:16:44 -0000 1.23
@@ -14,8 +14,6 @@
import java.util.TreeSet;
import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -25,12 +23,13 @@
import org.dom4j.io.SAXReader;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.actionparam.ActionParamMethodBinding;
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.core.Expressions.MethodBinding;
+import org.jboss.seam.core.Expressions.ValueBinding;
import org.jboss.seam.util.Parameters;
import org.jboss.seam.util.Resources;
@@ -125,9 +124,7 @@
{
if ( action.startsWith("#{") )
{
- MethodBinding methodBinding = FacesContext.getCurrentInstance()
- .getApplication()
- .createMethodBinding(action, null);
+ MethodBinding methodBinding = Expressions.instance().createMethodBinding(action);
entry.action = methodBinding;
}
else
@@ -139,8 +136,7 @@
List<Element> children = page.elements("param");
for (Element param: children)
{
- ValueBinding valueBinding = FacesContext.getCurrentInstance().getApplication()
- .createValueBinding( param.attributeValue("value") );
+ ValueBinding valueBinding = Expressions.instance().createValueBinding( param.attributeValue("value") );
entry.parameterValueBindings.put( param.attributeValue("name"), valueBinding );
}
}
@@ -201,7 +197,7 @@
{
fromAction = methodBinding.getExpressionString();
result = true;
- outcome = toString( methodBinding.invoke(facesContext, null) );
+ outcome = toString( methodBinding.invoke(null) );
}
}
@@ -255,9 +251,8 @@
String expression = "#{" + action + "}";
if ( !isActionAllowed(facesContext, expression) ) return result;
result = true;
- MethodBinding actionBinding = facesContext.getApplication()
- .createMethodBinding(expression, null);
- outcome = toString( actionBinding.invoke(facesContext, null) );
+ MethodBinding actionBinding = Expressions.instance().createMethodBinding(expression);
+ outcome = toString( actionBinding.invoke(null) );
fromAction = expression;
}
}
@@ -301,7 +296,7 @@
{
if ( !overridden.contains( me.getKey() ) )
{
- Object value = me.getValue().getValue( FacesContext.getCurrentInstance() );
+ Object value = me.getValue().getValue();
//TODO: handle multi-values!
if (value!=null)
{
@@ -317,11 +312,11 @@
Map<String, String[]> parameters = Parameters.getRequestParameters();
for (Map.Entry<String, ValueBinding> me: getParameterValueBindings(viewId))
{
- Class type = me.getValue().getType( FacesContext.getCurrentInstance() );
+ Class type = me.getValue().getType();
Object value = Parameters.convertMultiValueRequestParameter( parameters, me.getKey(), type );
if (value!=null)
{
- me.getValue().setValue( FacesContext.getCurrentInstance(), value );
+ me.getValue().setValue(value);
}
}
}
1.1 date: 2006/10/03 17:16:44; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/core/Expressions.java
Index: Expressions.java
===================================================================
//$Id: Expressions.java,v 1.1 2006/10/03 17:16:44 gavin Exp $
package org.jboss.seam.core;
import static org.jboss.seam.InterceptionType.NEVER;
import javax.faces.context.FacesContext;
import org.jboss.seam.Component;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
/**
* Factory for method and value bindings
*
* @author Gavin King
*/
@Scope(ScopeType.APPLICATION)
@Intercept(NEVER)
@Name("expressions")
@Startup
public class Expressions
{
public ValueBinding createValueBinding(String expression)
{
final javax.faces.el.ValueBinding vb = FacesContext.getCurrentInstance()
.getApplication().createValueBinding(expression);
return new ValueBinding() {
public String getExpressionString()
{
return vb.getExpressionString();
}
public Class getType()
{
return vb.getType( FacesContext.getCurrentInstance() );
}
public Object getValue()
{
return vb.getValue( FacesContext.getCurrentInstance() );
}
public boolean isReadOnly()
{
return vb.isReadOnly( FacesContext.getCurrentInstance() );
}
public void setValue(Object value)
{
vb.setValue( FacesContext.getCurrentInstance(), value );
}
};
}
public MethodBinding createMethodBinding(String expression)
{
final javax.faces.el.MethodBinding mb = FacesContext.getCurrentInstance()
.getApplication().createMethodBinding(expression, null);
return new MethodBinding() {
public String getExpressionString()
{
return mb.getExpressionString();
}
public Class getType()
{
return mb.getType( FacesContext.getCurrentInstance() );
}
public Object invoke(Object[] aobj)
{
return mb.invoke( FacesContext.getCurrentInstance(), aobj );
}
};
}
public static interface ValueBinding
{
public String getExpressionString();
public Class getType();
public Object getValue();
public boolean isReadOnly();
public void setValue(Object value);
}
public static interface MethodBinding {
public String getExpressionString();
public Class getType();
public Object invoke( Object aobj[] );
}
public static Expressions instance()
{
return (Expressions) Component.getInstance(Expressions.class);
}
}
More information about the jboss-cvs-commits
mailing list