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 2017/01/11 12:56:10 UTC
svn commit: r1778288 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/
tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/
tobago-example/tobago-example-dem...
Author: lofwyr
Date: Wed Jan 11 12:56:10 2017
New Revision: 1778288
URL: http://svn.apache.org/viewvc?rev=1778288&view=rev
Log:
TOBAGO-1649 <tc:treeSelect> only works with selectable-mode: multi,
multiLeafOnly and multiCascade
* fix selectable modes: single and singleLeafOnly
* test added for <tc:treeSelect>
[developed by hnoeth]
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.test.js
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.xhtml
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/internal/renderkit/renderer/TreeSelectRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java?rev=1778288&r1=1778287&r2=1778288&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/TreeSelectRenderer.java Wed Jan 11 12:56:10 2017
@@ -149,7 +149,7 @@ public class TreeSelectRenderer extends
private String getClientIdWithoutRowIndex(final AbstractUIData data, final String id) {
final char separatorChar = UINamingContainer.getSeparatorChar(FacesContext.getCurrentInstance());
- return id.replace("" + separatorChar + data.getRowIndex() + separatorChar, "" + separatorChar);
+ return id.substring(0, id.indexOf("" + separatorChar + data.getRowIndex() + separatorChar));
}
@Override
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java?rev=1778288&r1=1778287&r2=1778288&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/TreeSelectController.java Wed Jan 11 12:56:10 2017
@@ -48,6 +48,16 @@ public class TreeSelectController implem
public void setSelectable(String selectable) {
this.selectable = selectable;
+ resetSelection(sample);
+ }
+
+ public void resetSelection(DefaultMutableTreeNode node) {
+ Node userObject = (Node) node.getUserObject();
+ userObject.setSelected(false);
+ for (int i = 0; i < node.getChildCount(); i++) {
+ DefaultMutableTreeNode child = (DefaultMutableTreeNode) node.getChildAt(i);
+ resetSelection(child);
+ }
}
public String getSelectedNodes() {
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.test.js?rev=1778288&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.test.js (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.test.js Wed Jan 11 12:56:10 2017
@@ -0,0 +1,320 @@
+/*
+ * 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("single: select Music, select Mathematics", function(assert) {
+ assert.expect(4);
+ var done = assert.async(4);
+ var $music = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:3\\:select");
+ var $mathematics = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:9\\:select");
+ var $output = jQueryFrame("#page\\:mainForm\\:selectedNodesOutput span");
+ var $selectableNone = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:0");
+ var $selectableSingle = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:1");
+
+ $selectableNone.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length == 0;
+ }, function() {
+ assert.equal(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $selectableSingle = jQueryFrame($selectableSingle.selector);
+ $selectableSingle.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length > 0;
+ }, function() {
+ assert.notEqual(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $music = jQueryFrame($music.selector);
+ $music.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music");
+
+ $mathematics = jQueryFrame($mathematics.selector);
+ $mathematics.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Mathematics");
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+});
+
+QUnit.test("singleLeafOnly: select Classic, select Mathematics", function(assert) {
+ assert.expect(4);
+ var done = assert.async(4);
+ var $classic = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:4\\:select");
+ var $mathematics = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:9\\:select");
+ var $output = jQueryFrame("#page\\:mainForm\\:selectedNodesOutput span");
+ var $selectableNone = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:0");
+ var $selectableSingleLeafOnly = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:2");
+
+ $selectableNone.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length == 0;
+ }, function() {
+ assert.equal(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $selectableSingleLeafOnly = jQueryFrame($selectableSingleLeafOnly.selector);
+ $selectableSingleLeafOnly.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length > 0;
+ }, function() {
+ assert.notEqual(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $classic = jQueryFrame($classic.selector);
+ $classic.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Classic"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Classic");
+
+ $mathematics = jQueryFrame($mathematics.selector);
+ $mathematics.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Mathematics");
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+});
+
+QUnit.test("multi: select Music, select Mathematics, deselect Music", function(assert) {
+ assert.expect(4);
+ var done = assert.async(4);
+ var $music = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:3\\:select");
+ var $mathematics = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:9\\:select");
+ var $output = jQueryFrame("#page\\:mainForm\\:selectedNodesOutput span");
+ var $selectableNone = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:0");
+ var $selectableMulti = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:3");
+
+ $selectableNone.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length == 0;
+ }, function() {
+ assert.equal(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $selectableMulti = jQueryFrame($selectableMulti.selector);
+ $selectableMulti.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length > 0;
+ }, function() {
+ assert.notEqual(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $music = jQueryFrame($music.selector);
+ $music.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music");
+
+ $mathematics = jQueryFrame($mathematics.selector);
+ $mathematics.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music, Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music, Mathematics");
+
+ $music = jQueryFrame($music.selector);
+ $music.prop("checked", false).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Mathematics");
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+});
+
+QUnit.test("multiLeafOnly: select Classic, select Mathematics, deselect Classic", function(assert) {
+ assert.expect(4);
+ var done = assert.async(4);
+ var $classic = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:4\\:select");
+ var $mathematics = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:9\\:select");
+ var $output = jQueryFrame("#page\\:mainForm\\:selectedNodesOutput span");
+ var $selectableNone = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:0");
+ var $selectableMultiLeafOnly = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:4");
+
+ $selectableNone.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length == 0;
+ }, function() {
+ assert.equal(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $selectableMultiLeafOnly = jQueryFrame($selectableMultiLeafOnly.selector);
+ $selectableMultiLeafOnly.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length > 0;
+ }, function() {
+ assert.notEqual(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $classic = jQueryFrame($classic.selector);
+ $classic.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Classic"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Classic");
+
+ $mathematics = jQueryFrame($mathematics.selector);
+ $mathematics.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Classic, Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Classic, Mathematics");
+
+ $classic = jQueryFrame($classic.selector);
+ $classic.prop("checked", false).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Mathematics");
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+});
+
+QUnit.test("multiCascade: select Music, select Mathematics, deselect Classic", function(assert) {
+ assert.expect(4);
+ var done = assert.async(4);
+ var $music = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:3\\:select");
+ var $classic = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:4\\:select");
+ var $pop = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:5\\:select");
+ var $world = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:6\\:select");
+ var $mathematics = jQueryFrame("#page\\:mainForm\\:categoriesTree\\:9\\:select");
+ var $output = jQueryFrame("#page\\:mainForm\\:selectedNodesOutput span");
+ var $selectableNone = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:0");
+ var $selectableMultiCascade = jQueryFrame("#page\\:mainForm\\:selectable\\:\\:5");
+
+ $selectableNone.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length == 0;
+ }, function() {
+ assert.equal(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $selectableMultiCascade = jQueryFrame($selectableMultiCascade.selector);
+ $selectableMultiCascade.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ return jQueryFrame(".tobago-treeSelect input").length > 0;
+ }, function() {
+ assert.notEqual(jQueryFrame(".tobago-treeSelect input").length, 0);
+
+ $music = jQueryFrame($music.selector);
+ $music.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music, Classic, Pop, World"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music, Classic, Pop, World");
+
+ $mathematics = jQueryFrame($mathematics.selector);
+ $mathematics.prop("checked", true).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music, Classic, Pop, World, Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music, Classic, Pop, World, Mathematics");
+
+ $classic = jQueryFrame($classic.selector);
+ $classic.prop("checked", false).trigger("change");
+
+ waitForAjax(function() {
+ $output = jQueryFrame($output.selector);
+ return $output.text() == "Music, Pop, World, Mathematics"
+ }, function() {
+ $output = jQueryFrame($output.selector);
+ assert.equal($output.text(), "Music, Pop, World, Mathematics");
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+ done();
+ });
+});
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.xhtml?rev=1778288&r1=1778287&r2=1778288&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/090-tree/01-select/tree-select.xhtml Wed Jan 11 12:56:10 2017
@@ -37,19 +37,19 @@
The value of the attribute in this example can be changed by the radio buttons in the contentbox on the right.</p>
<tc:panel id="examplePanel">
<tc:flexLayout columns="*;auto">
- <tc:tree value="#{treeSelectController.sample}" var="node" showRoot="true"
+ <tc:tree id="categoriesTree" value="#{treeSelectController.sample}" var="node" showRoot="true"
selectable="#{treeSelectController.selectable}">
<tc:treeNode>
<tc:treeIndent/>
- <tc:treeSelect label="#{node.userObject.name}" value="#{node.userObject.selected}">
+ <tc:treeSelect id="select" label="#{node.userObject.name}" value="#{node.userObject.selected}">
<f:ajax render=":::selectedNodesOutput"/>
</tc:treeSelect>
</tc:treeNode>
</tc:tree>
<tc:panel>
<tc:box label="selectable">
- <tc:selectOneRadio value="#{treeSelectController.selectable}">
- <f:ajax render="examplePanel"/>
+ <tc:selectOneRadio id="selectable" value="#{treeSelectController.selectable}">
+ <f:ajax render="examplePanel selectedNodesOutput"/>
<tc:selectItem itemLabel="none" itemValue="none"/>
<tc:selectItem itemLabel="single" itemValue="single"/>
<tc:selectItem itemLabel="singleLeafOnly" itemValue="singleLeafOnly"/>
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=1778288&r1=1778287&r2=1778288&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 Wed Jan 11 12:56:10 2017
@@ -320,6 +320,12 @@ public class QUnitTests {
}
@Test
+ public void treeSelect() throws UnsupportedEncodingException, InterruptedException {
+ String page = "content/20-component/090-tree/01-select/tree-select.xhtml";
+ runStandardTest(page);
+ }
+
+ @Test
public void contentValidation() throws UnsupportedEncodingException, InterruptedException {
String page = "content/30-concept/06-validation/00/content-validation.xhtml";
runStandardTest(page);