You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2006/05/14 16:14:57 UTC
svn commit: r406333 -
/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java
Author: lofwyr
Date: Sun May 14 07:14:56 2006
New Revision: 406333
URL: http://svn.apache.org/viewcvs?rev=406333&view=rev
Log:
Utility to remove a managed-bean from any scope
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java
URL: http://svn.apache.org/viewcvs/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java?rev=406333&r1=406332&r2=406333&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/VariableResolverUtil.java Sun May 14 07:14:56 2006
@@ -19,12 +19,30 @@
import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.el.VariableResolver;
+import javax.faces.el.ValueBinding;
public class VariableResolverUtil {
+ private VariableResolverUtil() {
+ }
+
public static Object resolveVariable(FacesContext context, String variable) {
Application application = context.getApplication();
VariableResolver variableResolver = application.getVariableResolver();
return variableResolver.resolveVariable(context, variable);
+ }
+
+ /**
+ * Clears the value of the variable.
+ * Useful for cleaning up e.g. a session or application variable
+ * to save memory without the knowledge of the scope.
+ * Also useful to enforce a new creation of a managed-bean.
+ * @param context
+ * @param variable
+ */
+ public static void clearVariable(FacesContext context, String variable) {
+ Application application = context.getApplication();
+ ValueBinding valueBinding = application.createValueBinding("#{" + variable + "}");
+ valueBinding.setValue(context, null);
}
}