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 2006/05/18 20:44:12 UTC
svn commit: r407608 - in
/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared:
renderkit/html/HtmlButtonRendererBase.java
renderkit/html/HtmlLinkRendererBase.java renderkit/html/util/FormInfo.java
util/_ComponentUtils.java
Author: imario
Date: Thu May 18 11:44:10 2006
New Revision: 407608
URL: http://svn.apache.org/viewvc?rev=407608&view=rev
Log:
MYFACES-1308: use component family instead of "instanceof UIForm" to find the parent form
Modified:
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/FormInfo.java
myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java?rev=407608&r1=407607&r2=407608&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlButtonRendererBase.java Thu May 18 11:44:10 2006
@@ -20,7 +20,6 @@
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
import javax.faces.component.ValueHolder;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.context.ExternalContext;
@@ -173,7 +172,7 @@
throw new IllegalArgumentException("Component " + uiComponent.getClientId(facesContext) + " must be embedded in an form");
}
String formName = formInfo.getFormName();
- UIForm nestingForm = formInfo.getForm();
+ UIComponent nestingForm = formInfo.getForm();
StringBuffer onClick = new StringBuffer();
String commandOnClick = (String)uiComponent.getAttributes().get(HTML.ONCLICK_ATTR);
@@ -199,7 +198,7 @@
return onClick;
}
- protected void addHiddenCommandParameter(FacesContext facesContext, UIForm nestingForm, String hiddenFieldName)
+ protected void addHiddenCommandParameter(FacesContext facesContext, UIComponent nestingForm, String hiddenFieldName)
{
if (nestingForm != null)
{
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java?rev=407608&r1=407607&r2=407608&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlLinkRendererBase.java Thu May 18 11:44:10 2006
@@ -208,7 +208,7 @@
{
throw new IllegalArgumentException("Component " + clientId + " must be embedded in an form");
}
- UIForm nestingForm = formInfo.getForm();
+ UIComponent nestingForm = formInfo.getForm();
String formName = formInfo.getFormName();
StringBuffer onClick = new StringBuffer();
@@ -299,7 +299,7 @@
return _ComponentUtils.findNestingForm(uiComponent, facesContext);
}
- protected void addHiddenCommandParameter(FacesContext facesContext, UIForm nestingForm, String hiddenFieldName)
+ protected void addHiddenCommandParameter(FacesContext facesContext, UIComponent nestingForm, String hiddenFieldName)
{
if (nestingForm != null)
{
@@ -413,7 +413,7 @@
Object value,
StringBuffer onClick,
String jsForm,
- UIForm nestingForm)
+ UIComponent nestingForm)
{
if (name == null)
{
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/FormInfo.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/FormInfo.java?rev=407608&r1=407607&r2=407608&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/FormInfo.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/util/FormInfo.java Thu May 18 11:44:10 2006
@@ -15,20 +15,20 @@
*/
package org.apache.myfaces.shared.renderkit.html.util;
-import javax.faces.component.UIForm;
+import javax.faces.component.UIComponent;
public class FormInfo
{
- private final UIForm form;
+ private final UIComponent form;
private final String formName;
- public FormInfo(final UIForm form, final String formName)
+ public FormInfo(final UIComponent form, final String formName)
{
this.form = form;
this.formName = formName;
}
- public UIForm getForm()
+ public UIComponent getForm()
{
return form;
}
Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java?rev=407608&r1=407607&r2=407608&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java Thu May 18 11:44:10 2006
@@ -28,6 +28,8 @@
*/
public final class _ComponentUtils
{
+ public static final String COMPONENT_FAMILY = "javax.faces.Form";
+
private _ComponentUtils()
{
}
@@ -45,21 +47,16 @@
public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
{
UIComponent parent = uiComponent.getParent();
- while (parent != null && !(parent instanceof UIForm))
+ while (parent != null && !COMPONENT_FAMILY.equals(parent.getFamily()))
{
parent = parent.getParent();
}
- UIForm nestingForm = null;
- String formName;
-
if (parent != null)
{
//link is nested inside a form
- nestingForm = (UIForm)parent;
- formName = nestingForm.getClientId(facesContext);
-
- return new FormInfo(nestingForm, formName);
+ String formName = parent.getClientId(facesContext);
+ return new FormInfo(parent, formName);
}
return null;