You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/10/25 03:14:20 UTC

svn commit: r588100 - in /myfaces/orchestra/trunk: core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/ core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/ core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBui...

Author: imario
Date: Wed Oct 24 18:14:19 2007
New Revision: 588100

URL: http://svn.apache.org/viewvc?rev=588100&view=rev
Log:
interim hack to make dynaForm work with facelets ui:include/ui:param. The correct solution needs to be figured out.
Beware, this hack alone does not solve the problem, you need a Facelets ComponentHandler too which is not yet committed.
We need to figure out how things should be done right first.

Added:
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java   (with props)
Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraApplication.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaFormRenderer.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/Slipstream.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
    myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderDecorator.java

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraApplication.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraApplication.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraApplication.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/lib/jsf/OrchestraApplication.java Wed Oct 24 18:14:19 2007
@@ -20,6 +20,11 @@
 
 import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
 
+import javax.el.ELContextListener;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
 import javax.faces.FacesException;
 import javax.faces.application.Application;
 import javax.faces.application.NavigationHandler;
@@ -35,11 +40,6 @@
 import javax.faces.el.VariableResolver;
 import javax.faces.event.ActionListener;
 import javax.faces.validator.Validator;
-import javax.el.ELResolver;
-import javax.el.ValueExpression;
-import javax.el.ExpressionFactory;
-import javax.el.ELContextListener;
-import javax.el.ELException;
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Locale;

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaForm.java Wed Oct 24 18:14:19 2007
@@ -22,6 +22,7 @@
 import org.apache.myfaces.orchestra.dynaForm.uri.FacesUriResolver;
 import org.apache.myfaces.orchestra.dynaForm.uri.UriResolver;
 
+import javax.el.ELContext;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIComponentBase;
 import javax.faces.context.FacesContext;
@@ -52,6 +53,12 @@
     @Transient
 	private transient UriResolver.Configuration configuration = null;
 	private transient DynaConfigs formConfigs = null;
+	private transient ELContext elcontext;
+
+	public DynaForm()
+	{
+		super();
+	}
 
 	@Override
 	public String getFamily()
@@ -347,5 +354,15 @@
 		}
 
 		return null;
+	}
+
+	public ELContext getELContext()
+	{
+		return elcontext;
+	}
+
+	public void setELContext(ELContext elcontext)
+	{
+		this.elcontext = elcontext;
 	}
 }

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaFormRenderer.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaFormRenderer.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/component/dynaForm/DynaFormRenderer.java Wed Oct 24 18:14:19 2007
@@ -102,6 +102,11 @@
 		}
 	}
 
+	public void decode(FacesContext context, UIComponent component)
+	{
+		super.decode(context, component);	//To change body of overridden methods use File | Settings | File Templates.
+	}
+
 	@Override
 	public boolean getRendersChildren()
 	{
@@ -266,6 +271,7 @@
 
 		JsfGuiBuilder guiBuilder = createGuiBuilder(context);
 
+		guiBuilder.setELContext(dynaForm.getELContext());
 		guiBuilder.setContext(context);
 		// guiBuilder.setBackingBeanPrefix(dynaForm.getVar());
 

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/GuiBuilder.java Wed Oct 24 18:14:19 2007
@@ -35,7 +35,7 @@
 	private boolean displayOnly;
 	private Map labelBundle;
 
-    /**
+	/**
      * check if this field should be rendered display only
      */
     public boolean isDisplayOnly(FieldInterface field)

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/Slipstream.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/Slipstream.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/Slipstream.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/Slipstream.java Wed Oct 24 18:14:19 2007
@@ -109,5 +109,5 @@
 		guiBuilder.setDisplayOnly(isDisplayOnly());
 		guiBuilder.setLabelBundle(getLabelBundle());
         guiBuilder.setIdAsDisplayOnly(isIdAsDisplayOnly());
-    }
+	}
 }

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilder.java Wed Oct 24 18:14:19 2007
@@ -18,14 +18,16 @@
  */
 package org.apache.myfaces.orchestra.dynaForm.guiBuilder.impl.jsf;
 
+import org.apache.myfaces.orchestra.dynaForm.component.dynaForm.DynaForm;
 import org.apache.myfaces.orchestra.dynaForm.guiBuilder.GuiBuilder;
 import org.apache.myfaces.orchestra.dynaForm.lib.ObjectSerializationConverter;
