Author: rahul Date: Wed Jan 31 12:13:46 2007 New Revision: 501972 URL: http://svn.apache.org/viewvc?view=rev&rev=501972 Log: Add a ShaleDialogELContext, which is a Commons SCXML Context backed by the application VariableResolver. This simplest approach should work for JSF 1.2 as well, but uses the deprecated (in 1.2) Application#getVariableResolver(). Given the changes in the underlying EL API, we may have to resort to reflection at some point. @since tag points to 1.0.5, will port to 1_0_X branch in a few. Remove related todo. SHALE-403
Added: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java (with props) Modified: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java Modified: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java?view=diff&rev=501972&r1=501971&r2=501972 ============================================================================== --- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java (original) +++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/SCXMLDialogContext.java Wed Jan 31 12:13:46 2007 @@ -38,7 +38,6 @@ import org.apache.commons.scxml.TriggerEvent; import org.apache.commons.scxml.env.SimpleDispatcher; import org.apache.commons.scxml.env.SimpleErrorReporter; -import org.apache.commons.scxml.env.jsp.ELContext; import org.apache.commons.scxml.model.ModelException; import org.apache.commons.scxml.model.SCXML; import org.apache.commons.scxml.model.State; @@ -95,7 +94,7 @@ new SimpleDispatcher(), new SimpleErrorReporter()); SCXML statemachine = dialog.getStateMachine(); this.executor.setStateMachine(statemachine); - Context rootCtx = new ELContext(); + Context rootCtx = new ShaleDialogELContext(); rootCtx.setLocal(Globals.DIALOG_PROPERTIES, new DialogProperties()); this.executor.setRootContext(rootCtx); this.executor.addListener(statemachine, new DelegatingSCXMLListener()); @@ -104,10 +103,6 @@ log().debug("Constructor(id=" + id + ", name=" + name + ")"); } - - // TODO - Consider adding an explicit root context backed by either the - // request or session map for greater EL capacities in the SCXML - // document describing this dialog } Added: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java?view=auto&rev=501972 ============================================================================== --- shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java (added) +++ shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java Wed Jan 31 12:13:46 2007 @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to you under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shale.dialog.scxml; + +import javax.faces.context.FacesContext; +import javax.faces.el.VariableResolver; + +import org.apache.commons.scxml.env.SimpleContext; + + +/** + * <p>EL context used by the Commons SCXML executor driving the Shale + * dialog, backed by application [EMAIL PROTECTED] VariableResolver}.</p> + * + * @since 1.0.5 + * + * $Id$ + */ + +public class ShaleDialogELContext extends SimpleContext { + + /** Serial version UID. */ + private static final long serialVersionUID = 1L; + + /** + * Constructor. + */ + public ShaleDialogELContext() { + super(); + } + + + /** + * Get the value of this variable from the application + * [EMAIL PROTECTED] VariableResolver} in use; delegating to parent. + * + * @param name The variable name + * @return Object The variable value + * @see org.apache.commons.scxml.Context#get(java.lang.String) + */ + public Object get(final String name) { + FacesContext context = FacesContext.getCurrentInstance(); + VariableResolver vr = context.getApplication().getVariableResolver(); + Object value = vr.resolveVariable(context, name); + if (value != null) { + return value; + } + return super.get(name); + } + + +} Propchange: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: shale/framework/trunk/shale-dialog-scxml/src/main/java/org/apache/shale/dialog/scxml/ShaleDialogELContext.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL