Author: craigmcc Date: Thu Jan 5 20:54:44 2006 New Revision: 366429 URL: http://svn.apache.org/viewcvs?rev=366429&view=rev Log: Use VariableResolver instead of creating a value binding to instantiate ViewController instances. This avoids problems caused by an implementation of ViewControllerMapper that might create view identifiers that are not legal EL variable identifiers.
Also, per suggestion from Laurie Harper on the dev list, explicty catch and report evaluation exceptions caused by this instantiation, to give the developer a better shot at diagnosing what happened. Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleViewHandler.java struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleViewHandler.java URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleViewHandler.java?rev=366429&r1=366428&r2=366429&view=diff ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleViewHandler.java (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/faces/ShaleViewHandler.java Thu Jan 5 20:54:44 2006 @@ -26,7 +26,9 @@ import javax.faces.application.ViewHandler; import javax.faces.component.UIViewRoot; import javax.faces.context.FacesContext; +import javax.faces.el.EvaluationException; import javax.faces.el.ValueBinding; +import javax.faces.el.VariableResolver; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -223,11 +225,11 @@ // Retrieve an existing instance, or one created and configured by // the managed bean facility - ValueBinding vb = - context.getApplication().createValueBinding("#{" + viewName + "}"); ViewController vc = null; + VariableResolver vr = + context.getApplication().getVariableResolver(); try { - Object vcObject = vb.getValue(context); + Object vcObject = vr.resolveVariable(context, viewName); if (vcObject == null) { log.warn(messages.getMessage("view.noViewController", new Object[] { viewId, viewName })); @@ -237,6 +239,10 @@ } catch (ClassCastException e) { log.warn(messages.getMessage("view.notViewController", new Object[] { viewId, viewName })); + return; + } catch (EvaluationException e) { + log.warn(messages.getMessage("view.evalException", + new Object[] { viewId, viewName }), e); return; } Modified: struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties URL: http://svn.apache.org/viewcvs/struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties?rev=366429&r1=366428&r2=366429&view=diff ============================================================================== --- struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties (original) +++ struts/shale/trunk/core-library/src/java/org/apache/shale/resources/Bundle.properties Thu Jan 5 20:54:44 2006 @@ -29,6 +29,7 @@ filter.vcmInstantiate=ViewControllerMapper class {0} instance cannot be instantiated # org.apache.shale.application.ShaleViewHandler +view.evalException=Evaluation exception creating a managed bean named {1} for viewId {0} view.notViewController=Bean for viewId {0} under name {1} is not a ViewController view.noViewController=No ViewController for viewId {0} found under name {1} view.noViewControllerMapper=No ViewControllerMapper has been configured for this application --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]