+import org.apache.myfaces.orchestra.dynaForm.lib._FacesUtils;
 import org.apache.myfaces.orchestra.dynaForm.metadata.FieldInterface;
 import org.apache.myfaces.orchestra.dynaForm.metadata.Selection;
 import org.apache.myfaces.orchestra.dynaForm.metadata.utils.TypeInfos;
-import org.apache.myfaces.orchestra.dynaForm.component.dynaForm.DynaForm;
 import org.apache.myfaces.orchestra.lib.OrchestraException;
 
+import javax.el.ELContext;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIInput;
 import javax.faces.component.UIOutput;
@@ -72,6 +74,7 @@
 	public static final String SEARCH_ENTITY_BINDING = "_ff_searchEntityBinding";
 
 	private FacesContext context;
+	private ELContext elcontext;
 	private NewComponentListener newComponentListener;
 	private String backingEntityPrefix;
 
@@ -126,6 +129,21 @@
 		this.context = context;
 	}
 
+	public FacesContext getContext()
+	{
+		return context;
+	}
+
+	public void setELContext(ELContext elcontext)
+	{
+		this.elcontext = elcontext;
+	}
+
+	public ELContext getELContext()
+	{
+		return this.elcontext;
+	}
+
 	/* fulfill the interface */
 	@Override
 	public void createOutputText(FieldInterface field)
@@ -861,8 +879,21 @@
 	 */
 	public void initValueBinding(UIComponent cmp, FieldInterface field)
 	{
-		cmp.setValueBinding("value", context.getApplication()
-			.createValueBinding(createValueBindingString(field)));
+		if (_FacesUtils.useValueExpression())
+		{
+			ELContext elCtx = getELContext();
+			if (elCtx == null)
+			{
+				elCtx = context.getELContext();
+			}
+			cmp.setValueExpression("value", context.getApplication()
+				.getExpressionFactory().createValueExpression(elCtx, createValueBindingString(field), Object.class));
+		}
+		else
+		{
+			cmp.setValueBinding("value", context.getApplication()
+				.createValueBinding(createValueBindingString(field)));
+		}
 	}
 
 	protected String createValueBindingString(FieldInterface field)
@@ -1084,11 +1115,6 @@
 			si.setItemValue(selection.getValue());
 			cmp.getChildren().add(si);
 		}
-	}
-
-	public FacesContext getContext()
-	{
-		return context;
 	}
 
 	@Override

Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderDecorator.java?rev=588100&r1=588099&r2=588100&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderDecorator.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/guiBuilder/impl/jsf/JsfGuiBuilderDecorator.java Wed Oct 24 18:14:19 2007
@@ -33,6 +33,7 @@
 import javax.faces.component.html.HtmlSelectOneMenu;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.DateTimeConverter;
+import javax.el.ELContext;
 import java.util.Map;
 
 /**
@@ -231,6 +232,16 @@
 	public FacesContext getContext()
 	{
 		return original.getContext();
+	}
+
+	public void setELContext(ELContext elcontext)
+	{
+		original.setELContext(elcontext);
+	}
+
+	public ELContext getELContext()
+	{
+		return original.getELContext();
 	}
 
 	public NewComponentListener getNewComponentListener()

Added: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java?rev=588100&view=auto
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java (added)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java Wed Oct 24 18:14:19 2007
@@ -0,0 +1,61 @@
+/*
+ * 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.myfaces.orchestra.dynaForm.lib;
+
+import javax.faces.application.Application;
+
+/**
+ * Some JSF helpers, e.g. to determine the used JSF Version
+ */
+public final class _FacesUtils
+{
+	private static int version;
+
+	static
+	{
+		version = determineJSFVersion();
+	}
+
+	private _FacesUtils()
+	{
+	}
+
+	private static int determineJSFVersion()
+	{
+		try
+		{
+			Application.class.getMethod("getExpressionFactory", null); // NON-NLS
+		}
+		catch (NoSuchMethodException e)
+		{
+			return 11;
+		}
+		return 12;
+	}
+
+	private final static int getVersion()
+	{
+		return version;
+	}
+
+	public static boolean useValueExpression()
+	{
+		return getVersion() > 11;
+	}
+}

Propchange: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/lib/_FacesUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain