[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Sun Mar 18 13:53:52 EDT 2007
User: gavin
Date: 07/03/18 13:53:52
Modified: src/main/org/jboss/seam/core Expressions.java
Log:
fixed a bug that occurred when an Expression was used in a faces request, and then later used from an async request
Revision Changes Path
1.19 +52 -10 jboss-seam/src/main/org/jboss/seam/core/Expressions.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Expressions.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Expressions.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- Expressions.java 7 Mar 2007 23:53:57 -0000 1.18
+++ Expressions.java 18 Mar 2007 17:53:52 -0000 1.19
@@ -1,11 +1,14 @@
-//$Id: Expressions.java,v 1.18 2007/03/07 23:53:57 gavin Exp $
+//$Id: Expressions.java,v 1.19 2007/03/18 17:53:52 gavin Exp $
package org.jboss.seam.core;
import static org.jboss.seam.InterceptionType.NEVER;
import static org.jboss.seam.annotations.Install.BUILT_IN;
+import static org.jboss.seam.util.EL.EL_CONTEXT;
+import static org.jboss.seam.util.EL.EXPRESSION_FACTORY;
import java.io.Serializable;
+import javax.el.ValueExpression;
import javax.faces.context.FacesContext;
import org.hibernate.validator.ClassValidator;
@@ -18,7 +21,6 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.util.UnifiedELMethodBinding;
-import org.jboss.seam.util.UnifiedELValueBinding;
/**
* Factory for method and value bindings
@@ -41,6 +43,7 @@
private static final long serialVersionUID = -8655967672318993009L;
private transient javax.faces.el.ValueBinding cachedValueBinding;
+ private transient ValueExpression cachedValueExpression;
public String getExpressionString()
{
@@ -49,32 +52,71 @@
public Class getType()
{
+ if ( isFacesContext() )
+ {
return getFacesValueBinding().getType( FacesContext.getCurrentInstance() );
}
+ else
+ {
+ return getValueExpression().getType(EL_CONTEXT);
+ }
+ }
public Object getValue()
{
+ if ( isFacesContext() )
+ {
return getFacesValueBinding().getValue( FacesContext.getCurrentInstance() );
}
+ else
+ {
+ return getValueExpression().getValue(EL_CONTEXT);
+ }
+ }
public boolean isReadOnly()
{
+ if ( isFacesContext() )
+ {
return getFacesValueBinding().isReadOnly( FacesContext.getCurrentInstance() );
}
+ else
+ {
+ return getValueExpression().isReadOnly(EL_CONTEXT);
+ }
+ }
public void setValue(Object value)
{
+ if ( isFacesContext() )
+ {
getFacesValueBinding().setValue( FacesContext.getCurrentInstance(), value );
}
+ else
+ {
+ getValueExpression().setValue(EL_CONTEXT, value);
+ }
+ }
+
+ boolean isFacesContext()
+ {
+ return FacesContext.getCurrentInstance()!=null;
+ }
+
+ ValueExpression getValueExpression()
+ {
+ if (cachedValueExpression==null)
+ {
+ cachedValueExpression = EXPRESSION_FACTORY.createValueExpression(EL_CONTEXT, expression, Object.class);
+ }
+ return cachedValueExpression;
+ }
javax.faces.el.ValueBinding getFacesValueBinding()
{
if (cachedValueBinding==null)
{
- FacesContext context = FacesContext.getCurrentInstance();
- cachedValueBinding = context==null ?
- new UnifiedELValueBinding(expression) :
- context.getApplication().createValueBinding(expression);
+ cachedValueBinding = FacesContext.getCurrentInstance().getApplication().createValueBinding(expression);
}
return cachedValueBinding;
}
More information about the jboss-cvs-commits
mailing list