myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject svn commit: r1796602 - 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 Mon, 29 May 2017 09:26:58 GMT
Author: hnoeth
Date: Mon May 29 09:26:58 2017
New Revision: 1796602

URL: http://svn.apache.org/viewvc?rev=1796602&view=rev
Log:
TOBAGO-1721 Optimize HTML output when two renderer are involved
* fix dropdowns inside button groups (css class 'btn-group' was missing)

Added:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideButtonsRenderer.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/20-buttons/buttons.test.js
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/ButtonsRenderer.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
    myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java

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=1796602&r1=1796601&r2=1796602&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
Mon May 29 09:26:58 2017
@@ -27,6 +27,7 @@ public enum RendererTypes {
   Bar,
   Box,
   Button,
+  ButtonInsideButtons,
   ButtonInsideIn,
   ButtonInsideInAfter,
   Buttons,
@@ -104,6 +105,7 @@ public enum RendererTypes {
   public static final String BAR = "Bar";
   public static final String BOX = "Box";
   public static final String BUTTON = "Button";
+  public static final String BUTTON_INSIDE_BUTTONS = "ButtonInsideButtons";
   public static final String BUTTON_INSIDE_IN = "ButtonInsideIn";
   public static final String BUTTON_INSIDE_IN_AFTER = "ButtonInsideInAfter";
   public static final String BUTTONS = "Buttons";

Added: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideButtonsRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideButtonsRenderer.java?rev=1796602&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideButtonsRenderer.java
(added)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonInsideButtonsRenderer.java
Mon May 29 09:26:58 2017
@@ -0,0 +1,36 @@
+/*
+ * 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.internal.component.AbstractUICommand;
+import org.apache.myfaces.tobago.renderkit.css.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.css.CssItem;
+
+import javax.faces.context.FacesContext;
+import java.util.List;
+
+public class ButtonInsideButtonsRenderer extends ButtonRenderer {
+
+  @Override
+  protected void addOuterCssItems(final FacesContext facesContext, final AbstractUICommand
command,
+                                  final List<CssItem> collected) {
+    collected.add(BootstrapClass.BTN_GROUP);
+  }
+}

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonsRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonsRenderer.java?rev=1796602&r1=1796601&r2=1796602&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonsRenderer.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/ButtonsRenderer.java
Mon May 29 09:26:58 2017
@@ -19,6 +19,8 @@
 
 package org.apache.myfaces.tobago.internal.renderkit.renderer;
 
+import org.apache.myfaces.tobago.component.RendererTypes;
+import org.apache.myfaces.tobago.internal.component.AbstractUIButton;
 import org.apache.myfaces.tobago.internal.component.AbstractUIButtons;
 import org.apache.myfaces.tobago.internal.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
@@ -66,6 +68,25 @@ public class ButtonsRenderer extends Ren
     }
   }
 
+  @Override
+  public boolean getRendersChildren() {
+    return true;
+  }
+
+  @Override
+  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException
{
+    for (UIComponent child : component.getChildren()) {
+      if (child.isRendered()) {
+        if (child instanceof AbstractUIButton) {
+          child.setRendererType(RendererTypes.ButtonInsideButtons.name());
+          child.encodeAll(facesContext);
+        } else {
+          child.encodeAll(facesContext);
+        }
+      }
+    }
+  }
+
   @Override
   public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException
{
     final TobagoResponseWriter writer = getResponseWriter(facesContext);

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java?rev=1796602&r1=1796601&r2=1796602&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/ButtonTagDeclaration.java
Mon May 29 09:26:58 2017
@@ -60,7 +60,8 @@ import javax.faces.component.UICommand;
         "org.apache.myfaces.tobago.component.SupportsAccessKey"
     },
     componentFamily = UICommand.COMPONENT_FAMILY,
-    rendererType = {RendererTypes.BUTTON, RendererTypes.BUTTON_INSIDE_IN, RendererTypes.BUTTON_INSIDE_IN_AFTER},
+    rendererType = {RendererTypes.BUTTON, RendererTypes.BUTTON_INSIDE_BUTTONS, RendererTypes.BUTTON_INSIDE_IN,
+        RendererTypes.BUTTON_INSIDE_IN_AFTER},
     allowedChildComponenents = "NONE",
     facets = {
         @Facet(

Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/20-buttons/buttons.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/20-buttons/buttons.test.js?rev=1796602&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/20-buttons/buttons.test.js
(added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/040-command/20-buttons/buttons.test.js
Mon May 29 09:26:58 2017
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+QUnit.test("Dropdown button has 'btn-group'", function (assert) {
+  var $button = jQueryFrame("#page\\:mainForm\\:buttonWithLinks");
+  assert.ok($button.hasClass("btn-group"), "id=buttonWithLinks must have 'btn-group'");
+});

Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java?rev=1796602&r1=1796601&r2=1796602&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
(original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/test/java/org/apache/myfaces/tobago/example/demo/QUnitTests.java
Mon May 29 09:26:58 2017
@@ -350,6 +350,12 @@ public class QUnitTests {
   }
 
   @Test
+  public void buttons() throws UnsupportedEncodingException, InterruptedException {
+    String page = "content/20-component/040-command/20-buttons/buttons.xhtml";
+    runStandardTest(page);
+  }
+
+  @Test
   public void popup() throws UnsupportedEncodingException, InterruptedException {
     String page = "content/20-component/060-popup/popup.xhtml";
     runStandardTest(page);



Mime
View raw message