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 2016/06/20 06:34:04 UTC
svn commit: r1749268 - in /myfaces/tobago/trunk:
tobago-core/src/main/java/org/apache/myfaces/tobago/util/
tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/
tobago-example/tobago-example-demo/src/main/webapp/conte...
Author: lofwyr
Date: Mon Jun 20 06:34:04 2016
New Revision: 1749268
URL: http://svn.apache.org/viewvc?rev=1749268&view=rev
Log:
TOBAGO-1569: AJAX should be independent from Multi-Form concept
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=1749268&r1=1749267&r2=1749268&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Mon Jun 20 06:34:04 2016
@@ -435,7 +435,8 @@ public final class ComponentUtils {
public static boolean mayValidate(final UIComponent component) {
return !isOutputOnly(component)
- && ComponentUtils.isInActiveForm(component);
+ && (FacesContext.getCurrentInstance().getPartialViewContext().isAjaxRequest()
+ || ComponentUtils.isInActiveForm(component));
}
public static boolean mayUpdateModel(final UIComponent component) {
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java?rev=1749268&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/ExecuteController.java Mon Jun 20 06:34:04 2016
@@ -0,0 +1,81 @@
+package org.apache.myfaces.tobago.example.demo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Named;
+import java.io.Serializable;
+
+@Named
+@SessionScoped
+public class ExecuteController implements Serializable {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ExecuteController.class);
+
+ private String value1;
+ private String value2;
+ private String value3;
+ private String value4;
+
+ public String clear() {
+ LOG.info("action");
+ value1=null;
+ value2=null;
+ value3=null;
+ value4=null;
+ log();
+ return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml";
+ }
+
+ public String reload() {
+ LOG.info("reload");
+ log();
+ return "/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml";
+ }
+
+ public String action() {
+ LOG.info("action");
+ log();
+ return null;
+ }
+
+ private void log() {
+ LOG.info("value1='{}'", value1);
+ LOG.info("value2='{}'", value2);
+ LOG.info("value3='{}'", value3);
+ LOG.info("value4='{}'", value4);
+ }
+
+ public String getValue1() {
+ return value1;
+ }
+
+ public void setValue1(String value1) {
+ this.value1 = value1;
+ }
+
+ public String getValue2() {
+ return value2;
+ }
+
+ public void setValue2(String value2) {
+ this.value2 = value2;
+ }
+
+ public String getValue3() {
+ return value3;
+ }
+
+ public void setValue3(String value3) {
+ this.value3 = value3;
+ }
+
+ public String getValue4() {
+ return value4;
+ }
+
+ public void setValue4(String value4) {
+ this.value4 = value4;
+ }
+}
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.test.js?rev=1749268&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.test.js (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.test.js Mon Jun 20 06:34:04 2016
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+function jQueryFrame(expression) {
+ return document.getElementById("page:testframe").contentWindow.jQuery(expression);
+}
+
+QUnit.test("ajax excecute", function (assert) {
+
+ var $in1;
+ var $in2;
+ var $in3;
+ var $in4;
+
+ var $clearButton = jQueryFrame("#page\\:clear");
+ $clearButton.click();
+
+ $in1 = jQueryFrame("#page\\:in1\\:\\:field");
+ $in2 = jQueryFrame("#page\\:in2\\:\\:field");
+ $in3 = jQueryFrame("#page\\:in3\\:\\:field");
+ $in4 = jQueryFrame("#page\\:in4\\:\\:field");
+
+ assert.equal($in1.val(), "");
+ assert.equal($in2.val(), "");
+ assert.equal($in3.val(), "");
+ assert.equal($in4.val(), "");
+
+ $in1.val("a");
+ $in2.val("b");
+ $in3.val("c");
+ $in4.val("d");
+
+ var $submitButton = jQueryFrame("#page\\:clear");
+ $submitButton.click();
+
+ // todo: to be continued...
+
+});
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml?rev=1749268&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/50000-java/20-ajax-execute/ajax-execute.xhtml Mon Jun 20 06:34:04 2016
@@ -0,0 +1,65 @@
+<?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:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:f="http://java.sun.com/jsf/core">
+
+ <ui:param name="title" value="TODO"/>
+
+ This test is for
+ <tc:link
+ label="TOBAGO-1569: AJAX should be independent from Multi-Form concept"
+ link="https://issues.apache.org/jira/browse/TOBAGO-1569"/>.
+
+ <tc:in label="Field 1" id="in1" value="#{executeController.value1}"/>
+ <tc:in label="Field 2" id="in2" value="#{executeController.value2}"/>
+
+ <tc:box id="box" label="Box">
+ <tc:in label="Field 3" id="in3" value="#{executeController.value3}"/>
+ <tc:in label="Field 4" id="in4" value="#{executeController.value4}"/>
+ </tc:box>
+
+ <tc:segmentLayout medium="2;10">
+
+ <tc:button label="1. Clear" action="#{executeController.clear}" id="clear" immediate="true"/>
+ <tc:out value="Sets all 4 values to null"/>
+
+ <tc:button label="2. Manually" omit="true"/>
+ <tc:out value="Fill fields with some values, e.g. a, b, c, d."/>
+
+ <tc:button label="3. Submit" action="#{executeController.action}" id="submit">
+ <f:ajax execute="in1 in3" render="box"/>
+ </tc:button>
+ <tc:out value="Execute field 1 and 3 and render the box.
+ The result is, field 1, 2 and 3 are set and field 4 is cleared.
+ This is, because field 1 and 2 are not rendered (so they are untouched).
+ Field 3 and 4 are rerendered, but only filed 3 has a value, because it was executed
+ in contrast to field 4."/>
+
+ <tc:button label="4. Full Reload" id="reload" immediate="true">
+ <tc:resetInputActionListener/>
+ </tc:button>
+ <tc:out value="Shows values from server.
+ The result is, field 1 and 3 are set and field 2 and 4 is cleared."/>
+
+ </tc:segmentLayout>
+
+</ui:composition>
\ No newline at end of file