You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2014/10/02 13:59:47 UTC

svn commit: r1628953 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/util/ tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/ tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/ tobago-theme/...

Author: lofwyr
Date: Thu Oct  2 11:59:47 2014
New Revision: 1628953

URL: http://svn.apache.org/r1628953
Log:
TOBAGO-1421: MenuFacet shoud be usable in included facets

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
    myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/BoxRendererBase.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/BoxRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Thu Oct  2 11:59:47 2014
@@ -276,6 +276,24 @@ public final class ComponentUtils {
   }
 
   /**
+   * Searches the component tree beneath the component and return the first component matching the type.
+   */
+  public static <T extends UIComponent> T findFacetDescendant(
+      final UIComponent component, final String facet, final Class<T> type) {
+
+    final UIComponent facetComponent = component.getFacet(facet);
+    if (facetComponent != null) {
+      if (type.isAssignableFrom(facetComponent.getClass())) {
+        return (T) facetComponent;
+      } else {
+        return findDescendant(facetComponent, type);
+      }
+    } else {
+      return null;
+    }
+  }
+
+  /**
    * Searches the children beneath the component and return the first component matching the type.
    */
   public static <T extends UIComponent> T findChild(final UIComponent component, final Class<T> type) {

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/tags/layout/overview.xhtml Thu Oct  2 11:59:47 2014
@@ -31,35 +31,7 @@
       </f:facet>
 
       <f:facet name="menuBar">
-        <tc:menuBar>
-          <tc:form>
-            <tc:menu label="#{overviewBundle.menu_config}">
-              <tc:menu label="Hier sind die themes">
-                <tx:menuRadio action="#{clientConfigController.submit}" value="#{clientConfigController.theme}">
-                  <f:selectItems value="#{clientConfigController.themeItems}"/>
-                </tx:menuRadio>
-              </tc:menu>
-              <tc:menu label="#{overviewBundle.menu_locale}">
-                <tx:menuRadio action="#{clientConfigController.submit}" value="#{clientConfigController.locale}">
-                  <f:selectItems value="#{clientConfigController.localeItems}"/>
-                </tx:menuRadio>
-              </tc:menu>
-              <tc:menuCommand action="#{demo.resetSession}" label="Reset"/>
-            </tc:menu>
-
-            <tc:menu label="#{overviewBundle.menu_help}">
-              <tc:menuCommand label="#{overviewBundle.menu_about}" omit="true">
-                <tc:dataAttribute name="alert-text"
-                                  value="#{overviewBundle.pageTitle} - #{info.version} - #{overviewBundle.tobago_url}"/>
-              </tc:menuCommand>
-              <tc:menuCommand link="http://myfaces.apache.org/tobago" label="Tobago in the Web"/>
-              <tc:menuCommand action="server-info" immediate="true"
-                              label="Server Info"
-                              disabled="#{! info.enabled}"/>
-            </tc:menu>
-          </tc:form>
-        </tc:menuBar>
-
+        <ui:include src="/menu.xhtml"/>
       </f:facet>
 
       <f:facet name="layout">

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/WEB-INF/web.xml Thu Oct  2 11:59:47 2014
@@ -26,8 +26,8 @@
 
   <context-param>
     <param-name>javax.faces.PROJECT_STAGE</param-name>
-    <!--<param-value>Development</param-value>-->
-    <param-value>Production</param-value>
+    <param-value>Development</param-value>
+    <!--<param-value>Production</param-value>-->
   </context-param>
 
   <context-param>

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-speyside/src/main/java/org/apache/myfaces/tobago/renderkit/html/speyside/standard/tag/BoxRenderer.java Thu Oct  2 11:59:47 2014
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
@@ -126,7 +127,7 @@ without shadow
     }
     writer.endElement(HtmlElements.DIV);
 
-    final UIMenuBar menuBar = getMenuBarFacet(box);
+    final UIMenuBar menuBar = ComponentUtils.findFacetDescendant(box, Facets.MENUBAR, UIMenuBar.class);
     if (menuBar != null) {
       RenderUtils.encode(facesContext, menuBar);
     }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/BoxRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/BoxRendererBase.java?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/BoxRendererBase.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/BoxRendererBase.java Thu Oct  2 11:59:47 2014
@@ -24,6 +24,7 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIMenuBar;
 import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.layout.Measure;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,7 +44,7 @@ public abstract class BoxRendererBase ex
   public Measure getBorderTop(final FacesContext facesContext, final Configurable component) {
 
     Measure borderTop = super.getBorderTop(facesContext, component);
-    if (getMenuBarFacet((UIComponent) component) != null) {
+    if (ComponentUtils.findFacetDescendant((UIComponent) component, Facets.MENUBAR, UIMenuBar.class) != null) {
       borderTop = borderTop.add(19); // todo: get via theme config
     }
     return borderTop;

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/BoxRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/BoxRenderer.java?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/BoxRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/BoxRenderer.java Thu Oct  2 11:59:47 2014
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.renderk
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.util.RenderUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 
 import javax.faces.component.UIComponent;
@@ -95,7 +96,7 @@ public class BoxRenderer extends BoxRend
       }
     }
 
-    final UIMenuBar menuBar = getMenuBarFacet(box);
+    final UIMenuBar menuBar = ComponentUtils.findFacetDescendant(box, Facets.MENUBAR, UIMenuBar.class);
     if (menuBar != null) {
       RenderUtils.encode(facesContext, menuBar);
     }

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java?rev=1628953&r1=1628952&r2=1628953&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PageRenderer.java Thu Oct  2 11:59:47 2014
@@ -425,7 +425,7 @@ public class PageRenderer extends PageRe
     }
 */
 
-    final UIMenuBar menuBar = (UIMenuBar) page.getFacet(Facets.MENUBAR);
+    final UIMenuBar menuBar = ComponentUtils.findFacetDescendant(page, Facets.MENUBAR, UIMenuBar.class);
     if (menuBar != null) {
       menuBar.getAttributes().put(Attributes.PAGE_MENU, Boolean.TRUE);
       RenderUtils.encode(facesContext, menuBar);
@@ -714,7 +714,7 @@ public class PageRenderer extends PageRe
     // XXX this is a hack. correct would be the top-border, but this would shift the content, because of the
     // XXX hack before the code: writer.writeStyleAttribute(style)
     final UIPage page = (UIPage) component;
-    final UIMenuBar menuBar = (UIMenuBar) page.getFacet(Facets.MENUBAR);
+    final UIMenuBar menuBar = ComponentUtils.findFacetDescendant(page, Facets.MENUBAR, UIMenuBar.class);
     if (menuBar != null) {
       return getResourceManager().getThemeMeasure(facesContext, page, "custom.menuBar-height");
     } else {