You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2018/01/16 18:17:03 UTC
[myfaces-tobago] branch master updated: TOBAGO-1842 Wrong content
if using tc:tabGroup with tc:style * fix issue * add test
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/master by this push:
new 9f4f0a1 TOBAGO-1842 Wrong content if using tc:tabGroup with tc:style * fix issue * add test
9f4f0a1 is described below
commit 9f4f0a11c140c3590a97fe57ff99aad8afdcb75a
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Tue Jan 16 19:16:54 2018 +0100
TOBAGO-1842 Wrong content if using tc:tabGroup with tc:style
* fix issue
* add test
---
.../renderkit/renderer/TabGroupRenderer.java | 4 +-
.../40-test/2500-tab/tabgroup-style.test.js | 50 ++++++++++++++++++++++
.../content/40-test/2500-tab/tabgroup-style.xhtml | 42 ++++++++++++++++++
3 files changed, 94 insertions(+), 2 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
index ec34c77..060be7b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TabGroupRenderer.java
@@ -178,8 +178,8 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
int index = -1;
int closestRenderedTabIndex = -1;
for (final UIComponent tab : tabGroup.getChildren()) {
- index++;
if (tab instanceof AbstractUIPanelBase) {
+ index++;
if (index == activeIndex) {
if (tab.isRendered()) {
return index;
@@ -312,8 +312,8 @@ public class TabGroupRenderer extends RendererBase implements ComponentSystemEve
writer.endElement(HtmlElements.LI);
}
+ index++;
}
- index++;
}
writer.endElement(HtmlElements.UL);
}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js
new file mode 100644
index 0000000..4f36139
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.test.js
@@ -0,0 +1,50 @@
+/*
+ * 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("test numbers of tabgroupindex", function (assert) {
+ var $tabOne = jQueryFrame("#page\\:mainForm\\:tabOne");
+ var $tabTwo = jQueryFrame("#page\\:mainForm\\:tabTwo");
+ var $tabThree = jQueryFrame("#page\\:mainForm\\:tabThree");
+ var $tabFour = jQueryFrame("#page\\:mainForm\\:tabFour");
+ var $tabFive = jQueryFrame("#page\\:mainForm\\:tabFive");
+ var $tabOneContent = jQueryFrame("#page\\:mainForm\\:tabOne\\:\\:content");
+ var $tabTwoContent = jQueryFrame("#page\\:mainForm\\:tabTwo\\:\\:content");
+ var $tabThreeContent = jQueryFrame("#page\\:mainForm\\:tabThree\\:\\:content");
+ var $tabFourContent = jQueryFrame("#page\\:mainForm\\:tabFour\\:\\:content");
+ var $tabFiveContent = jQueryFrame("#page\\:mainForm\\:tabFive\\:\\:content");
+
+ assert.equal($tabOne.attr("tabgroupindex"), "0");
+ assert.equal($tabTwo.attr("tabgroupindex"), "1");
+ assert.equal($tabThree.length, 0, "Tab three is not rendered");
+ assert.equal($tabFour.attr("tabgroupindex"), "3");
+ assert.equal($tabFive.attr("tabgroupindex"), "4");
+
+ assert.equal($tabOneContent.attr("tabgroupindex"), "0");
+ assert.equal($tabTwoContent.attr("tabgroupindex"), "1");
+ assert.equal($tabThreeContent.length, 0, "Tab three content is not rendered");
+ assert.equal($tabFiveContent.attr("tabgroupindex"), "4");
+
+ assert.ok($tabOne.hasClass("tobago-tab-markup-selected"));
+ assert.notOk($tabTwo.hasClass("tobago-tab-markup-selected"));
+ assert.notOk($tabFour.hasClass("tobago-tab-markup-selected"));
+ assert.notOk($tabFive.hasClass("tobago-tab-markup-selected"));
+
+ assert.ok($tabOneContent.hasClass("active"));
+ assert.notOk($tabTwoContent.hasClass("active"));
+ assert.notOk($tabFourContent.hasClass("active"));
+ assert.notOk($tabFiveContent.hasClass("active"));
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.xhtml
new file mode 100644
index 0000000..c5d5a68
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/2500-tab/tabgroup-style.xhtml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * 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.
+-->
+
+<ui:composition template="/main.xhtml"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:tabGroup id="tabGroup">
+ <tc:style customClass="someCssClass"/>
+ <tc:tab id="tabOne" label="One">
+ First tab.
+ </tc:tab>
+ <tc:tab id="tabTwo" label="Two">
+ Second tab.
+ </tc:tab>
+ <tc:tab id="tabThree" label="Three" rendered="false">
+ not rendered
+ </tc:tab>
+ <tc:tab id="tabFour" label="Four" disabled="true">
+ disabled
+ </tc:tab>
+ <tc:tab id="tabFive" label="Five">
+ Fifth tab.
+ </tc:tab>
+ </tc:tabGroup>
+</ui:composition>
--
To stop receiving notification emails like this one, please contact
['"commits@myfaces.apache.org" <co...@myfaces.apache.org>'].