You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2010/04/27 06:20:19 UTC
svn commit: r938319 [2/3] - in
/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces: component/
component/html/ext/ custom/calendar/ custom/collapsiblepanel/
custom/column/ custom/datalist/ custom/date/ custom/div/ custom/layout/
custom/navi...
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/AbstractDiv.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/AbstractDiv.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/AbstractDiv.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/AbstractDiv.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.div;
+
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.custom.htmlTag.HtmlTag;
+
+/**
+ * Places a div around its children. Unless otherwise specified,
+ * all attributes accept static values or EL expressions.
+ *
+ * @JSFComponent
+ * name = "t:div"
+ * class = "org.apache.myfaces.custom.div.Div"
+ * tagClass = "org.apache.myfaces.custom.div.DivTag"
+ * @since 1.1.7
+ * @author bdudney (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractDiv extends HtmlTag implements EventAware, UniversalProperties, ClientBehaviorHolder
+{
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.Div";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DivRenderer";
+
+ /**
+ * @JSFProperty
+ * tagExcluded = "true"
+ */
+ public Object getValue()
+ {
+ return "div";
+ }
+}
\ No newline at end of file
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/DivRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/DivRenderer.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/DivRenderer.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/div/DivRenderer.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.div;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+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.custom.htmlTag.HtmlTagRenderer;
+
+/**
+ * @JSFRenderer
+ * renderKitId = "HTML_BASIC"
+ * family = "javax.faces.Output"
+ * type = "org.apache.myfaces.DivRenderer"
+ * @since 1.1.7
+ * @author bdudney (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691871 $ $Date: 2008-09-03 23:32:08 -0500 (mié, 03 sep 2008) $
+ */
+public class DivRenderer extends HtmlTagRenderer
+{
+ public static final String RENDERER_TYPE = "org.apache.myfaces.HtmlTagRenderer";
+
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException
+ {
+ if ((context == null) || (component == null))
+ {
+ throw new NullPointerException();
+ }
+
+ super.encodeBegin(context, component);
+
+ Div div = (Div) component;
+
+ if (div.isRendered())
+ {
+ ResponseWriter writer = context.getResponseWriter();
+ //Previously, style and styleClass was rendered,
+ //so on div renderer we need to add event and universal
+ //attributes only
+
+ Map<String, List<ClientBehavior>> behaviors = div.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE);
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(context, writer, component, behaviors);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, div,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/AbstractHtmlPanelLayout.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/AbstractHtmlPanelLayout.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/AbstractHtmlPanelLayout.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/AbstractHtmlPanelLayout.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.layout;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.component.html.HtmlPanelGroup;
+
+import org.apache.myfaces.component.AlignProperty;
+import org.apache.myfaces.component.DataProperties;
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.PanelProperties;
+import org.apache.myfaces.component.UniversalProperties;
+
+/**
+ * Determines where its children are positioned within the page
+ * relative to each other, similar to a Swing layout component.
+ *
+ * Unless otherwise specified, all attributes accept static values
+ * or EL expressions.
+ *
+ * @JSFComponent
+ * name = "t:panelLayout"
+ * class = "org.apache.myfaces.custom.layout.HtmlPanelLayout"
+ * tagClass = "org.apache.myfaces.custom.layout.HtmlPanelLayoutTag"
+ * @since 1.1.7
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractHtmlPanelLayout
+ extends HtmlPanelGroup implements
+ AlignProperty, UniversalProperties, EventAware, DataProperties,
+ PanelProperties, ClientBehaviorHolder
+{
+ //private static final Log log = LogFactory.getLog(HtmlPanelLayout.class);
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelLayout";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Layout";
+
+ private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
+ private static final String DEFAULT_LAYOUT = "classic";
+
+ // typesafe facet getters
+
+ /**
+ * @JSFFacet
+ */
+ public UIComponent getHeader()
+ {
+ return (UIComponent)getFacet("header");
+ }
+
+ /**
+ * @JSFFacet
+ */
+ public UIComponent getNavigation()
+ {
+ return (UIComponent)getFacet("navigation");
+ }
+
+ /**
+ * @JSFFacet
+ */
+ public UIComponent getBody()
+ {
+ return (UIComponent)getFacet("body");
+ }
+
+ /**
+ * @JSFFacet
+ */
+ public UIComponent getFooter()
+ {
+ return (UIComponent)getFacet("footer");
+ }
+
+ /**
+ * The CSS class to be applied to footer cells.
+ *
+ * @JSFProperty
+ */
+ public abstract String getFooterClass();
+
+ /**
+ * The CSS class to be applied to header cells.
+ *
+ * @JSFProperty
+ */
+ public abstract String getHeaderClass();
+
+ /**
+ * <pre>
+ * layout | header | navigation | body | footer
+ * =================|========|============|=======|========
+ * classic (Default)| top | left | right | bottom
+ * navigationRight | top | right | left | bottom
+ * upsideDown | bottom | left | right | top
+ * </pre>
+ *
+ * @JSFProperty
+ * defaultValue="classic"
+ */
+ public abstract String getLayout();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getNavigationClass();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getBodyClass();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getHeaderStyle();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getNavigationStyle();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getBodyStyle();
+
+ /**
+ * CSS class to be used for the table cell.
+ *
+ * @JSFProperty
+ */
+ public abstract String getFooterStyle();
+
+}
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/HtmlLayoutRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/HtmlLayoutRenderer.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/HtmlLayoutRenderer.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/layout/HtmlLayoutRenderer.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.layout;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+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.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;
+
+/**
+ * @JSFRenderer
+ * renderKitId = "HTML_BASIC"
+ * family = "javax.faces.Panel"
+ * type = "org.apache.myfaces.Layout"
+ *
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 659874 $ $Date: 2008-05-24 15:59:15 -0500 (sáb, 24 may 2008) $
+ */
+public class HtmlLayoutRenderer
+ extends HtmlRenderer
+{
+ private static final Log log = LogFactory.getLog(HtmlLayoutRenderer.class);
+
+ public static final String CLASSIC_LAYOUT = "classic";
+ public static final String NAV_RIGHT_LAYOUT = "navigationRight";
+ public static final String UPSIDE_DOWN_LAYOUT = "upsideDown";
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ public void encodeBegin(FacesContext context, UIComponent component) throws IOException
+ {
+ }
+
+ public void encodeChildren(FacesContext context, UIComponent component) throws IOException
+ {
+ }
+
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ RendererUtils.checkParamValidity(facesContext, component, HtmlPanelLayout.class);
+
+ HtmlPanelLayout panelLayout = (HtmlPanelLayout)component;
+
+ String layout = panelLayout.getLayout();
+ if (layout == null || layout.equals(CLASSIC_LAYOUT))
+ {
+ renderClassic(facesContext, panelLayout);
+ }
+ else if (layout.equals(NAV_RIGHT_LAYOUT))
+ {
+ renderNavRight(facesContext, panelLayout);
+ }
+ else if (layout.equals(UPSIDE_DOWN_LAYOUT))
+ {
+ renderUpsideDown(facesContext, panelLayout);
+ }
+ else
+ {
+ log.error("Unknown panel layout '" + layout + "'!");
+ }
+
+ if (panelLayout.getChildCount() > 0)
+ {
+ log.error("PanelLayout must not have children, only facets allowed!");
+ }
+ }
+
+ protected void renderClassic(FacesContext facesContext, HtmlPanelLayout panelLayout)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ UIComponent header = panelLayout.getHeader();
+ UIComponent navigation = panelLayout.getNavigation();
+ UIComponent body = panelLayout.getBody();
+ UIComponent footer = panelLayout.getFooter();
+
+ writer.startElement(HTML.TABLE_ELEM, panelLayout);
+
+ Map<String, List<ClientBehavior>> behaviors = panelLayout.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelLayout, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
+ if (header != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, header,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getHeaderClass(),
+ panelLayout.getHeaderStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (navigation != null || body != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ if (navigation != null)
+ {
+ renderTableCell(facesContext, writer, navigation, 0,
+ panelLayout.getNavigationClass(),
+ panelLayout.getNavigationStyle());
+ }
+ if (body != null)
+ {
+ renderTableCell(facesContext, writer, body, 0,
+ panelLayout.getBodyClass(),
+ panelLayout.getBodyStyle());
+ }
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (footer != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, footer,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getFooterClass(),
+ panelLayout.getFooterStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ writer.endElement(HTML.TABLE_ELEM);
+ }
+
+
+ protected void renderNavRight(FacesContext facesContext, HtmlPanelLayout panelLayout)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ UIComponent header = panelLayout.getHeader();
+ UIComponent navigation = panelLayout.getNavigation();
+ UIComponent body = panelLayout.getBody();
+ UIComponent footer = panelLayout.getFooter();
+
+ writer.startElement(HTML.TABLE_ELEM, panelLayout);
+ Map<String, List<ClientBehavior>> behaviors = panelLayout.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelLayout, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
+ if (header != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, header,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getHeaderClass(),
+ panelLayout.getHeaderStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (navigation != null || body != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ if (body != null)
+ {
+ renderTableCell(facesContext, writer, body, 0,
+ panelLayout.getBodyClass(),
+ panelLayout.getBodyStyle());
+ }
+ if (navigation != null)
+ {
+ renderTableCell(facesContext, writer, navigation, 0,
+ panelLayout.getNavigationClass(),
+ panelLayout.getNavigationStyle());
+ }
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (footer != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, footer,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getFooterClass(),
+ panelLayout.getFooterStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ writer.endElement(HTML.TABLE_ELEM);
+ }
+
+
+ protected void renderUpsideDown(FacesContext facesContext, HtmlPanelLayout panelLayout)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+ UIComponent header = panelLayout.getHeader();
+ UIComponent navigation = panelLayout.getNavigation();
+ UIComponent body = panelLayout.getBody();
+ UIComponent footer = panelLayout.getFooter();
+
+ writer.startElement(HTML.TABLE_ELEM, panelLayout);
+ Map<String, List<ClientBehavior>> behaviors = panelLayout.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelLayout, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelLayout, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
+ if (footer != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, footer,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getFooterClass(),
+ panelLayout.getFooterStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (navigation != null || body != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ if (navigation != null)
+ {
+ renderTableCell(facesContext, writer, navigation, 0,
+ panelLayout.getNavigationClass(),
+ panelLayout.getNavigationStyle());
+ }
+ if (body != null)
+ {
+ renderTableCell(facesContext, writer, body, 0,
+ panelLayout.getBodyClass(),
+ panelLayout.getBodyStyle());
+ }
+ writer.endElement(HTML.TR_ELEM);
+ }
+ if (header != null)
+ {
+ writer.startElement(HTML.TR_ELEM, panelLayout);
+ renderTableCell(facesContext, writer, header,
+ (navigation != null && body != null) ? 2 : 1,
+ panelLayout.getHeaderClass(),
+ panelLayout.getHeaderStyle());
+ writer.endElement(HTML.TR_ELEM);
+ }
+ writer.endElement(HTML.TABLE_ELEM);
+ }
+
+
+ protected void renderTableCell(FacesContext facesContext,
+ ResponseWriter writer,
+ UIComponent component,
+ int colspan,
+ String styleClass,
+ String style)
+ throws IOException
+ {
+ writer.startElement(HTML.TD_ELEM, component);
+ if (colspan > 0)
+ {
+ writer.writeAttribute(HTML.COLSPAN_ATTR, Integer.toString(colspan), null);
+ }
+ if (styleClass != null)
+ {
+ writer.writeAttribute(HTML.CLASS_ATTR, styleClass, null);
+ }
+ if (style != null)
+ {
+ writer.writeAttribute(HTML.STYLE_ATTR, style, null);
+ }
+
+ RendererUtils.renderChild(facesContext, component);
+
+ writer.endElement(HTML.TD_ELEM);
+ }
+
+}
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/AbstractHtmlPanelNavigation.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/AbstractHtmlPanelNavigation.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/AbstractHtmlPanelNavigation.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/AbstractHtmlPanelNavigation.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.navigation;
+
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.component.html.HtmlPanelGroup;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFComponent;
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFProperty;
+import org.apache.myfaces.component.AlignProperty;
+import org.apache.myfaces.component.DataProperties;
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.PanelProperties;
+import org.apache.myfaces.component.UniversalProperties;
+
+/**
+ *
+ * Renders a vertical menu structure with support for nested menu
+ * items. Unless otherwise specified, all attributes accept
+ * static values or EL expressions.
+ *
+ * Panel, that includes navigation items ({@link HtmlCommandNavigation}) and other
+ * components (separators).
+ *
+ * @since 1.1.7
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691871 $ $Date: 2008-09-03 23:32:08 -0500 (mié, 03 sep 2008) $
+ */
+@JSFComponent(
+ name = "t:panelNavigation",
+ clazz = "org.apache.myfaces.custom.navigation.HtmlPanelNavigation",
+ tagClass = "org.apache.myfaces.custom.navigation.HtmlPanelNavigationTag")
+public abstract class AbstractHtmlPanelNavigation
+ extends HtmlPanelGroup implements AlignProperty,
+ UniversalProperties, EventAware, DataProperties, PanelProperties, ClientBehaviorHolder
+{
+ private static final Log log = LogFactory.getLog(AbstractHtmlPanelNavigation.class);
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelNavigation";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Navigation";
+
+ private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
+
+ private static final String PREVIOUS_VIEW_ROOT = AbstractHtmlPanelNavigation.class.getName() + ".PREVIOUS_VIEW_ROOT";
+ private boolean _itemOpenActiveStatesRestored = false;
+
+ public void decode(FacesContext context)
+ {
+ super.decode(context); //To change body of overridden methods use File | Settings | File Templates.
+
+ //Save the current view root for later reference...
+ context.getExternalContext().getRequestMap().put(PREVIOUS_VIEW_ROOT, context.getViewRoot());
+ //...and remember that this instance needs NO special treatment on rendering:
+ _itemOpenActiveStatesRestored = true;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ if (!_itemOpenActiveStatesRestored && getChildCount() > 0)
+ {
+ UIViewRoot previousRoot = (UIViewRoot)context.getExternalContext().getRequestMap().get(PREVIOUS_VIEW_ROOT);
+ if (previousRoot != null)
+ {
+ restoreOpenActiveStates(context, previousRoot, getChildren());
+ }
+ else
+ {
+ //no previous root, means no decode was done
+ //--> a new request
+ }
+ }
+
+ super.encodeBegin(context); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void restoreOpenActiveStates(FacesContext facesContext,
+ UIViewRoot previousRoot,
+ List children)
+ {
+ for (Iterator it = children.iterator(); it.hasNext(); )
+ {
+ UIComponent child = (UIComponent)it.next();
+ if (child instanceof HtmlCommandNavigation)
+ {
+ HtmlCommandNavigation previousItem = (HtmlCommandNavigation)previousRoot.findComponent(child.getClientId(facesContext));
+ if (previousItem != null)
+ {
+
+ HtmlCommandNavigation childItem = (HtmlCommandNavigation)child;
+ if(previousItem.getOpenDirectly()!=null)
+ {
+ childItem.setOpen(previousItem.isOpen());
+ }
+ else if(previousItem.getValueExpression("open")!=null)
+ {
+ childItem.setValueExpression("open",previousItem.getValueExpression("open"));
+ }
+
+ if(previousItem.getActiveDirectly()!=null)
+ {
+ childItem.setActive(previousItem.isActive());
+ }
+ else if(previousItem.getValueExpression("active")!=null)
+ {
+ childItem.setValueExpression("active",previousItem.getValueExpression("active"));
+ }
+ }
+ else
+ {
+ log.error("Navigation item " + child.getClientId(facesContext) + " not found in previous view.");
+ }
+ if (child.getChildCount() > 0)
+ {
+ restoreOpenActiveStates(facesContext, previousRoot, child.getChildren());
+ }
+ }
+ }
+ }
+
+ /**
+ * The CSS class of closed navigation items.
+ *
+ */
+ @JSFProperty
+ public abstract String getItemClass();
+
+ /**
+ * The CSS class of open navigation items.
+ *
+ */
+ @JSFProperty
+ public abstract String getOpenItemClass();
+
+ /**
+ * The CSS class of the active navigation item.
+ *
+ */
+ @JSFProperty
+ public abstract String getActiveItemClass();
+
+ /**
+ * The CSS class for the td element of a separator.
+ *
+ */
+ @JSFProperty
+ public abstract String getSeparatorClass();
+
+ /**
+ * The CSS Style of closed navigation items.
+ *
+ */
+ @JSFProperty
+ public abstract String getItemStyle();
+
+ /**
+ * The CSS Style of open navigation items.
+ *
+ */
+ @JSFProperty
+ public abstract String getOpenItemStyle();
+
+ /**
+ * The CSS Style of the active navigation item.
+ *
+ */
+ @JSFProperty
+ public abstract String getActiveItemStyle();
+
+ /**
+ * The CSS Style for the td element of a separator.
+ *
+ */
+ @JSFProperty
+ public abstract String getSeparatorStyle();
+
+}
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/HtmlNavigationRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/HtmlNavigationRenderer.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/HtmlNavigationRenderer.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navigation/HtmlNavigationRenderer.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,348 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.navigation;
+
+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.HtmlRendererUtils;
+import org.apache.myfaces.renderkit.html.ext.HtmlLinkRenderer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @JSFRenderer
+ * renderKitId = "HTML_BASIC"
+ * family = "javax.faces.Panel"
+ * type = "org.apache.myfaces.Navigation"
+ *
+ * @JSFRenderer
+ * renderKitId = "HTML_BASIC"
+ * family = "javax.faces.Command"
+ * type = "org.apache.myfaces.Navigation"
+ *
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 659874 $ $Date: 2008-05-24 15:59:15 -0500 (sáb, 24 may 2008) $
+ */
+public class HtmlNavigationRenderer
+ extends HtmlLinkRenderer
+{
+ private static final Log log = LogFactory.getLog(HtmlNavigationRenderer.class);
+
+ private static final Integer ZERO_INTEGER = new Integer(0);
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ if (component instanceof HtmlCommandNavigation)
+ {
+ //HtmlCommandNavigation
+ super.decode(facesContext, component);
+ }
+ }
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ if (component instanceof HtmlCommandNavigation)
+ {
+ //HtmlCommandNavigation
+ super.encodeBegin(facesContext, component);
+ }
+ }
+
+ public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ if (component instanceof HtmlCommandNavigation)
+ {
+ //HtmlCommandNavigation
+ super.encodeChildren(facesContext, component);
+ }
+ }
+
+ public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
+ {
+ if (component instanceof HtmlCommandNavigation)
+ {
+ //HtmlCommandNavigation
+ super.encodeEnd(facesContext, component);
+ return;
+ }
+
+ RendererUtils.checkParamValidity(facesContext, component, HtmlPanelNavigation.class);
+ ResponseWriter writer = facesContext.getResponseWriter();
+ HtmlPanelNavigation panelNav = (HtmlPanelNavigation)component;
+
+ if (panelNav.getChildCount() > 0)
+ {
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.startElement(HTML.TABLE_ELEM, component);
+ Map<String, List<ClientBehavior>> behaviors = panelNav.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelNav, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
+
+ boolean isBorderAlreadyDefined = component.getAttributes().containsKey(HTML.BORDER_ATTR);
+
+ if (panelNav.getStyle() == null && panelNav.getStyleClass() == null && !isBorderAlreadyDefined)
+ {
+ writer.writeAttribute(HTML.BORDER_ATTR, ZERO_INTEGER, null);
+ }
+
+ renderChildren(facesContext, writer, panelNav, panelNav.getChildren(), 0);
+
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+ writer.endElement(HTML.TABLE_ELEM);
+ }
+ else
+ {
+ if (log.isWarnEnabled()) log.warn("Navigation panel without children.");
+ }
+ }
+
+
+ protected void renderChildren(FacesContext facesContext,
+ ResponseWriter writer,
+ HtmlPanelNavigation panelNav,
+ List children,
+ int level)
+ throws IOException
+ {
+ for (Iterator it = children.iterator(); it.hasNext(); )
+ {
+ UIComponent child = (UIComponent)it.next();
+ if (!child.isRendered()) continue;
+ if (child instanceof HtmlCommandNavigation)
+ {
+ //navigation item
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+
+ String style = getNavigationItemStyle(panelNav, (HtmlCommandNavigation)child);
+ String styleClass = getNavigationItemClass(panelNav, (HtmlCommandNavigation)child);
+
+ writer.startElement(HTML.TR_ELEM, panelNav);
+ writer.startElement(HTML.TD_ELEM, panelNav);
+ writeStyleAttributes(writer, style, styleClass);
+
+ if (style != null || styleClass != null)
+ {
+ writer.startElement(HTML.SPAN_ELEM, panelNav);
+ writeStyleAttributes(writer, style, styleClass);
+ }
+ indent(writer, level);
+ child.encodeBegin(facesContext);
+ child.encodeEnd(facesContext);
+ if (style != null || styleClass != null)
+ {
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+
+ if (child.getChildCount() > 0)
+ {
+ renderChildren(facesContext, writer, panelNav, child.getChildren(), level + 1);
+ }
+ }
+ else
+ {
+ //separator
+ HtmlRendererUtils.writePrettyLineSeparator(facesContext);
+
+ String style = panelNav.getSeparatorStyle();
+ String styleClass = panelNav.getSeparatorClass();
+
+ writer.startElement(HTML.TR_ELEM, panelNav);
+ writer.startElement(HTML.TD_ELEM, panelNav);
+ writeStyleAttributes(writer, style, styleClass);
+
+ if (style != null || styleClass != null)
+ {
+ writer.startElement(HTML.SPAN_ELEM, panelNav);
+ writeStyleAttributes(writer, style, styleClass);
+ }
+ indent(writer, level);
+ RendererUtils.renderChild(facesContext, child);
+ if (style != null || styleClass != null)
+ {
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+ }
+
+ }
+ }
+
+
+ protected void indent(ResponseWriter writer, int level)
+ throws IOException
+ {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < level; i++)
+ {
+ buf.append("    ");
+ }
+ writer.write(buf.toString());
+ }
+
+
+
+ protected String getNavigationItemStyle(HtmlPanelNavigation navPanel,
+ HtmlCommandNavigation navItem)
+ {
+ if (navItem.isActive())
+ {
+ return navPanel.getActiveItemStyle();
+ }
+ else if (navItem.isOpen())
+ {
+ return navPanel.getOpenItemStyle();
+ }
+ else
+ {
+ return navPanel.getItemStyle();
+ }
+ }
+
+ protected String getNavigationItemClass(HtmlPanelNavigation navPanel,
+ HtmlCommandNavigation navItem)
+ {
+ // MYFACES-117, if a styleClass is supplied for a HtmlCommandNavigation,
+ // panelNavigation active/open/normal styles for items will be overriden
+ if (navItem.getStyleClass() != null)
+ {
+ return navItem.getStyleClass();
+ }
+
+ if (navItem.isActive())
+ {
+ return navPanel.getActiveItemClass();
+ }
+ else if (navItem.isOpen())
+ {
+ return navPanel.getOpenItemClass();
+ }
+ else
+ {
+ return navPanel.getItemClass();
+ }
+ }
+
+
+
+ protected void writeStyleAttributes(ResponseWriter writer,
+ String style,
+ String styleClass)
+ throws IOException
+ {
+ HtmlRendererUtils.renderHTMLAttribute(writer, HTML.STYLE_ATTR, HTML.STYLE_ATTR, style);
+ HtmlRendererUtils.renderHTMLAttribute(writer, HTML.STYLE_CLASS_ATTR, HTML.STYLE_CLASS_ATTR, styleClass);
+ }
+
+
+ protected String getStyle(FacesContext facesContext, UIComponent link)
+ {
+ if (!(link instanceof HtmlCommandNavigation))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ UIComponent navPanel = link.getParent();
+ while (navPanel != null && !(navPanel instanceof HtmlPanelNavigation))
+ {
+ navPanel = navPanel.getParent();
+ }
+ if (navPanel == null)
+ {
+ throw new IllegalStateException("HtmlCommandNavigation not nested in HtmlPanelNavigation!?");
+ }
+
+ HtmlCommandNavigation navItem = (HtmlCommandNavigation)link;
+ if (navItem.isActive())
+ {
+ return ((HtmlPanelNavigation)navPanel).getActiveItemStyle();
+ }
+ else if (navItem.isOpen())
+ {
+ return ((HtmlPanelNavigation)navPanel).getOpenItemStyle();
+ }
+ else
+ {
+ return ((HtmlPanelNavigation)navPanel).getItemStyle();
+ }
+ }
+
+
+ protected String getStyleClass(FacesContext facesContext, UIComponent link)
+ {
+ if (!(link instanceof HtmlCommandNavigation))
+ {
+ throw new IllegalArgumentException();
+ }
+
+ UIComponent navPanel = link.getParent();
+ while (navPanel != null && !(navPanel instanceof HtmlPanelNavigation))
+ {
+ navPanel = navPanel.getParent();
+ }
+ if (navPanel == null)
+ {
+ throw new IllegalStateException("HtmlCommandNavigation not nested in HtmlPanelNavigation!?");
+ }
+
+ HtmlCommandNavigation navItem = (HtmlCommandNavigation)link;
+ if (navItem.isActive())
+ {
+ return ((HtmlPanelNavigation)navPanel).getActiveItemClass();
+ }
+ else if (navItem.isOpen())
+ {
+ return ((HtmlPanelNavigation)navPanel).getOpenItemClass();
+ }
+ else
+ {
+ return ((HtmlPanelNavigation)navPanel).getItemClass();
+ }
+ }
+
+
+
+}
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/AbstractHtmlPanelNavigationMenu.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/AbstractHtmlPanelNavigationMenu.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/AbstractHtmlPanelNavigationMenu.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/AbstractHtmlPanelNavigationMenu.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,246 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.navmenu.htmlnavmenu;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.AlignProperty;
+import org.apache.myfaces.component.DataProperties;
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.PanelProperties;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
+
+/**
+ * Renders a vertical menu structure with support for nested menu items.
+ *
+ * The menu is rendered as unordered List. The menu-tree can be
+ * dynamically build using NavigationMenuItem(s).
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * Many thanks to the guys from Swiss Federal Institute of Intellectual Property and Marc Bouquet
+ * for helping to develop this component.
+ *
+ * @JSFComponent
+ * name = "t:panelNavigation2"
+ * class = "org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlPanelNavigationMenu"
+ * tagClass = "org.apache.myfaces.custom.navmenu.htmlnavmenu.HtmlPanelNavigationMenuTag"
+ * @since 1.1.7
+ * @author Manfred Geiler
+ * @author Thomas Spiegl
+ */
+public abstract class AbstractHtmlPanelNavigationMenu extends HtmlPanelGroup
+ implements NamingContainer, UniversalProperties, EventAware,
+ PanelProperties, AlignProperty, DataProperties, ClientBehaviorHolder
+{
+ private static final Log log = LogFactory.getLog(AbstractHtmlPanelNavigationMenu.class);
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelNavigationMenu";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.NavigationMenu";
+
+ static final String PREVIOUS_VIEW_ROOT = AbstractHtmlPanelNavigationMenu.class.getName() + ".PREVIOUS_VIEW_ROOT";
+ private static final int DEFAULT_BORDER = Integer.MIN_VALUE;
+
+ private boolean _itemOpenActiveStatesRestored = false;
+
+ public void decode(FacesContext context)
+ {
+ super.decode(context); //To change body of overridden methods use File | Settings | File Templates.
+
+ //Save the current view root for later reference...
+ context.getExternalContext().getRequestMap().put(PREVIOUS_VIEW_ROOT, context.getViewRoot());
+ //...and remember that this instance needs NO special treatment on rendering:
+ _itemOpenActiveStatesRestored = true;
+ }
+
+ public void encodeBegin(FacesContext context) throws IOException
+ {
+ if (!_itemOpenActiveStatesRestored && getChildCount() > 0)
+ {
+ UIViewRoot previousRoot = (UIViewRoot)context.getExternalContext().getRequestMap().get(PREVIOUS_VIEW_ROOT);
+ if (previousRoot != null)
+ {
+ if(previousRoot.findComponent(getClientId(context)) instanceof AbstractHtmlPanelNavigationMenu)
+ {
+ restoreOpenActiveStates(context, previousRoot, getChildren());
+ }
+ }
+ else
+ {
+ //no previous root, means no decode was done
+ //--> a new request
+ }
+ }
+
+ super.encodeBegin(context); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void restoreOpenActiveStates(FacesContext facesContext,
+ UIViewRoot previousRoot,
+ List children)
+ {
+ for (Iterator it = children.iterator(); it.hasNext(); )
+ {
+ UIComponent child = (UIComponent)it.next();
+ UIComponent prevItem = (UIComponent)previousRoot.findComponent(child.getClientId(facesContext));
+
+ if (prevItem instanceof HtmlCommandNavigationItem &&
+ child instanceof HtmlCommandNavigationItem)
+ {
+ HtmlCommandNavigationItem previousItem = (HtmlCommandNavigationItem)prevItem;
+ if (previousItem != null)
+ {
+ ((HtmlCommandNavigationItem)child).setOpen(previousItem.isOpen());
+ ((HtmlCommandNavigationItem)child).setActive(previousItem.isActive());
+ }
+ else
+ {
+ log.debug("Navigation item " + child.getClientId(facesContext) + " not found in previous view.");
+ }
+ if (child.getChildCount() > 0)
+ {
+ restoreOpenActiveStates(facesContext, previousRoot, child.getChildren());
+ }
+ }
+ }
+ }
+
+ /**
+ * The CSS class of closed navigation items.
+ *
+ * @JSFProperty
+ */
+ public abstract String getItemClass();
+
+ /**
+ * The CSS class of open navigation items.
+ *
+ * @JSFProperty
+ */
+ public abstract String getOpenItemClass();
+
+ /**
+ * The CSS class of open navigation items.
+ *
+ * @JSFProperty
+ */
+ public abstract String getActiveItemClass();
+
+ /**
+ * The CSS class for the td element of a separator.
+ *
+ * @JSFProperty
+ */
+ public abstract String getSeparatorClass();
+
+ /**
+ * The CSS Style of closed navigation items.
+ *
+ * @JSFProperty
+ */
+ public abstract String getItemStyle();
+
+ /**
+ * The CSS Style of open navigation items.
+ *
+ * @JSFProperty
+ */
+ public abstract String getOpenItemStyle();
+
+ /**
+ * The CSS Style of the active navigation item.
+ *
+ * @JSFProperty
+ */
+ public abstract String getActiveItemStyle();
+
+ /**
+ * The CSS Style for the td element of a separator.
+ *
+ * @JSFProperty
+ */
+ public abstract String getSeparatorStyle();
+
+ /**
+ * 'table' or 'list' Layout (default is 'table')
+ *
+ * @JSFProperty
+ */
+ public abstract String getLayout();
+
+ /**
+ * @JSFProperty
+ * tagExcluded="true"
+ * literalOnly = "true"
+ * defaultValue = "false"
+ */
+ public abstract Boolean getPreprocessed();
+
+ /**
+ * If set to true all Items are expanded from the beginning and never closed.
+ *
+ * @JSFProperty
+ * defaultValue="false"
+ */
+ public abstract boolean isExpandAll();
+
+ /**
+ * If set to true all Items are rendered and other methods, like
+ * CSS should be used to hide them as necessary
+ *
+ * @JSFProperty
+ * defaultValue="false"
+ */
+ public abstract boolean isRenderAll();
+
+ /**
+ * When set instead of a Hyperlink a span tag is rendered in the corresponding Component
+ *
+ * @JSFProperty
+ * defaultValue="false"
+ */
+ public abstract boolean isDisabled();
+
+ /**
+ * CSS-Style Attribute to render when disabled is true
+ *
+ * @JSFProperty
+ */
+ public abstract String getDisabledStyle();
+
+ /**
+ * CSS-Style Class to use when disabled is true
+ *
+ * @JSFProperty
+ */
+ public abstract String getDisabledStyleClass();
+
+}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java?rev=938319&r1=938318&r2=938319&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/navmenu/htmlnavmenu/HtmlNavigationMenuRenderer.java Tue Apr 27 04:20:18 2010
@@ -22,12 +22,14 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.component.UIGraphic;
import javax.faces.component.UIOutput;
import javax.faces.component.UISelectItems;
import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
@@ -220,7 +222,18 @@ public class HtmlNavigationMenuRenderer
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.startElement(HTML.UL_ELEM, panelNav);
- HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.UL_PASSTHROUGH_ATTRIBUTES);
+ Map<String, List<ClientBehavior>> behaviors = panelNav.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelNav, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.UL_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.UL_PASSTHROUGH_ATTRIBUTES);
+ }
//iterate over the tree and toggleOpen if viewId in item.getActiveOnVieIds()
activeOnViewId(panelNav, facesContext.getViewRoot().getViewId());
@@ -245,7 +258,17 @@ public class HtmlNavigationMenuRenderer
if (panelNav.getChildCount() > 0) {
HtmlRendererUtils.writePrettyLineSeparator(facesContext);
writer.startElement(HTML.TABLE_ELEM, panelNav);
- HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ Map<String, List<ClientBehavior>> behaviors = panelNav.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, panelNav, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, panelNav, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
if (panelNav.getStyle() == null && panelNav.getStyleClass() == null) {
writer.writeAttribute(HTML.BORDER_ATTR, ZERO_INTEGER, null);
}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java?rev=938319&r1=938318&r2=938319&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/picklist/HtmlPicklistRenderer.java Tue Apr 27 04:20:18 2010
@@ -30,6 +30,8 @@ import javax.faces.application.ResourceD
import javax.faces.component.EditableValueHolder;
import javax.faces.component.UIComponent;
import javax.faces.component.UISelectMany;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
@@ -295,8 +297,25 @@ public class HtmlPicklistRenderer extend
{
writer.writeAttribute(HTML.SIZE_ATTR, Integer.toString(size), null);
}
- HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
- HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+
+ Map<String, List<ClientBehavior>> behaviors = null;
+ if (uiComponent instanceof ClientBehaviorHolder)
+ {
+ behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
+ }
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedOnchangeEventHandler(facesContext, writer, uiComponent, behaviors);
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, uiComponent, behaviors);
+ HtmlRendererUtils.renderBehaviorizedFieldEventHandlersWithoutOnchange(facesContext, writer, uiComponent, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent, HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, uiComponent,
+ HTML.SELECT_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED);
+ }
if (disabled)
{
writer.writeAttribute(HTML.DISABLED_ATTR, Boolean.TRUE, null);
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/popup/AbstractHtmlPopup.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.popup;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+
+/**
+ * Renders a popup which displays on a mouse event.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * @JSFComponent
+ * name = "t:popup"
+ * class = "org.apache.myfaces.custom.popup.HtmlPopup"
+ * tagClass = "org.apache.myfaces.custom.popup.HtmlPopupTag"
+ * @since 1.1.7
+ * @author Martin Marinschek (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractHtmlPopup
+ extends UIComponentBase implements
+ UniversalProperties, EventAware, UserRoleAware
+{
+ //private static final Log log = LogFactory.getLog(HtmlPopup.class);
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPopup";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Popup";
+
+ private static final String POPUP_FACET_NAME = "popup";
+
+ public void setPopup(UIComponent popup)
+ {
+ getFacets().put(POPUP_FACET_NAME, popup);
+ }
+
+ public UIComponent getPopup()
+ {
+ return (UIComponent)getFacets().get(POPUP_FACET_NAME);
+ }
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ public boolean isRendered()
+ {
+ if (!UserRoleUtils.isVisibleOnUserRole(this)) return false;
+ return super.isRendered();
+ }
+
+ /**
+ * HTML: CSS styling instructions.
+ *
+ * @JSFProperty
+ */
+ public abstract String getStyle();
+
+ /**
+ * The CSS class for this element. Corresponds to the HTML 'class' attribute.
+ *
+ * @JSFProperty
+ */
+ public abstract String getStyleClass();
+
+ /**
+ * Pop the panel up in horizontal distance of x pixels from event.
+ *
+ * @JSFProperty
+ */
+ public abstract Integer getDisplayAtDistanceX();
+
+ /**
+ * Pop the panel up in vertical distance of y pixels from event.
+ *
+ * @JSFProperty
+ */
+ public abstract Integer getDisplayAtDistanceY();
+
+ /**
+ * Close the popup when the triggering element is left.
+ *
+ * @JSFProperty
+ */
+ public abstract Boolean getClosePopupOnExitingElement();
+
+ /**
+ * Close the popup when the popup itself is left.
+ *
+ * @JSFProperty
+ */
+ public abstract Boolean getClosePopupOnExitingPopup();
+}
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTab.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.tabbedpane;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.html.HtmlPanelGroup;
+
+import org.apache.myfaces.component.EventAware;
+import org.apache.myfaces.component.UniversalProperties;
+import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.component.UserRoleUtils;
+
+/**
+ * TODO: Document this component.
+ *
+ * Unless otherwise specified, all attributes accept static values or EL expressions.
+ *
+ * @JSFComponent
+ * name = "t:panelTab"
+ * class = "org.apache.myfaces.custom.tabbedpane.HtmlPanelTab"
+ * tagClass = "org.apache.myfaces.custom.tabbedpane.HtmlPanelTabTag"
+ * @since 1.1.7
+ * @author Manfred Geiler (latest modification by $Author: lu4242 $)
+ * @version $Revision: 691856 $ $Date: 2008-09-03 21:40:30 -0500 (mié, 03 sep 2008) $
+ */
+public abstract class AbstractHtmlPanelTab
+ extends HtmlPanelGroup implements NamingContainer,
+ UserRoleAware, EventAware, UniversalProperties
+{
+ //private static final Log log = LogFactory.getLog(HtmlPanelTab.class);
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlPanelTab";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Group";
+ private static final boolean DEFAULT_DISABLED = false;
+
+ /**
+ * Label of this tab.
+ *
+ * @JSFProperty
+ */
+ public abstract String getLabel();
+
+ /**
+ * HTML: When true, this element cannot receive focus.
+ *
+ * @JSFProperty
+ * defaultValue = "false"
+ */
+ public abstract boolean isDisabled();
+
+ public boolean isRendered()
+ {
+ if (!UserRoleUtils.isVisibleOnUserRole(this)) {
+ return false;
+ }
+ return super.isRendered();
+ }
+}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java?rev=938319&r1=938318&r2=938319&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/AbstractHtmlPanelTabbedPane.java Tue Apr 27 04:20:18 2010
@@ -26,6 +26,7 @@ import javax.faces.component.StateHolder
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UINamingContainer;
+import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.context.FacesContext;
import javax.faces.el.EvaluationException;
@@ -60,7 +61,7 @@ import org.apache.myfaces.component.User
public abstract class AbstractHtmlPanelTabbedPane
extends HtmlPanelGroup
implements UniversalProperties, EventAware, PanelProperties,
- AlignProperty, DataProperties, UserRoleAware
+ AlignProperty, DataProperties, UserRoleAware, ClientBehaviorHolder
{
//private static final Log log = LogFactory.getLog(HtmlPanelTabbedPane.class);
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java?rev=938319&r1=938318&r2=938319&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tabbedpane/HtmlTabbedPaneRenderer.java Tue Apr 27 04:20:18 2010
@@ -29,6 +29,7 @@ import javax.faces.application.ViewHandl
import javax.faces.component.UIComponent;
import javax.faces.component.UIForm;
import javax.faces.component.UINamingContainer;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.ComponentSystemEvent;
@@ -379,7 +380,17 @@ public class HtmlTabbedPaneRenderer
String oldTabbedStyleClass = tabbedPane.getStyleClass();
tabbedPane.setStyleClass ((oldTabbedStyleClass == null) ? "myFaces_panelTabbedPane" : "myFaces_panelTabbedPane " + oldTabbedStyleClass);
writer.writeAttribute(HTML.CELLSPACING_ATTR, "0", null);
- HtmlRendererUtils.renderHTMLAttributes(writer, tabbedPane, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ Map<String, List<ClientBehavior>> behaviors = tabbedPane.getClientBehaviors();
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(facesContext, writer, tabbedPane, behaviors);
+ HtmlRendererUtils.renderHTMLAttributes(writer, tabbedPane, HTML.TABLE_PASSTHROUGH_ATTRIBUTES_WITHOUT_EVENTS);
+ }
+ else
+ {
+ HtmlRendererUtils.renderHTMLAttributes(writer, tabbedPane, HTML.TABLE_PASSTHROUGH_ATTRIBUTES);
+ }
writer.flush();
tabbedPane.setBgcolor(oldBgColor);
Added: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRenderer.java?rev=938319&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRenderer.java (added)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlGroupRenderer.java Tue Apr 27 04:20:18 2010
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.renderkit.html.ext;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.apache.myfaces.buildtools.maven2.plugin.builder.annotation.JSFRenderer;
+import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
+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.HtmlGroupRendererBase;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+
+
+/**
+ *
+ * @author Martin Marinschek (latest modification by $Author: mmarinschek $)
+ * @version $Revision: 167446 $ $Date: 2004-12-23 13:03:09Z $
+ */
+@JSFRenderer(
+ renderKitId = "HTML_BASIC",
+ family = "javax.faces.Panel",
+ type = "org.apache.myfaces.Group")
+public class HtmlGroupRenderer
+ extends HtmlGroupRendererBase
+{
+
+ public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ boolean span = false;
+ String element = getHtmlElement(component);
+
+ Map<String, List<ClientBehavior>> behaviors = null;
+ if (component instanceof ClientBehaviorHolder)
+ {
+ behaviors = ((ClientBehaviorHolder) component).getClientBehaviors();
+ }
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ //Render element and id to make javascript work
+ span = true;
+ writer.startElement(element, component);
+ writer.writeAttribute(HTML.ID_ATTR, component.getClientId(context),null);
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.UNIVERSAL_ATTRIBUTES);
+ HtmlRendererUtils.renderBehaviorizedEventHandlers(context, writer, component, behaviors);
+ }
+ else
+ {
+ //No behaviors, do it as usual
+ if(component.getId()!=null && !component.getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
+ {
+ span = true;
+
+ writer.startElement(element, component);
+
+ HtmlRendererUtils.writeIdIfNecessary(writer, component, context);
+
+ HtmlRendererUtils.renderHTMLAttributes(writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
+ else
+ {
+ span=HtmlRendererUtils.renderHTMLAttributesWithOptionalStartElement(writer,
+ component,
+ element,
+ HTML.COMMON_PASSTROUGH_ATTRIBUTES);
+ }
+ }
+
+ RendererUtils.renderChildren(context, component);
+ if (span)
+ {
+ writer.endElement(element);
+ }
+ }
+
+ private String getHtmlElement(UIComponent component) {
+ if (component instanceof HtmlPanelGroup) {
+ HtmlPanelGroup group = (HtmlPanelGroup) component;
+ if (HtmlPanelGroup.BLOCK_LAYOUT.equals(group.getLayout())) {
+ return HTML.DIV_ELEM;
+ }
+ }
+ return HTML.SPAN_ELEM;
+ }
+}
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java?rev=938319&r1=938318&r2=938319&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/renderkit/html/ext/HtmlTableRenderer.java Tue Apr 27 04:20:18 2010
@@ -923,12 +923,35 @@ public class HtmlTableRenderer extends H
protected void renderHtmlColumnAttributes(ResponseWriter writer,
UIComponent uiComponent, String prefix) throws IOException {
- String[] attrs = (String[]) ArrayUtils.concat(HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE, new String[]{HTML.COLSPAN_ATTR});
- for (int i = 0, size = attrs.length; i < size; i++) {
- String attributeName = attrs[i];
- String compAttrName = prefix != null ? prefix + attributeName : attributeName;
- HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
- compAttrName, attributeName);
+
+ Map<String, List<ClientBehavior>> behaviors = null;
+ if (uiComponent instanceof ClientBehaviorHolder)
+ {
+ behaviors = ((ClientBehaviorHolder) uiComponent).getClientBehaviors();
+ }
+
+ if (behaviors != null && !behaviors.isEmpty())
+ {
+ String[] attrs = (String[]) ArrayUtils.concat(HTML.UNIVERSAL_ATTRIBUTES_WITHOUT_STYLE, new String[]{HTML.COLSPAN_ATTR});
+ for (int i = 0, size = attrs.length; i < size; i++) {
+ String attributeName = attrs[i];
+ String compAttrName = prefix != null ? prefix + attributeName : attributeName;
+ HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
+ compAttrName, attributeName);
+ }
+
+ //TODO: behavior stuff
+
+ }
+ else
+ {
+ String[] attrs = (String[]) ArrayUtils.concat(HTML.COMMON_PASSTROUGH_ATTRIBUTES_WITHOUT_STYLE, new String[]{HTML.COLSPAN_ATTR});
+ for (int i = 0, size = attrs.length; i < size; i++) {
+ String attributeName = attrs[i];
+ String compAttrName = prefix != null ? prefix + attributeName : attributeName;
+ HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,
+ compAttrName, attributeName);
+ }
}
String compAttrName = prefix != null ? prefix + HTML.STYLE_ATTR : HTML.STYLE_ATTR;
HtmlRendererUtils.renderHTMLAttribute(writer, uiComponent,