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 2015/05/07 16:39:47 UTC

svn commit: r1678221 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/...

Author: lofwyr
Date: Thu May  7 14:39:47 2015
New Revision: 1678221

URL: http://svn.apache.org/r1678221
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
 - progress with tc:nav
 - adding label and image attributes

Added:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandGroup.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/CommandGroupTagDeclaration.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandGroupRenderer.java
Removed:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/header.xhtml
Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/NavTagDeclaration.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ImageRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/NavRenderer.java

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java Thu May  7 14:39:47 2015
@@ -34,6 +34,7 @@ public final class RendererTypes {
   public static final String COLUMN_LAYOUT = "ColumnLayout";
   public static final String COLUMN_SELECTOR = "ColumnSelector";
   public static final String COMMAND = "Command";
+  public static final String COMMAND_GROUP = "CommandGroup";
   public static final String DATE = "Date";
   @Deprecated
   public static final String DATE_PICKER = "DatePicker";

Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandGroup.java?rev=1678221&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandGroup.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUICommandGroup.java Thu May  7 14:39:47 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.tobago.internal.component;
+
+import javax.faces.component.UIPanel;
+
+public class AbstractUICommandGroup extends UIPanel {
+}

Added: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/CommandGroupTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/CommandGroupTagDeclaration.java?rev=1678221&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/CommandGroupTagDeclaration.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/CommandGroupTagDeclaration.java Thu May  7 14:39:47 2015
@@ -0,0 +1,37 @@
+/*
+ * 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.tobago.internal.taglib.component;
+
+import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
+
+import javax.faces.component.UIPanel;
+
+@Tag(name = "commandGroup")
+@UIComponentTag(uiComponent = "org.apache.myfaces.tobago.component.UICommandGroup",
+    uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUICommandGroup",
+    uiComponentFacesClass = "javax.faces.component.UIPanel",
+    componentFamily = UIPanel.COMPONENT_FAMILY,
+    rendererType = RendererTypes.COMMAND_GROUP,
+    allowedChildComponenents = "ALL")
+public interface CommandGroupTagDeclaration extends HasIdBindingAndRendered {
+}

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/NavTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/NavTagDeclaration.java?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/NavTagDeclaration.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/NavTagDeclaration.java Thu May  7 14:39:47 2015
@@ -24,6 +24,8 @@ import org.apache.myfaces.tobago.apt.ann
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasCurrentMarkup;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasIdBindingAndRendered;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasImage;
+import org.apache.myfaces.tobago.internal.taglib.declaration.HasLabel;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasMarkup;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasTip;
 
@@ -39,5 +41,6 @@ import javax.faces.component.UIPanel;
     componentFamily = UIPanel.COMPONENT_FAMILY,
     rendererType = RendererTypes.NAV,
     allowedChildComponenents = "ALL")
-public interface NavTagDeclaration extends HasIdBindingAndRendered, HasTip, HasMarkup, HasCurrentMarkup {
+public interface NavTagDeclaration
+    extends HasIdBindingAndRendered, HasTip, HasMarkup, HasCurrentMarkup, HasImage, HasLabel {
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml Thu May  7 14:39:47 2015
@@ -36,44 +36,32 @@
             </f:facet>
       -->
 
-      <tc:header>
-        <ui:include src="/menu.xhtml"/>
-      </tc:header>
+      <ui:include src="/menu.xhtml"/>
 
       <tc:panel>
         <f:facet name="layout">
-          <tc:flexLayout rows="100px;*"/>
+          <tc:flexLayout columns="*;4*"/>
         </f:facet>
 
         <tc:panel>
-          <ui:include src="/header.xhtml"/>
+          <ui:include src="/navigation.xhtml"/>
         </tc:panel>
 
         <tc:panel>
           <f:facet name="layout">
-            <tc:flexLayout columns="*;4*"/>
+            <tc:flexLayout rows="auto;*;auto"/>
           </f:facet>
 
-          <tc:panel>
-            <ui:include src="/navigation.xhtml"/>
-          </tc:panel>
-
-          <tc:panel>
-            <f:facet name="layout">
-              <tc:flexLayout rows="auto;*;auto"/>
-            </f:facet>
-
-            <tc:messages/>
+          <tc:messages/>
 
-            <tc:box label="#{title}" id="content">
-              <ui:insert/>
-            </tc:box>
+          <tc:box label="#{title}" id="content">
+            <ui:insert/>
+          </tc:box>
 
-            <ui:include src="/footer.xhtml"/>
-
-          </tc:panel>
+          <ui:include src="/footer.xhtml"/>
 
         </tc:panel>
+
       </tc:panel>
 
     </tc:page>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/menu.xhtml Thu May  7 14:39:47 2015
@@ -17,49 +17,76 @@
  * limitations under the License.
 -->
 
-<tc:nav
-    xmlns:f="http://java.sun.com/jsf/core"
-    xmlns:tc="http://myfaces.apache.org/tobago/component"
-    xmlns:tx="http://myfaces.apache.org/tobago/extension">
-  <tc:form>
-  <tc:command label="#{overviewBundle.menu_config}" omit="true">
-    <tc:command label="Hier sind die themes">
-      <tc:command action="#{clientConfigController.submit}">
-        <tc:selectOneRadio value="#{clientConfigController.theme}">
-          <tc:selectItems value="#{clientConfigController.themeItems}"/>
-        </tc:selectOneRadio>
-      </tc:command>
-    </tc:command>
-    <tc:command label="#{overviewBundle.menu_locale}">
-      <tc:command action="#{clientConfigController.submit}">
-        <tc:selectOneRadio value="#{clientConfigController.locale}">
-          <tc:selectItems value="#{clientConfigController.localeItems}"/>
-        </tc:selectOneRadio>
-      </tc:command>
-    </tc:command>
-    <tc:command action="#{demo.resetSession}" label="Reset"/>
-  </tc:command>
-
-  <tc:command label="#{overviewBundle.menu_help}" omit="true">
-    <tc:command label="#{overviewBundle.menu_about}" omit="true">
-      <tc:dataAttribute name="alert-text"
-                        value="#{overviewBundle.pageTitle} - #{info.version} - #{overviewBundle.tobago_url}"/>
-    </tc:command>
-    <tc:command link="http://myfaces.apache.org/tobago" label="Tobago in the Web"/>
-    <tc:command action="server-info" immediate="true" label="Server Info" disabled="#{! info.enabled}"/>
-    <tc:command label="Sub-Menu" omit="true">
-      <tc:command label="Sub 1" omit="true"/>
-      <tc:command label="Sub 2" omit="true"/>
-      <tc:command label="Sub 3" omit="true"/>
-      <tc:command action="doit" label="Sub 4 ich kann auch selber was" omit="true">
-        <tc:command label="Sub 4 1" omit="true"/>
-        <tc:command label="Sub 4 2" omit="true"/>
-      </tc:command>
-      <tc:command label="Sub 5" omit="true">
-        <tc:command label="Sub 5 1" omit="true"/>
-        <tc:command label="Sub 5 2" omit="true"/>
-      </tc:command>
-    </tc:command>
-  </tc:command>
-  </tc:form>
-</tc:nav>
+<tc:header xmlns:tc="http://myfaces.apache.org/tobago/component">
+
+  <tc:nav image="image/feather-leaf.png" label="Tobago Demo">
+
+    <tc:form>
+
+      <tc:commandGroup>
+
+        <tc:command label="#{overviewBundle.menu_config}" omit="true">
+          <tc:command label="Hier sind die themes">
+            <tc:command action="#{clientConfigController.submit}">
+              <tc:selectOneRadio value="#{clientConfigController.theme}">
+                <tc:selectItems value="#{clientConfigController.themeItems}"/>
+              </tc:selectOneRadio>
+            </tc:command>
+          </tc:command>
+          <tc:command label="#{overviewBundle.menu_locale}">
+            <tc:command action="#{clientConfigController.submit}">
+              <tc:selectOneRadio value="#{clientConfigController.locale}">
+                <tc:selectItems value="#{clientConfigController.localeItems}"/>
+              </tc:selectOneRadio>
+            </tc:command>
+          </tc:command>
+          <tc:command action="#{demo.resetSession}" label="Reset"/>
+        </tc:command>
+
+        <tc:command label="#{overviewBundle.menu_help}" omit="true">
+          <tc:command label="#{overviewBundle.menu_about}" omit="true">
+            <tc:dataAttribute name="alert-text"
+                              value="#{overviewBundle.pageTitle} - #{info.version} - #{overviewBundle.tobago_url}"/>
+          </tc:command>
+          <tc:command link="http://myfaces.apache.org/tobago" label="Tobago in the Web"/>
+          <tc:command action="server-info" immediate="true" label="Server Info" disabled="#{! info.enabled}"/>
+          <tc:command label="Sub-Menu" omit="true">
+            <tc:command label="Sub 1" omit="true"/>
+            <tc:command label="Sub 2" omit="true"/>
+            <tc:command label="Sub 3" omit="true"/>
+            <tc:command action="doit" label="Sub 4 ich kann auch selber was" omit="true">
+              <tc:command label="Sub 4 1" omit="true"/>
+              <tc:command label="Sub 4 2" omit="true"/>
+            </tc:command>
+            <tc:command label="Sub 5" omit="true">
+              <tc:command label="Sub 5 1" omit="true"/>
+              <tc:command label="Sub 5 2" omit="true"/>
+            </tc:command>
+          </tc:command>
+        </tc:command>
+
+      </tc:commandGroup>
+      <!-- TBD: this is not nice: can we put tc:out or tc:label into the menu?  -->
+      <tc:commandGroup>
+        <tc:command omit="true" label="Info">
+          <tc:command omit="true" label="Theme: #{clientConfigController.localizedTheme}"/>
+          <tc:command omit="true" label="Locale: #{clientConfigController.localizedLocale}"/>
+          <tc:command omit="true" label="Project Stage: #{tobagoContext.tobagoConfig.projectStage}"/>
+          <tc:command omit="true" label="CSP mode: #{tobagoContext.tobagoConfig.contentSecurityPolicy.mode}"/>
+          <tc:command omit="true" label="Requests: #{activityList.values[0].jsfRequest} / AJAX: #{activityList.values[0].ajaxRequest}"/>
+        </tc:command>
+      </tc:commandGroup>
+    </tc:form>
+
+    <tc:form>
+      <tc:in placeholder="Search"/>
+      <tc:button defaultCommand="true" omit="true" label="go">
+        <tc:dataAttribute name="alert-text"
+                          value="Sorry: Search not implemented"/>
+
+      </tc:button>
+    </tc:form>
+
+  </tc:nav>
+
+</tc:header>

Added: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandGroupRenderer.java?rev=1678221&view=auto
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandGroupRenderer.java (added)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/CommandGroupRenderer.java Thu May  7 14:39:47 2015
@@ -0,0 +1,70 @@
+/*
+ * 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.tobago.renderkit.html.standard.standard.tag;
+
+import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
+import org.apache.myfaces.tobago.renderkit.RendererBase;
+import org.apache.myfaces.tobago.renderkit.html.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
+import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+public class CommandGroupRenderer extends RendererBase {
+
+  @Override
+  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+
+    writer.startElement(HtmlElements.UL, null);
+    writer.writeClassAttribute(BootstrapClass.NAV, BootstrapClass.NAVBAR_NAV);
+  }
+
+  @Override
+  public boolean getRendersChildren() {
+    return true;
+  }
+
+  @Override
+  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+
+    for (UIComponent child : component.getChildren()) {
+      if (child.isRendered()) {
+        if (child instanceof AbstractUIForm) { // XXX hack! TBD: How to walk through the children, or do that in JS?
+          encodeChildren(facesContext, child);
+        } else {
+          writer.startElement(HtmlElements.LI, null);
+          child.encodeAll(facesContext);
+          writer.endElement(HtmlElements.LI);
+        }
+      }
+    }
+  }
+
+  @Override
+  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    writer.endElement(HtmlElements.UL);
+  }
+}

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ImageRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ImageRenderer.java?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ImageRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ImageRenderer.java Thu May  7 14:39:47 2015
@@ -21,14 +21,17 @@ package org.apache.myfaces.tobago.render
 
 import org.apache.myfaces.tobago.component.Attributes;
 import org.apache.myfaces.tobago.component.UICommand;
+import org.apache.myfaces.tobago.component.UINav;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.internal.component.AbstractUIImage;
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Classes;
 import org.apache.myfaces.tobago.renderkit.css.Style;
+import org.apache.myfaces.tobago.renderkit.html.BootstrapClass;
 import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
+import org.apache.myfaces.tobago.util.ComponentUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -89,7 +92,12 @@ public class ImageRenderer extends Layou
     writer.writeAttribute(HtmlAttributes.BORDER, border, false);
     final Style style = new Style(facesContext, image);
     writer.writeStyleAttribute(style);
-    writer.writeClassAttribute(Classes.create(image));
+    if (ComponentUtils.findAncestor(image, UINav.class) != null) { // todo: may set a marker in the context in the
+      // todo: NavRenderer, or the additional class, to avoid tree traversing
+      writer.writeClassAttribute(Classes.create(image).getStringValue() + " " + BootstrapClass.NAVBAR_BRAND.getName());
+    } else {
+      writer.writeClassAttribute(Classes.create(image));
+    }
     writer.endElement(HtmlElements.IMG);
   }
 

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/NavRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/NavRenderer.java?rev=1678221&r1=1678220&r2=1678221&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/NavRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/NavRenderer.java Thu May  7 14:39:47 2015
@@ -19,6 +19,9 @@
 
 package org.apache.myfaces.tobago.renderkit.html.standard.standard.tag;
 
+import org.apache.myfaces.tobago.component.UINav;
+import org.apache.myfaces.tobago.context.ResourceManagerUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUICommandGroup;
 import org.apache.myfaces.tobago.internal.component.AbstractUIForm;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.renderkit.html.BootstrapClass;
@@ -39,9 +42,11 @@ public class NavRenderer extends Rendere
 
   @Override
   public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
+
+    final UINav nav = (UINav) component;
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
-    final String clientId = component.getClientId(facesContext);
+    final String clientId = nav.getClientId(facesContext);
     final String navbarId = clientId + "::navbar";
 
     writer.startElement(HtmlElements.NAV, null);
@@ -51,15 +56,12 @@ public class NavRenderer extends Rendere
     writer.startElement(HtmlElements.DIV, null);
     writer.writeClassAttribute(BootstrapClass.CONTAINER_FLUID);
 
-    encodeOpener(writer, navbarId);
+    encodeOpener(facesContext, nav, writer, navbarId);
 
     writer.startElement(HtmlElements.DIV, null);
     writer.writeIdAttribute(navbarId);
     writer.writeClassAttribute(BootstrapClass.COLLAPSE, BootstrapClass.NAVBAR_COLLAPSE);
 // XXX writer.writeClassAttribute(BootstrapClass.COLLAPSE, BootstrapClass.NAVBAR_COLLAPSE, BootstrapClass.NAVBAR_TEXT);
-
-    writer.startElement(HtmlElements.UL, null);
-    writer.writeClassAttribute(BootstrapClass.NAV, BootstrapClass.NAVBAR_NAV);
   }
 
   @Override
@@ -69,31 +71,39 @@ public class NavRenderer extends Rendere
 
   @Override
   public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
+
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
 
+    final DivHelper helper = new DivHelper(writer);
+
     for (UIComponent child : component.getChildren()) {
       if (child.isRendered()) {
-        if (child instanceof AbstractUIForm) { // XXX hack! TBD: How to walk through the children, or do that in JS?
+        if (child instanceof AbstractUIForm) {
+          helper.mayEnd();
           encodeChildren(facesContext, child);
+        } else if (child instanceof AbstractUICommandGroup) {
+          helper.mayEnd();
+          child.encodeAll(facesContext);
         } else {
-          writer.startElement(HtmlElements.LI, null);
+          helper.mayStart();
           child.encodeAll(facesContext);
-          writer.endElement(HtmlElements.LI);
         }
       }
     }
+
+    helper.mayEnd();
   }
 
   @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
     final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-    writer.endElement(HtmlElements.UL);
     writer.endElement(HtmlElements.DIV);
     writer.endElement(HtmlElements.DIV);
     writer.endElement(HtmlElements.NAV);
   }
 
-  private void encodeOpener(TobagoResponseWriter writer, String navbarId) throws IOException {
+  private void encodeOpener(
+      FacesContext facesContext, UINav nav, TobagoResponseWriter writer, String navbarId) throws IOException {
 
     // todo: consolidate this rendering with ToolBarRenderer
 
@@ -121,7 +131,57 @@ public class NavRenderer extends Rendere
 
     writer.endElement(HtmlElements.BUTTON);
 
+    final String image = nav.getImage();
+    if (image != null) {
+      final String src = ResourceManagerUtils.getImageWithPath(facesContext, image);
+      if (src != null) {
+        writer.startElement(HtmlElements.IMG, null);
+        writer.writeClassAttribute(BootstrapClass.NAVBAR_BRAND);
+        writer.writeAttribute(HtmlAttributes.SRC, src, true);
+        writer.writeAttribute(HtmlAttributes.ALT, "", false);
+        writer.endElement(HtmlElements.IMG);
+      }
+    }
+
+    final String label = nav.getLabel();
+    if (label != null) {
+      writer.startElement(HtmlElements.SPAN, null);
+      writer.writeClassAttribute(BootstrapClass.NAVBAR_BRAND);
+      writer.writeText(label);
+      writer.endElement(HtmlElements.SPAN);
+    }
+
     writer.endElement(HtmlElements.DIV);
   }
 
+  /**
+   * This class helps to put some tags of specific type into one DIV.
+   */
+  public static class DivHelper {
+
+    private TobagoResponseWriter writer;
+
+    private boolean isInDiv = false;
+
+
+    public DivHelper(final TobagoResponseWriter writer) {
+      this.writer = writer;
+    }
+
+    public void mayStart() throws IOException {
+      if (!isInDiv) {
+        writer.startElement(HtmlElements.DIV, null);
+        writer.writeClassAttribute(BootstrapClass.NAVBAR_FORM);
+        isInDiv = true;
+      }
+    }
+
+    public void mayEnd() throws IOException {
+      if(isInDiv) {
+        writer.endElement(HtmlElements.DIV);
+      }
+    }
+
+  }
+
 }