You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2006/07/17 02:29:46 UTC

svn commit: r422578 - in /myfaces: core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/ shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/ shared/tr...

Author: mmarinschek
Date: Sun Jul 16 17:29:45 2006
New Revision: 422578

URL: http://svn.apache.org/viewvc?rev=422578&view=rev
Log:
further compatibility work. Reworked all form searching routines to also look up the trinidad form. Tried to avoid any casts to UIForm (where they are still there, they are marked as todo). Tried to avoid any casts to UIInput.

Modified:
    myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHiddenRenderer.java
    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/renderkit/html/HtmlButtonRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.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/HtmlRadioRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/_ComponentUtils.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadio.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlButtonRenderer.java
    myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlLinkRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java
    myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java

Modified: myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHiddenRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHiddenRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHiddenRenderer.java (original)
+++ myfaces/core/trunk/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlHiddenRenderer.java Sun Jul 16 17:29:45 2006
@@ -72,16 +72,10 @@
 
     public void decode(FacesContext facesContext, UIComponent component)
      {
-         RendererUtils.checkParamValidity(facesContext,component,null);
+         RendererUtils.checkParamValidity(facesContext,component,UIInput.class);
+
+         HtmlRendererUtils.decodeUIInput(facesContext, component);
 
-         if (component instanceof UIInput)
-         {
-             HtmlRendererUtils.decodeUIInput(facesContext, component);
-         }
-         else
-         {
-             throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName());
-         }
      }
 
 }

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?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- 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 Sun Jul 16 17:29:45 2006
@@ -20,6 +20,7 @@
 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 javax.faces.FacesException;
 import javax.faces.event.PhaseId;
@@ -692,19 +693,40 @@
         return i != null ? i.intValue() : defaultValue;
     }
 
-    public static UIForm findParentForm(UIComponentBase comp)
+    private static final String FORM_COMPONENT_FAMILY = "javax.faces.Form";
+    private static final String TRINIDAD_FORM_COMPONENT_FAMILY = "org.apache.myfaces.adf.Form";
+
+    /**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
+     * and the Trinidad form family.
+     * 
+     * There might be additional form families
+     * which have to be explicitly entered here.
+     *
+     * @param uiComponent
+     * @param facesContext
+     * @return
+     */
+    public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
     {
-        UIComponent parent = comp.getParent();
-        while (parent != null)
+        UIComponent parent = uiComponent.getParent();
+        while (parent != null && (!FORM_COMPONENT_FAMILY.equals(parent.getFamily()) && !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent.getFamily())))
         {
-            if (parent instanceof UIForm)
-            {
-                return (UIForm)parent;
-            }
             parent = parent.getParent();
         }
+
+        if (parent != null)
+        {
+            //link is nested inside a form
+            String formName = parent.getClientId(facesContext);
+            return new FormInfo(parent, formName);
+        }
+
         return null;
     }
