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 2005/05/22 19:54:02 UTC

svn commit: r171350 - /myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java /myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java

Author: mmarinschek
Date: Sun May 22 10:54:01 2005
New Revision: 171350

URL: http://svn.apache.org/viewcvs?rev=171350&view=rev
Log:
HtmlPanelTabbedPane fixes by Philipp Ahlner.

Modified:
    myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java
    myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java

Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java?rev=171350&r1=171349&r2=171350&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlPanelTabbedPane.java Sun May 22 10:54:01 2005
@@ -50,32 +50,21 @@
     }
 
     public void processDecodes(javax.faces.context.FacesContext context)
-    {
-        if (context == null) throw new NullPointerException("context");
-        decode(context);
+   {
+       if (context == null) throw new NullPointerException("context");
+       decode(context);
 
-        int tabIdx = 0;
-        int selectedIndex = getSelectedIndex();
+       int tabIdx = 0;
+       int selectedIndex = getSelectedIndex();
 
-        Iterator it = getFacetsAndChildren();
+       Iterator it = getFacetsAndChildren();
 
-        while (it.hasNext())
-        {
-            UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
-            if (childOrFacet instanceof HtmlPanelTab)
-            {
-                if (tabIdx == selectedIndex)
-                {
-                    childOrFacet.processDecodes(context);
-                }
-                tabIdx++;
-            }
-            else
-            {
-                childOrFacet.processDecodes(context);
-            }
-        }
-    }
+       while (it.hasNext())
+       {
+           UIComponent childOrFacet = getUIComponent((UIComponent) it.next());
+           childOrFacet.processDecodes(context);
+       }
+   }
 
     private UIComponent getUIComponent(UIComponent uiComponent)
     {

Modified: myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java?rev=171350&r1=171349&r2=171350&view=diff
==============================================================================
--- myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java (original)
+++ myfaces/trunk/src/components/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java Sun May 22 10:54:01 2005
@@ -22,16 +22,15 @@
 import org.apache.myfaces.component.UserRoleUtils;
 
 import javax.faces.application.ViewHandler;
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIViewRoot;
-import javax.faces.component.UINamingContainer;
+import javax.faces.component.*;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
+import javax.faces.convert.Converter;
+import javax.faces.FacesException;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
+import java.util.Iterator;
 
 /**
  * @author Manfred Geiler (latest modification by $Author$)
@@ -226,7 +225,6 @@
         }
     }
 
-
     protected void writeFormStart(ResponseWriter writer,
                                   FacesContext facesContext,
                                   UIComponent tabbedPane)
@@ -383,41 +381,40 @@
     }
 
 
-    protected void writeTabCell(ResponseWriter writer,
-                                FacesContext facesContext,
-                                HtmlPanelTabbedPane tabbedPane,
-                                int tabCount,
-                                int selectedIndex)
-        throws IOException
-    {
-        HtmlRendererUtils.writePrettyLineSeparator(facesContext);
-        HtmlRendererUtils.writePrettyIndent(facesContext);
-        writer.startElement(HTML.TD_ELEM, tabbedPane);
-        writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString(tabCount + 1), null);
-        writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE + "background-color:" + tabbedPane.getBgcolor(), null);
-        HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane, "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
-
-        int tabIdx = 0;
-        List children = tabbedPane.getChildren();
-        for (int i = 0, len = children.size(); i < len; i++)
-        {
-            UIComponent child = getUIComponent((UIComponent)children.get(i));
-            if (child instanceof HtmlPanelTab)
-            {
-                if (tabIdx == selectedIndex)
-                {
-                    RendererUtils.renderChild(facesContext, child);
-                }
-                tabIdx++;
-            }
-            else
-            {
-                RendererUtils.renderChild(facesContext, child);
-            }
-        }
+    protected void writeTabCell(ResponseWriter writer, FacesContext facesContext, HtmlPanelTabbedPane tabbedPane,
+           int tabCount, int selectedIndex) throws IOException {
+       HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+       HtmlRendererUtils.writePrettyIndent(facesContext);
+       writer.startElement(HTML.TD_ELEM, tabbedPane);
+       writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString(tabCount + 1), null);
+       writer.writeAttribute(HTML.STYLE_ATTR, TAB_CELL_STYLE + "background-color:" + tabbedPane.getBgcolor(), null);
+       HtmlRendererUtils.renderHTMLAttribute(writer, tabbedPane, "tabContentStyleClass", HTML.STYLE_CLASS_ATTR);
+
+       int tabIdx = 0;
+       List children = tabbedPane.getChildren();
+       for (int i = 0, len = children.size(); i < len; i++) {
+           UIComponent child = getUIComponent((UIComponent) children.get(i));
+           if (child instanceof HtmlPanelTab) {
+               // the inactive tabs are hidden with a div-tag
+               if (tabIdx != selectedIndex) {
+                   writer.startElement(HTML.DIV_ELEM, tabbedPane);
+                   writer.writeAttribute(HTML.STYLE_ATTR, "display:none", null);
+                   RendererUtils.renderChild(facesContext, child);
+                   writer.endElement(HTML.DIV_ELEM);
+               }
+               else
+               {
+                   RendererUtils.renderChild(facesContext, child);
+               }
+
+               tabIdx++;
+           } else {
+               RendererUtils.renderChild(facesContext, child);
+           }
+       }
 
-        writer.endElement(HTML.TD_ELEM);
-    }
+       writer.endElement(HTML.TD_ELEM);
+   }
 
     private UIComponent getUIComponent(UIComponent uiComponent)
     {