You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ma...@apache.org on 2006/11/22 09:01:41 UTC

svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Author: matzew
Date: Wed Nov 22 00:01:40 2006
New Revision: 478073

URL: http://svn.apache.org/viewvc?view=rev&rev=478073
Log:
First step for MYFACES-1496. Making _ComponentUtils deprecated! and modifying RendererUtils.

Modified:
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.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/RendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java?view=diff&rev=478073&r1=478072&r2=478073
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/RendererUtils.java Wed Nov 22 00:01:40 2006
@@ -18,31 +18,46 @@
  */
 package org.apache.myfaces.shared.renderkit;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.shared.util.HashMapUtils;
-import org.apache.myfaces.shared.util.SelectItemsIterator;
-import org.apache.myfaces.shared.renderkit._SharedRendererUtils;
-import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 
 import javax.faces.FacesException;
-import javax.faces.event.PhaseId;
-import javax.faces.component.*;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UINamingContainer;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UISelectMany;
+import javax.faces.component.UISelectOne;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.ValueHolder;
 import javax.faces.component.html.HtmlInputText;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.el.PropertyNotFoundException;
 import javax.faces.el.ValueBinding;
+import javax.faces.event.PhaseId;
 import javax.faces.model.SelectItem;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Array;
-import java.util.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
+import org.apache.myfaces.shared.util.HashMapUtils;
+import org.apache.myfaces.shared.util.SelectItemsIterator;
 
 /**
  * @author Manfred Geiler (latest modification by $Author$)
@@ -170,6 +185,16 @@
         return ((ValueHolder) component).getValue();
     }
 
+    public static String getStringValue(FacesContext context, ValueBinding vb)
+    {
+        Object value = vb.getValue(context);
+        if (value != null)
+        {
+            return value.toString();
+        }
+        return null;
+    }
+    
     public static String getStringValue(FacesContext facesContext,
                                         UIComponent component) {
         try {
@@ -607,7 +632,6 @@
         return i != null ? i.intValue() : defaultValue;
     }
 
-    private static final String FORM_COMPONENT_FAMILY = "javax.faces.Form";
     private static final String TRINIDAD_FORM_COMPONENT_FAMILY = "org.apache.myfaces.trinidad.Form";
     private static final String ADF_FORM_COMPONENT_FAMILY = "oracle.adf.Form";
 
@@ -615,9 +639,10 @@
     /**
      * Find the enclosing form of a component
      * in the view-tree.
-     * All known form-families are searched for.
-     * Currently those are the standard form family,
-     * the Trinidad form family, and the (old) ADF Faces form family.
+     * All Subclasses of <code>UIForm</code> and all known 
+     * form-families are searched for.
+     * Currently those are the Trinidad form family,
+     * and the (old) ADF Faces form family.
      * <p/>
      * There might be additional form families
      * which have to be explicitly entered here.
@@ -626,15 +651,18 @@
      * @param facesContext
      * @return FormInfo Information about the form - the form itself and its name.
      */
-    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext) {
+    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
+    {
         UIComponent parent = uiComponent.getParent();
-        while (parent != null && (!FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
-            !ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
-            !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent.getFamily()))) {
+        while (parent != null && (!ADF_FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
+            !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent.getFamily()) &&
+            !(parent instanceof UIForm)))
+        {
             parent = parent.getParent();
         }
 
-        if (parent != null) {
+        if (parent != null)
+        {
             //link is nested inside a form
             String formName = parent.getClientId(facesContext);
             return new FormInfo(parent, formName);
@@ -642,7 +670,6 @@
 
         return null;
     }
-
 
     public static boolean getBooleanValue(String attribute, Object value, boolean defaultValue) {
         if (value instanceof Boolean) {

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?view=diff&rev=478073&r1=478072&r2=478073
==============================================================================
--- 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 Wed Nov 22 00:01:40 2006
@@ -28,6 +28,7 @@
 /**
  * @author Mathias Br&ouml;kelmann (latest modification by $Author$)
  * @version $Revision$ $Date$
+ * @deprecated use <code>RendererUtils</code> instead
  */
 public final class _ComponentUtils
 {
@@ -36,6 +37,10 @@
     {
     }
 
+    /**
+     * 
+     * @deprecated use <code>RendererUtils.getStringValue</code> instead
+     */
     public static String getStringValue(FacesContext context, ValueBinding vb)
     {
         Object value = vb.getValue(context);
@@ -49,6 +54,10 @@
     private static final String TRINIDAD_FORM_COMPONENT_FAMILY = "org.apache.myfaces.trinidad.Form";
     private static final String ADF_FORM_COMPONENT_FAMILY = "oracle.adf.Form";
     
+    /**
+     * 
+     * @deprecated use <code>RendererUtils.findNestingForm</code> instead
+     */
     public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
     {
         UIComponent parent = uiComponent.getParent();



Re: svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> done for findNestingForm ;)
> (not getValie...
Great! Thanks!
I'll drink a beer for your tonight :-D


Ciao,
Mario


Re: svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Posted by Matthias Wessendorf <ma...@apache.org>.
done for findNestingForm ;)
(not getValie...


On 11/22/06, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi!
> > see my other comment on that;
> > I didn't got feedback on my first email, so I only started on that.
> Well, I am fine with what you do, nothing bad :-)
> Deprecation is good and remove all callers is super, still, delegating
> the deprecated methods to the supported one is just another wish from my
> side ;-)
>
> Ciao,
> Mario
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
> see my other comment on that;
> I didn't got feedback on my first email, so I only started on that.
Well, I am fine with what you do, nothing bad :-)
Deprecation is good and remove all callers is super, still, delegating
the deprecated methods to the supported one is just another wish from my
side ;-)

Ciao,
Mario


Re: svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Posted by Matthias Wessendorf <ma...@apache.org>.
see my other comment on that;
I didn't got feedback on my first email, so I only started on that.

currently I remove all callers for findNestingForm;
getValue...() is under discussion



On 11/22/06, Mario Ivankovits <ma...@ops.co.at> wrote:
> Hi Matze!
> > First step for MYFACES-1496. Making _ComponentUtils deprecated! and modifying RendererUtils.
> >
> Maybe you can not only deprecate it, but also delegate them to the
> RendererUtils.
> That way we do not have to maintain two pieces of code.
>
> Ciao,
> Mario
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: svn commit: r478073 - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: renderkit/RendererUtils.java util/_ComponentUtils.java

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi Matze!
> First step for MYFACES-1496. Making _ComponentUtils deprecated! and modifying RendererUtils.
>   
Maybe you can not only deprecate it, but also delegate them to the
RendererUtils.
That way we do not have to maintain two pieces of code.

Ciao,
Mario