myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject svn commit: r1794042 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/component/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ tobago-core/src/main/java/org/apache/myfaces/tobago/interna...
Date Fri, 05 May 2017 12:39:50 GMT
Author: hnoeth
Date: Fri May  5 12:39:50 2017
New Revision: 1794042

URL: http://svn.apache.org/viewvc?rev=1794042&view=rev
Log:
TOBAGO-1721 Optimize HTML output when two renderer are involved
* separator for dropdown menus implemented

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SeparatorInsideCommandRenderer.java
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SeparatorTagDeclaration.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/30-separator/separator.xhtml

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java?rev=1794042&r1=1794041&r2=1794042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/component/RendererTypes.java
Fri May  5 12:39:50 2017
@@ -79,6 +79,7 @@ public enum RendererTypes {
   SelectOneListbox,
   SelectReference,
   Separator,
+  SeparatorInsideCommand,
   Sheet,
   SheetPageCommand,
   /** @deprecated since 3.1.0 */
@@ -155,6 +156,7 @@ public enum RendererTypes {
   public static final String SELECT_ONE_LISTBOX = "SelectOneListbox";
   public static final String SELECT_REFERENCE = "SelectReference";
   public static final String SEPARATOR = "Separator";
+  public static final String SEPARATOR_INSIDE_COMMAND = "SeparatorInsideCommand";
   public static final String SHEET = "Sheet";
   public static final String SHEET_PAGE_COMMAND = "SheetPageCommand";
   /** @deprecated since 3.1.0 */

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java?rev=1794042&r1=1794041&r2=1794042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/CommandRendererBase.java
Fri May  5 12:39:50 2017
@@ -27,6 +27,7 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectBooleanCheckbox;
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectManyCheckbox;
 import org.apache.myfaces.tobago.internal.component.AbstractUISelectOneRadio;
+import org.apache.myfaces.tobago.internal.component.AbstractUISeparator;
 import org.apache.myfaces.tobago.internal.util.AccessKeyLogger;
 import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.internal.util.JsonUtils;
@@ -180,6 +181,9 @@ public abstract class CommandRendererBas
           } else if (child instanceof AbstractUISelectOneRadio) {
             child.setRendererType(RendererTypes.SelectOneRadioInsideCommand.name());
             child.encodeAll(facesContext);
+          } else if( child instanceof AbstractUISeparator) {
+            child.setRendererType(RendererTypes.SeparatorInsideCommand.name());
+            child.encodeAll(facesContext);
           } else {
             writer.startElement(HtmlElements.DIV);
             writer.writeClassAttribute(BootstrapClass.DROPDOWN_ITEM);

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SeparatorInsideCommandRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SeparatorInsideCommandRenderer.java?rev=1794042&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SeparatorInsideCommandRenderer.java
(added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SeparatorInsideCommandRenderer.java
Fri May  5 12:39:50 2017
@@ -0,0 +1,48 @@
+/*
+ * 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.renderkit.renderer;
+
+import org.apache.myfaces.tobago.component.UISeparator;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
+import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
+import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.io.IOException;
+
+public class SeparatorInsideCommandRenderer extends SeparatorRenderer {
+
+  @Override
+  public void encodeEnd(final FacesContext facesContext, final UIComponent component) throws
IOException {
+    final UISeparator separator = (UISeparator) component;
+    final TobagoResponseWriter writer = getResponseWriter(facesContext);
+    final String clientId = separator.getClientId(facesContext);
+
+    writer.startElement(HtmlElements.DIV);
+    writer.writeIdAttribute(clientId);
+    writer.writeClassAttribute(
+        TobagoClass.SEPARATOR,
+        BootstrapClass.DROPDOWN_DIVIDER,
+        separator.getCustomClass());
+    writer.endElement(HtmlElements.DIV);
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SeparatorTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SeparatorTagDeclaration.java?rev=1794042&r1=1794041&r2=1794042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SeparatorTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SeparatorTagDeclaration.java
Fri May  5 12:39:50 2017
@@ -36,7 +36,7 @@ import org.apache.myfaces.tobago.interna
     uiComponent = "org.apache.myfaces.tobago.component.UISeparator",
     uiComponentBaseClass = "org.apache.myfaces.tobago.internal.component.AbstractUISeparator",
     componentFamily = "org.apache.myfaces.tobago.Separator",
-    rendererType = RendererTypes.SEPARATOR,
+    rendererType = {RendererTypes.SEPARATOR, RendererTypes.SEPARATOR_INSIDE_COMMAND},
     allowedChildComponenents = "NONE",
     interfaces = {
         // As long as no behavior event names are defined, ClientBehaviorHolder must be implemented
for Majorra.

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java?rev=1794042&r1=1794041&r2=1794042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/css/BootstrapClass.java
Fri May  5 12:39:50 2017
@@ -156,6 +156,7 @@ public enum BootstrapClass implements Cs
   D_INLINE("d-inline"),
   DISABLED("disabled"),
   DROPDOWN("dropdown"),
+  DROPDOWN_DIVIDER("dropdown-divider"),
   DROPDOWN_ITEM("dropdown-item"),
   DROPDOWN_MENU("dropdown-menu"),
   DROPDOWN_MENU_RIGHT("dropdown-menu-right"),

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/30-separator/separator.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/30-separator/separator.xhtml?rev=1794042&r1=1794041&r2=1794042&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/30-separator/separator.xhtml
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/050-container/30-separator/separator.xhtml
Fri May  5 12:39:50 2017
@@ -37,4 +37,14 @@
     <tc:separator/>
     <tc:in id="i4" label="Text 2"/>
   </tc:section>
+
+  <tc:section label="Separator in dropdown menu">
+    <p>Just put a <code class="language-markup">&lt;tc:separator/></code>
tag between dropdown menu entries.</p>
+    <p>The <code>label</code> attribute has no effect.</p>
+    <tc:button label="Dropdown" omit="true">
+      <tc:link label="Entry One" omit="true"/>
+      <tc:separator/>
+      <tc:link label="Entry Two" omit="true"/>
+    </tc:button>
+  </tc:section>
 </ui:composition>



Mime
View raw message