myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svieu...@apache.org
Subject svn commit: r168045 - in /myfaces/trunk: doc/release-notes.txt src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java
Date Wed, 04 May 2005 02:17:07 GMT
Author: svieujot
Date: Tue May  3 19:17:06 2005
New Revision: 168045

URL: http://svn.apache.org/viewcvs?rev=168045&view=rev
Log:
Avoid evaluating expression on each phase (quite an efficiency improvement when your aliased
object is a DAO method).

Modified:
    myfaces/trunk/doc/release-notes.txt
    myfaces/trunk/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java

Modified: myfaces/trunk/doc/release-notes.txt
URL: http://svn.apache.org/viewcvs/myfaces/trunk/doc/release-notes.txt?rev=168045&r1=168044&r2=168045&view=diff
==============================================================================
--- myfaces/trunk/doc/release-notes.txt (original)
+++ myfaces/trunk/doc/release-notes.txt Tue May  3 19:17:06 2005
@@ -4,6 +4,7 @@
 ----------------------------------------------------------------------
 Changes in Release 1.0.10
 * added renderFacetsIfSinglePage to x:dataScroller
+* aliasBean : avoid evaluating expressions on each phase
 * closed MYFACES-177
 * closed MYFACES-199
 * closed MYFACES-209

Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java?rev=168045&r1=168044&r2=168045&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/aliasbean/AliasBean.java Tue May
 3 19:17:06 2005
@@ -90,6 +90,7 @@
     private String _aliasBeanExpression = null;
 
     private transient FacesContext _context = null;
+	private transient Object evaluatedExpression = null;
 
     public AliasBean() {
         setRendererType(DEFAULT_RENDERER_TYPE);
@@ -248,12 +249,12 @@
         _context = context;
         makeAlias();
     }
-
-    private void makeAlias() {
-        // First, compute the value or reference
-        Object value;
-        
-        ValueBinding valueVB = null;
+	
+	private void computeEvaluatedExpression(){
+		if( evaluatedExpression != null )
+			return;
+		
+		ValueBinding valueVB = null;
         if (_valueExpression == null) {
             valueVB = getValueBinding("value");
             _valueExpression = valueVB.getExpressionString();
@@ -262,13 +263,18 @@
         if( valueVB == null ){
             if( _valueExpression.startsWith("#{") ){
                 valueVB = _context.getApplication().createValueBinding(_valueExpression);
-                value = valueVB.getValue(_context);
+				evaluatedExpression = valueVB.getValue(_context);
             }else{
-                value = _valueExpression;
+				evaluatedExpression = _valueExpression;
             }
         }else{
-            value = valueVB.getValue(_context);
+			evaluatedExpression = valueVB.getValue(_context);
         }
+	}
+
+    private void makeAlias() {
+        // First, compute the value or reference
+		computeEvaluatedExpression();
 
         // Then set the alias to this value
         ValueBinding aliasVB;
@@ -279,7 +285,7 @@
             aliasVB = _context.getApplication().createValueBinding(_aliasBeanExpression);
         }
 
-        aliasVB.setValue(_context, value);
+        aliasVB.setValue(_context, evaluatedExpression);
 
         log.debug("makeAlias: " + _valueExpression + " = " + _aliasBeanExpression);
     }



Mime
View raw message