+
 
     public static boolean getBooleanValue(String attribute, Object value, boolean defaultValue)
     {

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=422578&r1=422577&r2=422578&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 Sun Jul 16 17:29:45 2006
@@ -142,33 +142,6 @@
     protected StringBuffer buildOnClick(UIComponent uiComponent, FacesContext facesContext, ResponseWriter writer)
         throws IOException
     {
-    	/* DUMMY STUFF
-        //Find form
-        UIComponent parent = uiComponent.getParent();
-        while (parent != null && !(parent instanceof UIForm))
-        {
-            parent = parent.getParent();
-        }
-
-        UIForm nestingForm = null;
-        String formName;
-
-        if (parent != null)
-        {
-            //link is nested inside a form
-            nestingForm = (UIForm)parent;
-            formName = nestingForm.getClientId(facesContext);
-
-        }
-        else
-        {
-            //not nested in form, we must add a dummy form at the end of the document
-            formName = DummyFormUtils.DUMMY_FORM_NAME;
-            //dummyFormResponseWriter = DummyFormUtils.getDummyFormResponseWriter(facesContext);
-            //dummyFormResponseWriter.setWriteDummyForm(true);
-            DummyFormUtils.setWriteDummyForm(facesContext, true);
-        }
-        */
     	FormInfo formInfo = findNestingForm(uiComponent, facesContext);
     	if (formInfo == null)
     	{
@@ -187,7 +160,7 @@
         }
 
         //call the script to clear the form (clearFormHiddenParams_<formName>) method
-        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("('").append(formName).append("');");
+        HtmlRendererUtils.appendClearHiddenCommandFormParamsFunctionCall(onClick,formName);
 
         if (MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).isAutoScroll())
         {

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlFormRendererBase.java Sun Jul 16 17:29:45 2006
@@ -16,6 +16,8 @@
 package org.apache.myfaces.shared.renderkit.html;
 
 import org.apache.myfaces.shared.config.MyfacesConfig;
+import org.apache.myfaces.shared.renderkit.RendererUtils;
+import org.apache.myfaces.shared.renderkit.html.util.FormInfo;
 
 import javax.faces.FacesException;
 import javax.faces.application.ViewHandler;
@@ -82,20 +84,15 @@
 
         if("true".equals(facesContext.getExternalContext().getInitParameter(VALIDATE_CONTEXT_PARAM)))
         {
-            UIComponent parent = component.getParent();
+            FormInfo info = RendererUtils.findNestingForm(component, facesContext);
 
-            while(parent != null)
+            if(info!=null && info.getForm()!=null)
             {
-                if(parent instanceof UIForm)
-                {
                     throw new FacesException("You should never nest HTML-forms. "+
                             "This leads to unpredictable behaviour in all major browsers. "+
                                 "You can use multiple forms on a page, but they may not be nested!"+
                                     "If you need to disable this check (on your own risk!) set the param " +
                                         "org.apache.myfaces.VALIDATE in your web.xml context parameters to false");
-                }
-
-                parent = parent.getParent();
             }
         }
 

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=422578&r1=422577&r2=422578&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 Sun Jul 16 17:29:45 2006
@@ -237,7 +237,7 @@
         }
 
         //call the script to clear the form (clearFormHiddenParams_<formName>) method
-        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("('").append(formName).append("');");
+        HtmlRendererUtils.appendClearHiddenCommandFormParamsFunctionCall(onClick,formName);
 
         String jsForm = "document.forms['" + formName + "']";
 

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRadioRendererBase.java Sun Jul 16 17:29:45 2006
@@ -15,14 +15,15 @@
  */
 package org.apache.myfaces.shared.renderkit.html;
 
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.shared.renderkit.JSFAttr;
+import org.apache.myfaces.shared.renderkit.RendererUtils;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.component.UIOutput;
 import javax.faces.component.UISelectOne;
+import javax.faces.component.EditableValueHolder;
 import javax.faces.component.html.HtmlSelectOneRadio;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
@@ -30,12 +31,9 @@
 import javax.faces.convert.ConverterException;
 import javax.faces.model.SelectItem;
 import javax.faces.model.SelectItemGroup;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.myfaces.shared.renderkit.JSFAttr;
-import org.apache.myfaces.shared.renderkit.RendererUtils;
-import org.apache.myfaces.shared.renderkit.html.HTML;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
 
 /**
  * @author Manfred Geiler (latest modification by $Author$)
@@ -210,7 +208,7 @@
     }
 
     protected void renderRadio(FacesContext facesContext,
-                               UIInput uiComponent,
+                               UIComponent uiComponent,
                                String value,
                                String label,
                                boolean disabled,
@@ -274,7 +272,7 @@
     public void decode(FacesContext facesContext, UIComponent uiComponent)
     {
         org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext, uiComponent, null);
-        if (uiComponent instanceof UIInput)
+        if (uiComponent instanceof EditableValueHolder)
         {
             HtmlRendererUtils.decodeUISelectOne(facesContext, uiComponent);
         }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java Sun Jul 16 17:29:45 2006
@@ -800,7 +800,7 @@
         return false;
     }
 
-    public static void renderDisplayValueOnly(FacesContext facesContext, UIInput input) throws IOException {
+    public static void renderDisplayValueOnly(FacesContext facesContext, UIComponent input) throws IOException {
         ResponseWriter writer = facesContext.getResponseWriter();
         writer.startElement(org.apache.myfaces.shared.renderkit.html.HTML.SPAN_ELEM, input);
 
@@ -814,6 +814,15 @@
         writer.endElement(HTML.SPAN_ELEM);
     }
 
+    public static void appendClearHiddenCommandFormParamsFunctionCall(StringBuffer onClick, String formName)
+    {
+        onClick.append("if(window.");
+        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName));
+        onClick.append("!=undefined) {");
+        onClick.append(HtmlRendererUtils.getClearHiddenCommandFormParamsFunctionName(formName)).append("('").append(formName).append("');");
+        onClick.append("}");
+    }
+
     public static class LinkParameter {
         private String _name;
 
@@ -933,34 +942,6 @@
                                              + formName
                     .replace(NamingContainer.SEPARATOR_CHAR, '_'));
     }
-
-    /**
-     * Return the clientId of the form associated with the specified component.
-     * <p>
-     * If the component is nested within a UIForm, that component's id is returned.
-     * <p>
-     * Otherwise the component of the "dummy form" is returned. At most one dummy
-     * form is output into each page; all components which can cause page submission
-     * but are not nested within a real form will cause the dummy form to be
-     * submitted instead.
-     */
-    /*
-    public static String getFormName(UIComponent component, FacesContext context) {
-        //Find form
-        UIComponent parent = component.getParent();
-        while (parent != null && !(parent instanceof UIForm)) {
-            parent = parent.getParent();
-        }
-
-        if (parent != null) {
-            //link is nested inside a form
-            return ((UIForm) parent).getClientId(context);
-        }
-        //not nested in form, we must add a dummy form at the end of the
-        // document
-        return org.apache.myfaces.shared.renderkit.html.util.DummyFormUtils.DUMMY_FORM_NAME;
-    }
-    */
 
     /**
      * Get the name of the request parameter that holds the id of the

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlSecretRendererBase.java Sun Jul 16 17:29:45 2006
@@ -17,13 +17,10 @@
 
 import org.apache.myfaces.shared.renderkit.JSFAttr;
 import org.apache.myfaces.shared.renderkit.RendererUtils;
-import org.apache.myfaces.shared.renderkit.html.HTML;
-import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.component.UIOutput;
+import javax.faces.component.UIInput;
 import javax.faces.component.html.HtmlInputSecret;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextRendererBase.java Sun Jul 16 17:29:45 2006
@@ -22,10 +22,7 @@
 import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
 import org.apache.myfaces.shared.component.EscapeCapable;
 
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
-import javax.faces.component.UIOutput;
-import javax.faces.component.UIViewRoot;
+import javax.faces.component.*;
 import javax.faces.component.html.HtmlInputText;
 import javax.faces.component.html.HtmlOutputText;
 import javax.faces.context.FacesContext;
@@ -48,11 +45,11 @@
     {
         org.apache.myfaces.shared.renderkit.RendererUtils.checkParamValidity(facesContext,component,null);
 
-        if (component instanceof UIInput)
+        if (component instanceof EditableValueHolder)
         {
             renderInput(facesContext, component);
         }
-        else if (component instanceof UIOutput)
+        else if (component instanceof ValueHolder)
         {
             renderOutput(facesContext, component);
         }
@@ -170,11 +167,11 @@
     {
         RendererUtils.checkParamValidity(facesContext,component,null);
 
-        if (component instanceof UIInput)
+        if (component instanceof EditableValueHolder)
         {
             HtmlRendererUtils.decodeUIInput(facesContext, component);
         }
-        else if (component instanceof UIOutput)
+        else if (component instanceof ValueHolder)
         {
             //nothing to decode
         }

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java (original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlTextareaRendererBase.java Sun Jul 16 17:29:45 2006
@@ -16,13 +16,10 @@
 package org.apache.myfaces.shared.renderkit.html;
 
 import org.apache.myfaces.shared.renderkit.RendererUtils;
-import org.apache.myfaces.shared.renderkit.html.HTML;
-import org.apache.myfaces.shared.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
 import javax.faces.component.UIOutput;
+import javax.faces.component.UIInput;
 import javax.faces.component.html.HtmlInputTextarea;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;

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=422578&r1=422577&r2=422578&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 Sun Jul 16 17:29:45 2006
@@ -16,7 +16,6 @@
 package org.apache.myfaces.shared.util;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 import javax.faces.el.ValueBinding;
 
@@ -28,8 +27,7 @@
  */
 public final class _ComponentUtils
 {
-    public static final String COMPONENT_FAMILY = "javax.faces.Form";
-    
+
     private _ComponentUtils()
     {
     }
@@ -44,22 +42,24 @@
         return null;
     }
 
+    private static final String FORM_COMPONENT_FAMILY = "javax.faces.Form";
+    private static final String TRINIDAD_FORM_COMPONENT_FAMILY = "org.apache.myfaces.adf.Form";
+
     public static FormInfo findNestingForm(UIComponent uiComponent, FacesContext facesContext)
     {
-        /*big todo: check how to handle the adf-faces form */
         UIComponent parent = uiComponent.getParent();
-        while (parent != null && !COMPONENT_FAMILY.equals(parent.getFamily()))
+        while (parent != null && (!FORM_COMPONENT_FAMILY.equals(parent.getFamily()) && !TRINIDAD_FORM_COMPONENT_FAMILY.equals(parent.getFamily())))
         {
             parent = parent.getParent();
         }
-        
+
         if (parent != null)
         {
             //link is nested inside a form
-        	String formName = parent.getClientId(facesContext);
-        	return new FormInfo(parent, formName);
+            String formName = parent.getClientId(facesContext);
+            return new FormInfo(parent, formName);
         }
-        
+
         return null;
     }
 }

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadio.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadio.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadio.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/component/html/ext/HtmlSelectOneRadio.java Sun Jul 16 17:29:45 2006
@@ -15,27 +15,27 @@
  */
 package org.apache.myfaces.component.html.ext;
 
-import java.util.Iterator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+import org.apache.myfaces.component.html.util.HtmlComponentUtils;
+import org.apache.myfaces.shared_tomahawk.component.DisplayValueOnlyCapable;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
 
+import javax.faces.FacesException;
 import javax.faces.application.FacesMessage;
-import javax.faces.component.UIInput;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.el.EvaluationException;
 import javax.faces.el.MethodBinding;
 import javax.faces.el.ValueBinding;
 import javax.faces.validator.Validator;
 import javax.faces.validator.ValidatorException;
-
-import org.apache.myfaces.shared_tomahawk.component.DisplayValueOnlyCapable;
-import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
-import org.apache.myfaces.shared_tomahawk.util._ComponentUtils;
-
-import org.apache.myfaces.component.UserRoleAware;
-import org.apache.myfaces.component.UserRoleUtils;
-import org.apache.myfaces.component.html.util.HtmlComponentUtils;
-import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.Iterator;
 
 /**
  * @author Manfred Geiler (latest modification by $Author$)
@@ -138,9 +138,14 @@
         return defaultValue;
     }
 
-    private static void callValidators(FacesContext context, UIInput input, Object convertedValue)
+    private static void callValidators(FacesContext context, UIComponent input, Object convertedValue)
     {
-        Validator[] validators = input.getValidators();
+        if(!(input instanceof EditableValueHolder))
+            throw new FacesException("param input not of type EditableValueHolder, but of : "+input.getClass().getName());
+
+        EditableValueHolder holder = (EditableValueHolder) input;
+
+        Validator[] validators = holder.getValidators();
         for (int i = 0; i < validators.length; i++)
         {
             Validator validator = validators[i];
@@ -150,7 +155,7 @@
             }
             catch (ValidatorException e)
             {
-                input.setValid(false);
+                holder.setValid(false);
                 FacesMessage facesMessage = e.getFacesMessage();
                 if (facesMessage != null)
                 {
@@ -160,7 +165,7 @@
             }
         }
 
-        MethodBinding validatorBinding = input.getValidator();
+        MethodBinding validatorBinding = holder.getValidator();
         if (validatorBinding != null)
         {
             try
@@ -169,7 +174,7 @@
             }
             catch (EvaluationException e)
             {
-                input.setValid(false);
+                holder.setValid(false);
                 Throwable cause = e.getCause();
                 if (cause instanceof ValidatorException)
                 {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/inputHtml/InputHtmlRenderer.java Sun Jul 16 17:29:45 2006
@@ -25,6 +25,7 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.convert.ConverterException;
+import javax.faces.FacesException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -40,6 +41,7 @@
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.HTMLEncoder;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.JavascriptUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
 /**
  * @author Sylvain Vieujot (latest modification by $Author$)
@@ -157,6 +159,7 @@
      */
     private UIComponent htmlTabbedPaneRenderer_getUIComponent(UIComponent uiComponent)
     {
+        /* todo: forms other than UIForm, e.g. Trinidad's UIForm */
         if (uiComponent instanceof UIForm || uiComponent instanceof UINamingContainer)
         {
             List children = uiComponent.getChildren();
@@ -228,18 +231,10 @@
 
     private void encodeEndNormalMode(FacesContext context, InputHtml editor) throws IOException {
         String clientId = editor.getClientId(context);
-        String formId;
-        {
-            UIComponent tmpComponent = editor.getParent();
-            while((tmpComponent != null) && !(tmpComponent instanceof UIForm) ){
-                tmpComponent = tmpComponent.getParent();
-            }
-            if (tmpComponent == null) {
-                log.warn("The inputHtml component must be within a form, giving up!");
-                return;
-            } 
-            formId = tmpComponent.getClientId(context);
-        }
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(editor, context);
+        if(parentFormInfo == null)
+            throw new FacesException("InputHtml must be embedded in a form.");
+        String formId = parentFormInfo.getFormName();
 
         AddResource addResource = AddResourceFactory.getInstance(context);
         addResource.addStyleSheet(context, AddResource.HEADER_BEGIN, InputHtmlRenderer.class, "kupustyles.css");

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/navmenu/jscookmenu/HtmlJSCookMenuRenderer.java Sun Jul 16 17:29:45 2006
@@ -15,22 +15,6 @@
  */
 package org.apache.myfaces.custom.navmenu.jscookmenu;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.ActionEvent;
-import javax.faces.webapp.UIComponentTag;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.custom.navmenu.NavigationMenuItem;
@@ -45,8 +29,24 @@
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlFormRendererBase;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.JavascriptUtils;
 
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.webapp.UIComponentTag;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
 /**
  * @author Thomas Spiegl
  * @version $Revision$ $Date$
@@ -161,18 +161,22 @@
         List list = NavigationMenuUtils.getNavigationMenuItemList(component);
         if (list.size() > 0)
         {
-            UIForm parentForm = getParentForm(component);
-            String formName = getFormName(parentForm,context);
+            FormInfo parentFormInfo = RendererUtils.findNestingForm(component, context);
+
+            if(parentFormInfo == null)
+                throw new FacesException("jscook menu is not embedded in a form.");
+            String formName = parentFormInfo.getFormName();
             List uiNavMenuItemList = component.getChildren();
-            if( formName == null ) {
+            /* todo: disabled for now. Check if dummy form stuff is still needed/desired
+                if( formName == null ) {
                 DummyFormUtils.setWriteDummyForm(context,true);
                 DummyFormUtils.addDummyFormParameter(context,JSCOOK_ACTION_PARAM);
 
                 formName = DummyFormUtils.getDummyFormName();
             }
-            else {
-                HtmlFormRendererBase.addHiddenCommandParameter(context,parentForm,JSCOOK_ACTION_PARAM);
-            }
+            else {*/
+                HtmlFormRendererBase.addHiddenCommandParameter(context,parentFormInfo.getForm(),JSCOOK_ACTION_PARAM);
+            //}
 
             String myId = getMenuId(context, component);
 
@@ -193,36 +197,6 @@
         }
     }
 
-    /**
-     * Method getFormName.
-     *
-     * @param facesContext FacesContext
-     * @return String
-     */
-    private String getFormName(UIForm parentForm,
-                               FacesContext facesContext) {
-        // See if we are in a form
-        if (parentForm != null) { return parentForm.getClientId(facesContext); }
-
-        // Not in a form. Return the child form's name
-        return null;
-    }
-
-    /**
-     * Get the parent UIForm. If no parent is a UIForm then returns null.
-     * 
-     * @param component
-     * @return UIForm
-     */
-    private UIForm getParentForm(UIComponent component) {
-        // See if we are in a form
-        UIComponent parent = component.getParent();
-        while (parent != null && !(parent instanceof UIForm)) {
-            parent = parent.getParent();
-        }
-        return (UIForm) parent;
-    }
-
     private void encodeNavigationMenuItems(FacesContext context,
                                            StringBuffer writer,
                                            NavigationMenuItem[] items,
@@ -396,8 +370,8 @@
                 // should never happen; theme is a required attribute in the jsp tag definition
             throw new IllegalArgumentException("theme name is mandatory for a jscookmenu.");
         }
-        
-    	addResourcesToHeader(theme,menu,context);
+
+        addResourcesToHeader(theme,menu,context);
     }
 
     public void encodeEnd(FacesContext context, UIComponent component) throws IOException

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractCompactScheduleRenderer.java Sun Jul 16 17:29:45 2006
@@ -16,27 +16,22 @@
 
 package org.apache.myfaces.custom.schedule.renderer;
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.custom.schedule.HtmlSchedule;
 import org.apache.myfaces.custom.schedule.model.ScheduleDay;
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
 import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.*;
 
 /**
  * <p>
@@ -147,9 +142,9 @@
                                 boolean isCurrentMonth, int rowspan) throws IOException
     {
         final String clientId = schedule.getClientId(context);
-        final UIForm parentForm = getParentForm(schedule);
         final Map attributes = schedule.getAttributes();
-        final String formId = parentForm == null ? null : parentForm.getClientId(context);
+        final FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
+        final String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();
         final String dayHeaderId = clientId + "_header_" + ScheduleUtil.getDateId(day.getDate());
         final String dayBodyId = clientId + "_body_" + ScheduleUtil.getDateId(day.getDate());
         writer.startElement(HTML.TD_ELEM, schedule);
@@ -220,8 +215,8 @@
                     null);
         }
 
-        
-        
+
+
         writer.writeText(getDateString(context, schedule, day.getDate()), null);
         writer.endElement(HTML.TD_ELEM);
         writer.endElement(HTML.TR_ELEM);
@@ -256,7 +251,7 @@
                 HTML.STYLE_ATTR,
                 "width: 100%; height: 100%; vertical-align: top;",
                 null);
-        
+
         //register an onclick event listener to a day cell which will capture
         //the date
         if (!schedule.isReadonly() && schedule.isSubmitOnClick()) {
@@ -303,9 +298,9 @@
     protected void writeEntries(FacesContext context, HtmlSchedule schedule,
                                 ScheduleDay day, ResponseWriter writer) throws IOException
     {
-        final UIForm parentForm = getParentForm(schedule);
         final String clientId = schedule.getClientId(context);
-        final String formId = parentForm == null ? null : parentForm.getClientId(context);
+        final FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
+        final String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();
         final TreeSet entrySet = new TreeSet(comparator);
 
         for (Iterator entryIterator = day.iterator(); entryIterator.hasNext();)
@@ -389,7 +384,7 @@
 
         return selectedEntry.getId().equals(entry.getId());
     }
-    
+
     /**
      * In the compact renderer, we don't take the y coordinate of the mouse
      * into account when determining the last clicked date.
@@ -399,12 +394,12 @@
         //the dateId is the schedule client id + "_" + yyyyMMdd 
         String day = dateId.substring(dateId.lastIndexOf("_") + 1);
         Date date = ScheduleUtil.getDateFromId(day);
-        
+
         if (date != null) cal.setTime(date);
         cal.set(Calendar.HOUR_OF_DAY, schedule.getVisibleStartHour());
         log.debug("last clicked datetime: " + cal.getTime());
         return cal.getTime();
     }
-    
+
 }
 // The End

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/AbstractScheduleRenderer.java Sun Jul 16 17:29:45 2006
@@ -16,21 +16,6 @@
 
 package org.apache.myfaces.custom.schedule.renderer;
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.ValueBinding;
-import javax.faces.event.ActionEvent;
-import javax.faces.render.Renderer;
-
 import org.apache.myfaces.custom.schedule.HtmlSchedule;
 import org.apache.myfaces.custom.schedule.ScheduleMouseEvent;
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
@@ -40,6 +25,19 @@
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+import javax.faces.render.Renderer;
+import java.io.IOException;
+import java.io.Serializable;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
 /**
  * <p>
  * Abstract superclass for all renderer of the UISchedule component
@@ -325,31 +323,6 @@
         return (String) attributes.get("headerDateFormat");
     }
 
-    /**
-     * <p>
-     * Get the parent form of the schedule component
-     * </p>
-     *
-     * @param component the component
-     *
-     * @return the parent form
-     */
-    protected UIForm getParentForm(UIComponent component)
-    {
-        UIComponent parent = component.getParent();
-
-        while (parent != null)
-        {
-            if (parent instanceof UIForm)
-            {
-                break;
-            }
-
-            parent = parent.getParent();
-        }
-
-        return (UIForm) parent;
-    }
 
     /**
      * <p>

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/schedule/renderer/ScheduleDetailedDayRenderer.java Sun Jul 16 17:29:45 2006
@@ -16,28 +16,23 @@
 
 package org.apache.myfaces.custom.schedule.renderer;
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeSet;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.ValueBinding;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.custom.schedule.HtmlSchedule;
 import org.apache.myfaces.custom.schedule.model.ScheduleDay;
 import org.apache.myfaces.custom.schedule.model.ScheduleEntry;
 import org.apache.myfaces.custom.schedule.util.ScheduleUtil;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.*;
 
 /**
  * <p>
@@ -111,8 +106,8 @@
         HtmlSchedule schedule = (HtmlSchedule) component;
         ResponseWriter writer = context.getResponseWriter();
         String clientId = schedule.getClientId(context);
-        UIForm parentForm = getParentForm(schedule);
-        String formId = parentForm == null ? null : parentForm.getClientId(context);
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
+        String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();
 
         for (Iterator dayIterator = schedule.getModel().iterator(); dayIterator
                 .hasNext();)
@@ -250,7 +245,7 @@
     }
 
     private void writeBackground(FacesContext context, HtmlSchedule schedule,
-            ResponseWriter writer) throws IOException
+                                 ResponseWriter writer) throws IOException
     {
         final int rowHeight = getRowHeight(schedule.getAttributes()) - 1;
         final int headerHeight = rowHeight + 10;
@@ -418,52 +413,52 @@
 
     private int getRenderedStartHour(HtmlSchedule schedule)
     {
-    	int startHour = schedule.getVisibleStartHour();
-        
+        int startHour = schedule.getVisibleStartHour();
+
         //default behaviour: do not auto-expand the schedule to display all
         //entries
         if (!expandToFitEntries(schedule)) return startHour;
-    	
-    	for (Iterator dayIterator = schedule.getModel().iterator(); dayIterator.hasNext();)
-    	{
-    		ScheduleDay day = (ScheduleDay) dayIterator.next();
-    		int dayStart = day.getFirstEventHour();
-    		
-    		if (dayStart < startHour) {
-    			startHour = dayStart;
-    		}
-    	}
 
-    	return startHour;
+        for (Iterator dayIterator = schedule.getModel().iterator(); dayIterator.hasNext();)
+        {
+            ScheduleDay day = (ScheduleDay) dayIterator.next();
+            int dayStart = day.getFirstEventHour();
+
+            if (dayStart < startHour) {
+                startHour = dayStart;
+            }
+        }
+
+        return startHour;
     }
 
     private int getRenderedEndHour(HtmlSchedule schedule)
     {
-    	int endHour = schedule.getVisibleEndHour();
-    	
+        int endHour = schedule.getVisibleEndHour();
+
         //default behaviour: do not auto-expand the schedule to display all
         //entries
         if (!expandToFitEntries(schedule)) return endHour;
 
         for (Iterator dayIterator = schedule.getModel().iterator(); dayIterator.hasNext();)
-    	{
-    		ScheduleDay day = (ScheduleDay) dayIterator.next();
-    		int dayEnd = day.getLastEventHour();
-    		
-    		if (dayEnd > endHour) {
-    			endHour = dayEnd;
-    		}
-    	}
-    	
-    	return endHour;
+        {
+            ScheduleDay day = (ScheduleDay) dayIterator.next();
+            int dayEnd = day.getLastEventHour();
+
+            if (dayEnd > endHour) {
+                endHour = dayEnd;
+            }
+        }
+
+        return endHour;
     }
-    
+
     private void writeEntries(FacesContext context, HtmlSchedule schedule,
-            ScheduleDay day, ResponseWriter writer) throws IOException
+                              ScheduleDay day, ResponseWriter writer) throws IOException
     {
-        final UIForm parentForm = getParentForm(schedule);
         final String clientId = schedule.getClientId(context);
-        final String formId = parentForm == null ? null : parentForm.getClientId(context);
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
+        String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();
 
         TreeSet entrySet = new TreeSet();
 
@@ -585,13 +580,13 @@
     }
 
     private void writeForegroundStart(FacesContext context,
-            HtmlSchedule schedule, ResponseWriter writer) throws IOException
+                                      HtmlSchedule schedule, ResponseWriter writer) throws IOException
     {
         final int rowHeight = getRowHeight(schedule.getAttributes()) - 1;
         final int headerHeight = rowHeight + 10;
         final String clientId = schedule.getClientId(context);
-        final UIForm parentForm = getParentForm(schedule);
-        final String formId = parentForm == null ? null : parentForm.getClientId(context);
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(schedule, context);
+        String formId = parentFormInfo == null ? null : parentFormInfo.getFormName();
 
         writer.startElement(HTML.DIV_ELEM, schedule);
         writer.writeAttribute(HTML.CLASS_ATTR, getStyleClass(schedule,
@@ -685,7 +680,7 @@
         //the dateId is the schedule client id + "_" + yyyyMMdd 
         String day = dateId.substring(dateId.lastIndexOf("_") + 1);
         Date date = ScheduleUtil.getDateFromId(day);
-        
+
         if (date != null) cal.setTime(date);
         cal.set(Calendar.HOUR_OF_DAY, getRenderedStartHour(schedule));
         //OK, we have the date, let's determine the time
@@ -700,7 +695,7 @@
         log.debug("last clicked datetime: " + cal.getTime());
         return cal.getTime();
     }
-    
+
     /**
      * <p>
      * When the start- and endtime of an entry are the same, should the entry
@@ -759,7 +754,7 @@
                 .booleanValue();
     }
 
-    
+
     private class EntryWrapper implements Comparable
     {
         //~ Static fields/initializers -----------------------------------------
@@ -886,7 +881,7 @@
             StringBuffer buffer = new StringBuffer();
 
             boolean entryVisible = height > 0 || renderZeroLengthEntries(schedule);
-            
+
             if (!entryVisible)
             {
                 buffer.append("visibility: hidden; ");

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java Sun Jul 16 17:29:45 2006
@@ -68,6 +68,7 @@
 
     private UIComponent getUIComponent(UIComponent uiComponent)
     {
+        /*todo: checking for UIForm is not enough - Trinidad form, etc.*/
         if (uiComponent instanceof UINamingContainer || uiComponent instanceof UIForm)
         {
             List children = uiComponent.getChildren();

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java Sun Jul 16 17:29:45 2006
@@ -34,6 +34,7 @@
 import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.JavascriptUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
 
@@ -106,8 +107,8 @@
 
         int selectedIndex = tabbedPane.getSelectedIndex();
 
-        UIForm parentForm = RendererUtils.findParentForm(tabbedPane);
-        if (parentForm == null)
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(tabbedPane, facesContext);
+        if (parentFormInfo == null)
         {
             writeFormStart(writer, facesContext, tabbedPane);
         }
@@ -227,7 +228,7 @@
         HtmlRendererUtils.writePrettyLineSeparator(facesContext);
         writer.endElement(HTML.TABLE_ELEM);
 
-        if (parentForm == null)
+        if (parentFormInfo == null)
         {
             writeFormEnd(writer, facesContext);
         }
@@ -539,6 +540,7 @@
 
     private UIComponent getUIComponent(UIComponent uiComponent)
     {
+        /* todo: handle forms other than UIForm */
         if (uiComponent instanceof UIForm || uiComponent instanceof UINamingContainer)
         {
             List children = uiComponent.getChildren();

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlButtonRenderer.java Sun Jul 16 17:29:45 2006
@@ -15,14 +15,13 @@
  */
 package org.apache.myfaces.renderkit.html.ext;
 
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-
 import org.apache.myfaces.renderkit.html.jsf.ExtendedHtmlButtonRenderer;
 import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 
 /**
  * @author Manfred Geiler (latest modification by $Author$)
@@ -31,7 +30,7 @@
 public class HtmlButtonRenderer
     extends ExtendedHtmlButtonRenderer
 {
-    protected void addHiddenCommandParameter(FacesContext facesContext, UIForm nestingForm, String hiddenFieldName)
+    protected void addHiddenCommandParameter(FacesContext facesContext, UIComponent nestingForm, String hiddenFieldName)
 	{
 		if (nestingForm != null)
         {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlButtonRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlButtonRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlButtonRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlButtonRenderer.java Sun Jul 16 17:29:45 2006
@@ -15,14 +15,13 @@
  */
 package org.apache.myfaces.renderkit.html.jsf;
 
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-
 import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlButtonRendererBase;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 
 /**
  * Add dummyForm functionality 
@@ -33,7 +32,7 @@
 public class ExtendedHtmlButtonRenderer
     extends HtmlButtonRendererBase
 {
-    protected void addHiddenCommandParameter(FacesContext facesContext, UIForm nestingForm, String hiddenFieldName)
+    protected void addHiddenCommandParameter(FacesContext facesContext, UIComponent nestingForm, String hiddenFieldName)
 	{
 		if (nestingForm != null)
         {

Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlLinkRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlLinkRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/renderkit/html/jsf/ExtendedHtmlLinkRenderer.java Sun Jul 16 17:29:45 2006
@@ -15,14 +15,13 @@
  */
 package org.apache.myfaces.renderkit.html.jsf;
 
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-
 import org.apache.myfaces.renderkit.html.util.DummyFormUtils;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlLinkRendererBase;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
 /**
  * Add dummyForm functionality
  * 
@@ -32,7 +31,7 @@
 public class ExtendedHtmlLinkRenderer
         extends HtmlLinkRendererBase
 {
-	protected void addHiddenCommandParameter(FacesContext facesContext, UIForm nestingForm, String hiddenFieldName)
+	protected void addHiddenCommandParameter(FacesContext facesContext, UIComponent nestingForm, String hiddenFieldName)
 	{
 		if (nestingForm != null)
 	    {

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/statechangednotifier/StateChangedNotifierRenderer.java Sun Jul 16 17:29:45 2006
@@ -24,6 +24,7 @@
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 import javax.faces.convert.ConverterException;
+import javax.faces.FacesException;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.myfaces.custom.dojo.DojoConfig;
@@ -36,6 +37,7 @@
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
 import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
 
 /**
@@ -86,8 +88,11 @@
         String replacedClientId = notifierClientId.replaceAll(":", "_");
         String initFunctionName = "init_" + replacedClientId;
 
-        UIForm form   = getParentForm(notifier);
-        String formId = form.getClientId(facesContext);
+        FormInfo formInfo   = RendererUtils.findNestingForm(notifier,facesContext);
+        if(formInfo == null)
+            throw new FacesException("StateChangedNotifier must be embedded in a form.");
+
+        String formId = formInfo.getFormName();
 
         String notifierVar = replacedClientId + "Notifier";
 
@@ -110,24 +115,6 @@
 
         AddResource addResource = AddResourceFactory.getInstance(facesContext);
         addResource.addInlineScriptAtPosition(facesContext, AddResource.HEADER_BEGIN, sb.toString());
-    }
-
-    /**
-     * Get the parent UIForm. If no parent is a UIForm then returns null.
-     *
-     * @param component
-     * @return UIForm
-     */
-    private UIForm getParentForm(UIComponent component) {
-
-        // See if we are in a form
-        UIComponent parent = component.getParent();
-
-        while ((parent != null) && !(parent instanceof UIForm)) {
-            parent = parent.getParent();
-        }
-
-        return (UIForm) parent;
     }
 
     private void renderInitialization(FacesContext facesContext, UIComponent uiComponent, StateChangedNotifier notifier)

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/subform/SubFormRenderer.java Sun Jul 16 17:29:45 2006
@@ -15,17 +15,17 @@
  */
 package org.apache.myfaces.custom.subform;
 
-import java.io.IOException;
-import java.util.Map;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.util.FormInfo;
 
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
-
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
-import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import java.io.IOException;
+import java.util.Map;
 
 /**
  * @author Gerald Muellan
@@ -47,8 +47,11 @@
         writer.startElement(HTML.SCRIPT_ELEM, null);
         writer.writeAttribute(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_ATTR, org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_TYPE_TEXT_JAVASCRIPT, null);
 
-        UIForm parentForm = findParentForm(component);
-        writer.writeText(createPartialSubmitJS(component.getId(), parentForm.getClientId(context)), null);
+        FormInfo parentFormInfo = RendererUtils.findNestingForm(component,context);
+        if(parentFormInfo!=null)
+        {
+            writer.writeText(createPartialSubmitJS(component.getId(), parentFormInfo.getFormName()), null);
+        }
 
         writer.endElement(org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SCRIPT_ELEM);
         HtmlRendererUtils.writePrettyLineSeparator(context);
@@ -87,16 +90,4 @@
         return script.toString();
     }
 
-    /**
-     * 
-     */
-    protected UIForm findParentForm(UIComponent component)
-    {
-        UIComponent parentComponent = component.getParent();
-        while (!(parentComponent instanceof UIForm))
-        {
-            parentComponent = parentComponent.getParent();
-        }
-        return (UIForm) parentComponent;
-    }
 }

Modified: myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java?rev=422578&r1=422577&r2=422578&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java (original)
+++ myfaces/tomahawk/trunk/sandbox/examples/src/main/java/org/apache/myfaces/examples/inputAjax/InputAjaxBean.java Sun Jul 16 17:29:45 2006
@@ -21,7 +21,7 @@
 
 import javax.faces.application.FacesMessage;
 import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
+import javax.faces.component.EditableValueHolder;
 import javax.faces.context.FacesContext;
 import javax.faces.model.SelectItem;
 
@@ -67,7 +67,7 @@
             String valStr = (String) value;
             if (valStr.length() < 3)
             {
-                ((UIInput) toValidate).setValid(false);
+                ((EditableValueHolder) toValidate).setValid(false);
                 context.addMessage(toValidate.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, "Text must be longer than 3 characters", null));
             }
         }
@@ -81,7 +81,7 @@
             String valStr = (String) value;
             if (valStr.length() > 5)
             {
-                ((UIInput) toValidate).setValid(false);
+                ((EditableValueHolder) toValidate).setValid(false);
                 context.addMessage(toValidate.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, "Length must be smaller than 5 characters", null));
             }
         }
@@ -95,7 +95,7 @@
             String valStr = (String) value;
             if (valStr.length() < 5)
             {
-                ((UIInput) toValidate).setValid(false);
+                ((EditableValueHolder) toValidate).setValid(false);
                 context.addMessage(toValidate.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, "Length must be longer than 5 characters", null));
             }
         }
@@ -108,7 +108,7 @@
             String valStr = (String) value;
             if (valStr.indexOf(" ") != -1)
             {
-                ((UIInput) toValidate).setValid(false);
+                ((EditableValueHolder) toValidate).setValid(false);
                 context.addMessage(toValidate.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, "Cannot contain a space", null));
             }
         }