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/02/09 15:00:49 UTC
svn commit: r1782340 - in
/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main:
java/org/apache/myfaces/tobago/example/demo/
webapp/content/40-test/6000-event/
Author: lofwyr
Date: Thu Feb 9 15:00:48 2017
New Revision: 1782340
URL: http://svn.apache.org/viewvc?rev=1782340&view=rev
Log:
Demo: Improve tests for ClientBehaviors
* remove c:forEach function
* cleanup event.test.js
* add test for <tc:selectBooleanCheckbox>
* add test for <tc:textarea>
[developed by hnoeth]
Added:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-selectBooleanCheckbox.xhtml
Removed:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-component-content.xhtml
Modified:
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.test.js
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-bar.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-button.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-in.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-row.xhtml
myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-textarea.xhtml
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/EventController.java Thu Feb 9 15:00:48 2017
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.compone
import org.apache.myfaces.tobago.component.UIButton;
import org.apache.myfaces.tobago.component.UIIn;
import org.apache.myfaces.tobago.component.UIRow;
+import org.apache.myfaces.tobago.component.UISelectBooleanCheckbox;
import org.apache.myfaces.tobago.component.UITextarea;
import org.apache.myfaces.tobago.example.data.SolarObject;
import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -31,7 +32,6 @@ import javax.enterprise.context.SessionS
import javax.faces.component.UIData;
import javax.faces.event.ActionEvent;
import javax.faces.event.AjaxBehaviorEvent;
-import javax.faces.event.FacesEvent;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Named;
import java.io.Serializable;
@@ -48,18 +48,20 @@ public class EventController implements
private List<EventsOnComponent> eventsOnComponents = new ArrayList<EventsOnComponent>();
private EventsOnComponent selectedComponent;
+ private String eventName;
private int action = 0;
private int actionListener = 0;
private int ajaxListener = 0;
private int valueChangeListener = 0;
private List<SolarObject> planets = new ArrayList<SolarObject>();
- private String selectedPlanet;
public EventController() {
eventsOnComponents.add(new EventsOnComponent("bar", new UIBar().getEventNames()));
eventsOnComponents.add(new EventsOnComponent("button", new UIButton().getEventNames()));
eventsOnComponents.add(new EventsOnComponent("in", new UIIn().getEventNames()));
eventsOnComponents.add(new EventsOnComponent("row", new UIRow().getEventNames()));
+ eventsOnComponents.add(new EventsOnComponent("selectBooleanCheckbox",
+ new UISelectBooleanCheckbox().getEventNames()));
eventsOnComponents.add(new EventsOnComponent("textarea", new UITextarea().getEventNames()));
planets.add(new SolarObject("Mercury", "I", "Sun", 57910, 87.97, 7.00, 0.21, "-", null));
@@ -77,7 +79,6 @@ public class EventController implements
actionListener = 0;
ajaxListener = 0;
valueChangeListener = 0;
- selectedPlanet = null;
}
public List<EventsOnComponent> getEventsOnComponents() {
@@ -88,13 +89,18 @@ public class EventController implements
return selectedComponent;
}
- public void setSelectedComponent(EventsOnComponent selectedComponent) {
- this.selectedComponent = selectedComponent;
+ public String getEventName() {
+ return eventName;
+ }
+
+ public String getInclude() {
+ return selectedComponent != null ? "x-event-" + selectedComponent.getTagName() + ".xhtml" : "";
}
public void selectComponent(final ActionEvent actionEvent) {
final UIData data = ComponentUtils.findAncestor(actionEvent.getComponent(), UIData.class);
selectedComponent = data != null ? ((EventsOnComponent) data.getRowData()) : null;
+ eventName = actionEvent.getComponent().getAttributes().get("eventName").toString();
}
public void action() {
@@ -137,19 +143,6 @@ public class EventController implements
return planets;
}
- public String getSelectedPlanet() {
- return selectedPlanet;
- }
-
- public void setSelectedPlanet(String selectedPlanet) {
- this.selectedPlanet = selectedPlanet;
- }
-
- public void selectPlanet(final FacesEvent actionEvent) {
- final UIData data = ComponentUtils.findAncestor(actionEvent.getComponent(), UIData.class);
- selectedPlanet = data != null ? ((SolarObject) data.getRowData()).getName() : null;
- }
-
public class EventsOnComponent {
private String tagName;
private Set<String> eventNames = new TreeSet<String>();
@@ -165,54 +158,60 @@ public class EventController implements
return tagName;
}
- public Set<String> getEventNames() {
- return eventNames;
+ public boolean hasBlurEvent() {
+ return eventNames.contains(CommonEvent.blur.name());
}
- public String getChangeEvent() {
- return getCommonEventString(CommonEvent.change);
+ public boolean hasChangeEvent() {
+ return eventNames.contains(CommonEvent.change.name());
}
- public String getClickEvents() {
- return getCommonEventString(CommonEvent.click, CommonEvent.dblclick);
+ public boolean hasClickEvent() {
+ return eventNames.contains(CommonEvent.click.name());
}
- public String getFocusEvents() {
- return getCommonEventString(CommonEvent.focus, CommonEvent.blur);
+ public boolean hasDblclickEvent() {
+ return eventNames.contains(CommonEvent.dblclick.name());
}
- public String getKeyEvents() {
- return getCommonEventString(CommonEvent.keydown, CommonEvent.keypress, CommonEvent.keyup);
+ public boolean hasFocusEvent() {
+ return eventNames.contains(CommonEvent.focus.name());
}
- public String getMouseEvents() {
- return getCommonEventString(CommonEvent.mousedown, CommonEvent.mousemove, CommonEvent.mouseout,
- CommonEvent.mouseover, CommonEvent.mouseup);
+ public boolean hasKeydownEvent() {
+ return eventNames.contains(CommonEvent.keydown.name());
}
- public String getSelectEvent() {
- return getCommonEventString(CommonEvent.select);
+ public boolean hasKeypressEvent() {
+ return eventNames.contains(CommonEvent.keypress.name());
}
- private String getCommonEventString(CommonEvent... commonEvents) {
- boolean allTrue = true;
- boolean allFalse = true;
+ public boolean hasKeyupEvent() {
+ return eventNames.contains(CommonEvent.keyup.name());
+ }
- for (CommonEvent commonEvent : commonEvents) {
- if (eventNames.contains(commonEvent.name())) {
- allFalse = false;
- } else {
- allTrue = false;
- }
- }
+ public boolean hasMousedownEvent() {
+ return eventNames.contains(CommonEvent.mousedown.name());
+ }
- if (allTrue) {
- return "x";
- } else if (allFalse) {
- return "-";
- } else {
- return concatStrings(eventNames);
- }
+ public boolean hasMousemoveEvent() {
+ return eventNames.contains(CommonEvent.mousemove.name());
+ }
+
+ public boolean hasMouseoutEvent() {
+ return eventNames.contains(CommonEvent.mouseout.name());
+ }
+
+ public boolean hasMouseoverEvent() {
+ return eventNames.contains(CommonEvent.mouseover.name());
+ }
+
+ public boolean hasMouseupEvent() {
+ return eventNames.contains(CommonEvent.mouseup.name());
+ }
+
+ public boolean hasSelectEvent() {
+ return eventNames.contains(CommonEvent.select.name());
}
public String getSpecialEvents() {
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.test.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.test.js?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.test.js (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.test.js Thu Feb 9 15:00:48 2017
@@ -15,350 +15,197 @@
* limitations under the License.
*/
-QUnit.test("tc:button tc:event - blur", function(assert) {
- testButtonEvent(assert, "blur");
+QUnit.test("tc:button", function(assert) {
+ var eventNames = ["click", "dblclick", "focus", "blur"];
+ var $eventComponent = jQueryFrame("#page\\:mainForm\\:buttonevent");
+ var $ajaxComponent = jQueryFrame("#page\\:mainForm\\:buttonajax");
+ testEvent(assert, "button", eventNames, $eventComponent, $ajaxComponent, null);
});
-QUnit.test("tc:button tc:event - click", function(assert) {
- testButtonEvent(assert, "click");
-});
-
-QUnit.test("tc:button tc:event - dblclick", function(assert) {
- testButtonEvent(assert, "dblclick");
-});
-
-QUnit.test("tc:button tc:event - focus", function(assert) {
- testButtonEvent(assert, "focus");
-});
-
-QUnit.test("tc:button f:ajax - blur", function(assert) {
- testButtonAjax(assert, "blur");
-});
-
-QUnit.test("tc:button f:ajax - click", function(assert) {
- testButtonAjax(assert, "click");
-});
-
-QUnit.test("tc:button f:ajax - dblclick", function(assert) {
- testButtonAjax(assert, "dblclick");
-});
-
-QUnit.test("tc:button f:ajax - focus", function(assert) {
- testButtonAjax(assert, "focus");
-});
-
-QUnit.test("tc:in tc:event - blur", function(assert) {
- testInEvent(assert, "blur");
-});
-
-QUnit.test("tc:in tc:event - change", function(assert) {
- testInEvent(assert, "change");
-});
-
-QUnit.test("tc:in tc:event - click", function(assert) {
- testInEvent(assert, "click");
-});
-
-QUnit.test("tc:in tc:event - dblclick", function(assert) {
- testInEvent(assert, "dblclick");
-});
-
-QUnit.test("tc:in tc:event - focus", function(assert) {
- testInEvent(assert, "focus");
-});
-
-QUnit.test("tc:in f:ajax - blur", function(assert) {
- testInAjax(assert, "blur");
-});
-
-QUnit.test("tc:in f:ajax - change", function(assert) {
- testInAjax(assert, "change");
-});
-QUnit.test("tc:in f:ajax - click", function(assert) {
- testInAjax(assert, "click");
-});
-QUnit.test("tc:in f:ajax - dblclick", function(assert) {
- testInAjax(assert, "dblclick");
-});
-QUnit.test("tc:in f:ajax - focus", function(assert) {
- testInAjax(assert, "focus");
-});
-
-QUnit.test("tc:row tc:event - click", function(assert) {
- testRowEvent(assert, "click");
-});
-
-QUnit.test("tc:row tc:event - dblclick", function(assert) {
- testRowEvent(assert, "dblclick");
-});
-
-QUnit.test("tc:row f:ajax - click", function(assert) {
- testRowAjax(assert, "click");
-});
-
-QUnit.test("tc:row f:ajax - dblclick", function(assert) {
- testRowAjax(assert, "dblclick");
-});
-
-function testButtonEvent(assert, eventName) {
- testEvent(assert, "button", function() {
- return jQueryFrame("#page\\:mainForm\\:buttonevent" + eventName + "\\:\\:command");
- }, eventName, true, true, false, false, false);
-}
-
-function testButtonAjax(assert, eventName) {
- testAjax(assert, "button", function() {
- return jQueryFrame("#page\\:mainForm\\:buttonajax" + eventName);
- }, eventName, false, false, true, false, false);
-}
-
-function testInEvent(assert, eventName) {
- testEvent(assert, "in", function() {
- var $inputField = jQueryFrame("#page\\:mainForm\\:inevent" + eventName + "\\:\\:field");
- var newValue = "hello";
- if (newValue == $inputField.val()) {
- newValue = "hi there";
- }
- $inputField.val(newValue);
- return $inputField;
- }, eventName, true, true, false, true, false);
-}
-
-function testInAjax(assert, eventName) {
- testAjax(assert, "in", function() {
- var $inputField = jQueryFrame("#page\\:mainForm\\:inajax" + eventName + "\\:\\:field");
+QUnit.test("tc:in", function(assert) {
+ var eventNames = ["change", "click", "dblclick", "focus", "blur"];
+ var $eventComponent = jQueryFrame("#page\\:mainForm\\:inevent\\:\\:field");
+ var $ajaxComponent = jQueryFrame("#page\\:mainForm\\:inajax\\:\\:field");
+ var changeValue = function($component) {
+ var oldValue = $component.val();
var newValue = "hello";
- if (newValue == $inputField.val()) {
- newValue = "hi there";
+ if (oldValue == "hello") {
+ newValue = "hello there!"
}
- $inputField.val(newValue);
- return $inputField;
- }, eventName, false, false, true, true, false);
-}
-
-function testRowEvent(assert, eventName) {
- var newSelectedPlanet = "Venus";
- testEvent(assert, "row", function() {
- var $row = jQueryFrame("#page\\:mainForm\\:sheetevent" + eventName + "\\:1\\:selectPlanet");
- if (getSelectedPlanet() == newSelectedPlanet) {
- $row = jQueryFrame("#page\\:mainForm\\:sheetevent" + eventName + "\\:4\\:selectPlanet");
- newSelectedPlanet = "Jupiter";
+ return $component.val(newValue);
+ };
+ testEvent(assert, "in", eventNames, $eventComponent, $ajaxComponent, changeValue);
+});
+
+QUnit.test("tc:row", function(assert) {
+ var eventNames = ["click", "dblclick"];
+ var $eventComponent = jQueryFrame("#page\\:mainForm\\:sheetevent\\:0\\:selectPlanet");
+ var $ajaxComponent = jQueryFrame("#page\\:mainForm\\:sheetajax\\:0\\:selectPlanet");
+ testEvent(assert, "row", eventNames, $eventComponent, $ajaxComponent, null);
+});
+
+QUnit.test("tc:selectBooleanCheckbox", function(assert) {
+ var eventNames = ["change", "click", "dblclick", "focus", "blur"];
+ var $eventComponent = jQueryFrame("#page\\:mainForm\\:selectBooleanCheckboxevent\\:\\:field");
+ var $ajaxComponent = jQueryFrame("#page\\:mainForm\\:selectBooleanCheckboxajax\\:\\:field");
+ var changeValue = function($component) {
+ var currentEvent = jQueryFrame("#page\\:mainForm\\:outEventName span").text();
+ if (currentEvent != "click") {
+ console.log("old -- currentEvent: " + currentEvent + " isChecked: " + $component.prop("checked"));
+ return $component.prop("checked", !$component.prop("checked"));
+ console.log("new -- currentEvent: " + currentEvent + " isChecked: " + $component.prop("checked"));
+ } else {
+ return $component;
}
- return $row;
- }, eventName, true, false, false, false, true);
-}
+ };
+ testEvent(assert, "selectBooleanCheckbox", eventNames, $eventComponent, $ajaxComponent, changeValue);
+});
-function testRowAjax(assert, eventName) {
- var newSelectedPlanet = "Venus";
- testAjax(assert, "row", function() {
- var $row = jQueryFrame("#page\\:mainForm\\:sheetajax" + eventName + "\\:1\\:selectPlanet");
- if (getSelectedPlanet() == newSelectedPlanet) {
- $row = jQueryFrame("#page\\:mainForm\\:sheetajax" + eventName + "\\:4\\:selectPlanet");
- newSelectedPlanet = "Jupiter";
+QUnit.test("tc:textarea", function(assert) {
+ var eventNames = ["change", "click", "dblclick", "focus", "blur"];
+ var $eventComponent = jQueryFrame("#page\\:mainForm\\:textareaevent\\:\\:field");
+ var $ajaxComponent = jQueryFrame("#page\\:mainForm\\:textareaajax\\:\\:field");
+ var changeValue = function($component) {
+ var oldValue = $component.val();
+ var newValue = "hello";
+ if (oldValue == "hello") {
+ newValue = "hello there!"
}
- return $row;
- }, eventName, false, false, false, false, true);
-}
+ return $component.val(newValue);
+ };
+ testEvent(assert, "textarea", eventNames, $eventComponent, $ajaxComponent, changeValue);
+});
-function testEvent(assert, componentName, componentFunc, event,
- incAction, incActionListener, incAjaxListener, incValueChangeListener, changePlanet) {
- assert.expect(6);
- var changeActiveComponent = jQueryFrame("#page\\:mainForm\\:compTestSection > div > h1 > span").text()
- != "<tc:" + componentName + ">";
- var done = assert.async(1 + changeActiveComponent);
+function testEvent(assert, componentName, eventNames, $eventComponent, $ajaxComponent, changeValue) {
+ assert.expect(10 * eventNames.length);
+ var step = 0;
+ var done = assert.async(3 * eventNames.length);
var oldActionCount;
var oldActionListenerCount;
var oldAjaxListenerCount;
var oldValueChangeListenerCount;
var oldTimestamp;
- var oldPlanet;
-
- if (changeActiveComponent) {
- activateComponent(componentName);
- var step = 1;
-
- jQuery("#page\\:testframe").load(function() {
- if (step == 1) {
- oldActionCount = getActionCount();
- oldActionListenerCount = getActionListenerCount();
- oldAjaxListenerCount = getAjaxListenerCount();
- oldValueChangeListenerCount = getValueChangeListenerCount();
- oldTimestamp = getTimestamp();
- oldPlanet = getSelectedPlanet();
-
- componentFunc().trigger(event);
- } else if (step == 2) {
- validateEvent(assert, oldActionCount, oldActionListenerCount, oldAjaxListenerCount,
- oldValueChangeListenerCount, oldTimestamp, oldPlanet, incAction, incActionListener, incAjaxListener,
- incValueChangeListener, changePlanet);
- }
- step++;
- done();
- });
- } else {
- oldActionCount = getActionCount();
- oldActionListenerCount = getActionListenerCount();
- oldAjaxListenerCount = getAjaxListenerCount();
- oldValueChangeListenerCount = getValueChangeListenerCount();
- oldTimestamp = getTimestamp();
- oldPlanet = getSelectedPlanet();
-
- componentFunc().trigger(event);
-
- jQuery("#page\\:testframe").load(function() {
- validateEvent(assert, oldActionCount, oldActionListenerCount, oldAjaxListenerCount, oldValueChangeListenerCount,
- oldTimestamp, oldPlanet, incAction, incActionListener, incAjaxListener, incValueChangeListener, changePlanet);
-
- done();
- });
- }
-}
-function validateEvent(assert, oldActionCount, oldActionListenerCount, oldAjaxListenerCount,
- oldValueChangeListenerCount, oldTimestamp, oldPlanet, incAction, incActionListener,
- incAjaxListener, incValueChangeListener, changePlanet) {
- var newActionCount = getActionCount();
- var newActionListenerCount = getActionListenerCount();
- var newAjaxListenerCount = getAjaxListenerCount();
- var newValueChangeListenerCount = getValueChangeListenerCount();
- var newTimestamp = getTimestamp();
- var newPlanet = getSelectedPlanet();
-
- assert.equal(newActionCount, oldActionCount + incAction, "action");
- assert.equal(newActionListenerCount, oldActionListenerCount + incActionListener, "actionListener");
- assert.equal(newAjaxListenerCount, oldAjaxListenerCount + incAjaxListener, "ajaxListener");
- assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount + incValueChangeListener,
- "valueChangeListener");
- assert.ok(newTimestamp > oldTimestamp, "timestamp");
- if (changePlanet) {
- assert.notEqual(newPlanet, oldPlanet, "selectedPlanet");
- } else {
- assert.equal(newPlanet, oldPlanet, "selectedPlanet");
- }
-}
+ var eventName = eventNames[0];
+ activateComponent(componentName, eventName);
-function testAjax(assert, componentName, componentFunc, event,
- incAction, incActionListener, incAjaxListener, incValueChangeListener, changePlanet) {
- assert.expect(6);
- var changeActiveComponent = jQueryFrame("#page\\:mainForm\\:compTestSection > div > h1 > span").text()
- != "<tc:" + componentName + ">";
- var done = assert.async(1 + changeActiveComponent);
+ jQuery("#page\\:testframe").load(function() {
+ if (step % 3 == 0) {
+ oldActionCount = getActionCount();
+ oldActionListenerCount = getActionListenerCount();
+ oldAjaxListenerCount = getAjaxListenerCount();
+ oldValueChangeListenerCount = getValueChangeListenerCount();
+ oldTimestamp = getTimestamp();
+
+ $eventComponent = jQueryFrame($eventComponent.selector);
+ if (changeValue != null) {
+ $eventComponent = changeValue($eventComponent);
+ }
+ $eventComponent.trigger(eventName);
+ } else if (step % 3 == 1) {
+ var newActionCount = getActionCount();
+ var newActionListenerCount = getActionListenerCount();
+ var newAjaxListenerCount = getAjaxListenerCount();
+ var newValueChangeListenerCount = getValueChangeListenerCount();
+ var newTimestamp = getTimestamp();
+
+ assert.equal(newActionCount, oldActionCount + 1, eventName + " - tc:event - action");
+ assert.equal(newActionListenerCount, oldActionListenerCount + 1, eventName + " - tc:event - actionListener");
+ assert.equal(newAjaxListenerCount, oldAjaxListenerCount, eventName + " - tc:event - ajaxListener");
+ if (changeValue != null) {
+ assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount + 1,
+ eventName + " - tc:event - valueChangeListener");
+ } else {
+ assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount,
+ eventName + " - tc:event - valueChangeListener");
+ }
+ assert.ok(newTimestamp > oldTimestamp, eventName + " - tc:event - timestamp");
- var oldActionCount;
- var oldActionListenerCount;
- var oldAjaxListenerCount;
- var oldValueChangeListenerCount;
- var oldTimestamp;
- var oldPlanet;
- if (changeActiveComponent) {
- activateComponent(componentName);
- var step = 1;
-
- jQuery("#page\\:testframe").load(function() {
- if (step == 1) {
- oldActionCount = getActionCount();
- oldActionListenerCount = getActionListenerCount();
- oldAjaxListenerCount = getAjaxListenerCount();
- oldValueChangeListenerCount = getValueChangeListenerCount();
- oldTimestamp = getTimestamp();
- oldPlanet = getSelectedPlanet();
-
- componentFunc().trigger(event);
-
- validateAjax(assert, done, oldActionCount, oldActionListenerCount, oldAjaxListenerCount,
- oldValueChangeListenerCount, oldTimestamp, oldPlanet, incAction, incActionListener, incAjaxListener,
- incValueChangeListener, changePlanet);
+ oldActionCount = getActionCount();
+ oldActionListenerCount = getActionListenerCount();
+ oldAjaxListenerCount = getAjaxListenerCount();
+ oldValueChangeListenerCount = getValueChangeListenerCount();
+ oldTimestamp = getTimestamp();
+
+ $ajaxComponent = jQueryFrame($ajaxComponent.selector);
+ if (changeValue != null) {
+ $ajaxComponent = changeValue($ajaxComponent);
}
- step++;
- done();
- });
- } else {
- oldActionCount = getActionCount();
- oldActionListenerCount = getActionListenerCount();
- oldAjaxListenerCount = getAjaxListenerCount();
- oldValueChangeListenerCount = getValueChangeListenerCount();
- oldTimestamp = getTimestamp();
- oldPlanet = getSelectedPlanet();
-
- componentFunc().trigger(event);
-
- validateAjax(assert, done, oldActionCount, oldActionListenerCount, oldAjaxListenerCount,
- oldValueChangeListenerCount, oldTimestamp, oldPlanet, incAction, incActionListener, incAjaxListener,
- incValueChangeListener, changePlanet);
- }
-}
+ $ajaxComponent.trigger(eventName);
-function validateAjax(assert, done, oldActionCount, oldActionListenerCount, oldAjaxListenerCount,
- oldValueChangeListenerCount, oldTimestamp, oldPlanet, incAction, incActionListener,
- incAjaxListener, incValueChangeListener, changePlanet) {
- waitForAjax(function() {
- var newActionCount = getActionCount();
- var newActionListenerCount = getActionListenerCount();
- var newAjaxListenerCount = getAjaxListenerCount();
- var newValueChangeListenerCount = getValueChangeListenerCount();
- var newTimestamp = getTimestamp();
- var newPlanet = getSelectedPlanet();
-
- return newActionCount == (oldActionCount + incAction)
- && newActionListenerCount == (oldActionListenerCount + incActionListener)
- && newAjaxListenerCount == (oldAjaxListenerCount + incAjaxListener)
- && newValueChangeListenerCount == (oldValueChangeListenerCount + incValueChangeListener)
- && newTimestamp > oldTimestamp
- && changePlanet ? newPlanet != oldPlanet : newPlanet == oldPlanet;
- }, function() {
- var newActionCount = getActionCount();
- var newActionListenerCount = getActionListenerCount();
- var newAjaxListenerCount = getAjaxListenerCount();
- var newValueChangeListenerCount = getValueChangeListenerCount();
- var newTimestamp = getTimestamp();
- var newPlanet = getSelectedPlanet();
-
- assert.equal(newActionCount, oldActionCount + incAction, "action");
- assert.equal(newActionListenerCount, oldActionListenerCount + incActionListener, "actionListener");
- assert.equal(newAjaxListenerCount, oldAjaxListenerCount + incAjaxListener, "ajaxListener");
- assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount + incValueChangeListener,
- "valueChangeListener");
- assert.ok(newTimestamp > oldTimestamp, "timestamp");
- if (changePlanet) {
- assert.notEqual(newPlanet, oldPlanet, "selectedPlanet");
- } else {
- assert.equal(newPlanet, oldPlanet, "selectedPlanet");
+ waitForAjax(function() {
+ newActionCount = getActionCount();
+ newActionListenerCount = getActionListenerCount();
+ newAjaxListenerCount = getAjaxListenerCount();
+ newValueChangeListenerCount = getValueChangeListenerCount();
+ newTimestamp = getTimestamp();
+
+ return step % 3 == 2
+ && newAjaxListenerCount == oldAjaxListenerCount + 1
+ && newTimestamp > oldTimestamp;
+ }, function() {
+ newActionCount = getActionCount();
+ newActionListenerCount = getActionListenerCount();
+ newAjaxListenerCount = getAjaxListenerCount();
+ newValueChangeListenerCount = getValueChangeListenerCount();
+ newTimestamp = getTimestamp();
+
+ assert.equal(newActionCount, oldActionCount, eventName + " - f:ajax - action");
+ assert.equal(newActionListenerCount, oldActionListenerCount, eventName + " - f:ajax - actionListener");
+ assert.equal(newAjaxListenerCount, oldAjaxListenerCount + 1, eventName + " - f:ajax - ajaxListener");
+ if (changeValue != null) {
+ assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount + 1,
+ eventName + " - f:ajax - valueChangeListener");
+ } else {
+ assert.equal(newValueChangeListenerCount, oldValueChangeListenerCount,
+ eventName + " - f:ajax - valueChangeListener");
+ }
+ assert.ok(newTimestamp > oldTimestamp, eventName + " - f:ajax - timestamp");
+
+ step++;
+ done();
+
+ // activate next event
+ eventName = eventNames[step / 3];
+ activateComponent(componentName, eventName);
+ });
}
-
+ step++;
done();
- }, 3000);
+ });
+}
+
+function activateComponent(componentName, eventName) {
+ jQueryFrame("#page\\:mainForm\\:componentTable .tobago-sheet-row").each(function() {
+ if (jQuery(this).find("td").eq(0).find("span").text() == componentName) {
+ jQuery(this).find("button").each(function() {
+ var id = jQuery(this).attr("id");
+ if (id != undefined && id.indexOf(eventName + "Behavior") >= 0) {
+ this.click();
+ }
+ });
+ }
+ });
}
function getActionCount() {
- return parseInt(jQueryFrame("#page\\:mainForm\\:outAction span").text());
+ return parseInt(jQueryFrame("#page\\:mainForm\\:inAction\\:\\:field").val());
}
function getActionListenerCount() {
- return parseInt(jQueryFrame("#page\\:mainForm\\:outActionListener span").text());
+ return parseInt(jQueryFrame("#page\\:mainForm\\:inActionListener\\:\\:field").val());
}
function getAjaxListenerCount() {
- return parseInt(jQueryFrame("#page\\:mainForm\\:outAjaxListener span").text());
+ return parseInt(jQueryFrame("#page\\:mainForm\\:inAjaxListener\\:\\:field").val());
}
function getValueChangeListenerCount() {
- return parseInt(jQueryFrame("#page\\:mainForm\\:outValueChangeListener span").text());
+ return parseInt(jQueryFrame("#page\\:mainForm\\:inValueChangeListener\\:\\:field").val());
}
function getTimestamp() {
- return parseInt(jQueryFrame("#page\\:mainForm\\:outTimestamp span").text());
-}
-
-function getSelectedPlanet() {
- return jQueryFrame("#page\\:mainForm\\:inPlanet\\:\\:field").val()
-}
-
-function activateComponent(componentName) {
- jQueryFrame("#page\\:mainForm\\:componentTable .tobago-sheet-row").each(function() {
- if (jQuery(this).find("td").eq(0).find("span").text() == componentName) {
- this.click();
- }
- });
+ return parseInt(jQueryFrame("#page\\:mainForm\\:inTimestamp\\:\\:field").val());
}
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/event.xhtml Thu Feb 9 15:00:48 2017
@@ -21,83 +21,148 @@
xmlns="http://www.w3.org/1999/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"
- xmlns:c="http://java.sun.com/jsp/jstl/core">
+ xmlns:f="http://java.sun.com/jsf/core">
<ui:param name="title" value="<tc:event>"/>
- <tc:box id="metrics" label="Metrics" rendered="#{eventController.selectedComponent != null}">
+ <tc:style file="#{request.contextPath}/style/tobago.css"/>
+
+ <tc:box id="metrics" label="Metrics">
<f:facet name="bar">
<tc:button label="Reset" action="#{eventController.reset}"/>
</f:facet>
- <tc:out id="outAction" label="Action" value="#{eventController.actionCount}"/>
- <tc:out id="outActionListener" label="ActionListener" value="#{eventController.actionListenerCount}"/>
- <tc:out id="outAjaxListener" label="AjaxListener" value="#{eventController.ajaxListenerCount}"/>
- <tc:out id="outValueChangeListener" label="ValueChange-Listener"
- value="#{eventController.valueChangeListenerCount}"/>
- <tc:separator/>
- <tc:out id="outTimestamp" label="Timestamp" value="#{eventController.currentTimestamp}"/>
- <tc:in id="inPlanet" label="Selected planet" value="#{eventController.selectedPlanet}"/>
+ <tc:in id="inAction" label="Action" value="#{eventController.actionCount}" readonly="true" focus="true"/>
+ <tc:in id="inActionListener" label="ActionListener" value="#{eventController.actionListenerCount}"
+ readonly="true"/>
+ <tc:in id="inAjaxListener" label="AjaxListener" value="#{eventController.ajaxListenerCount}" readonly="true"/>
+ <tc:in id="inValueChangeListener" label="ValueChange-Listener" value="#{eventController.valueChangeListenerCount}"
+ readonly="true"/>
+ <tc:in id="inTimestamp" label="Timestamp" value="#{eventController.currentTimestamp}" readonly="true"/>
</tc:box>
- <tc:section id="compTestSection" label="<tc:#{eventController.selectedComponent.tagName}>"
- rendered="#{eventController.selectedComponent != null}">
- <tc:segmentLayout medium="6;6">
- <tc:box label="<tc:event>">
- <c:forEach items="#{eventController.selectedComponent.eventNames}" var="event">
- <ui:include src="#{'x-event-'.concat(eventController.selectedComponent.tagName).concat('.xhtml')}">
- <ui:param name="type" value="event"/>
- <ui:param name="event" value="#{event}"/>
- </ui:include>
- </c:forEach>
+ <tc:box id="compTestBox" label="Test Box" rendered="#{eventController.selectedComponent != null}">
+ <tc:out id="outComponent" label="Component" value="<tc:#{eventController.selectedComponent.tagName}>"/>
+ <tc:out id="outEventName" label="Event Name" value="#{eventController.eventName}"/>
+ <tc:segmentLayout extraSmall="6;6">
+ <tc:box label="Event">
+ <ui:include src="x-event-#{eventController.selectedComponent.tagName}.xhtml">
+ <ui:param name="tag" value="#{eventController.selectedComponent.tagName}"/>
+ <ui:param name="eventName" value="#{eventController.eventName}"/>
+ <ui:param name="eventType" value="event"/>
+ </ui:include>
</tc:box>
- <tc:box label="<f:ajax>">
- <c:forEach items="#{eventController.selectedComponent.eventNames}" var="event">
- <ui:include src="#{'x-event-'.concat(eventController.selectedComponent.tagName).concat('.xhtml')}">
- <ui:param name="type" value="ajax"/>
- <ui:param name="event" value="#{event}"/>
- </ui:include>
- </c:forEach>
+ <tc:box label="Ajax">
+ <ui:include src="x-event-#{eventController.selectedComponent.tagName}.xhtml">
+ <ui:param name="tag" value="#{eventController.selectedComponent.tagName}"/>
+ <ui:param name="eventName" value="#{eventController.eventName}"/>
+ <ui:param name="eventType" value="ajax"/>
+ </ui:include>
</tc:box>
</tc:segmentLayout>
- </tc:section>
+ </tc:box>
- <tc:separator/>
- <p>click events = click, dblclick<br/>
- focus events = focus, blur<br/>
- mouse events = mousedown, mousemove, mouseout, mouseover, mouseup<br/>
- key events = keydown, keypress, keyup</p>
<tc:sheet id="componentTable" value="#{eventController.eventsOnComponents}" var="comp" markup="small">
<tc:column label="Tag Name">
<tc:out value="#{comp.tagName}" labelLayout="skip"/>
</tc:column>
- <tc:column label="change" align="center"
- markup="#{comp.changeEvent == 'x' ? 'lightgreen' : comp.changeEvent == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.changeEvent}" labelLayout="skip"/>
- </tc:column>
- <tc:column label="click events" align="center"
- markup="#{comp.clickEvents == 'x' ? 'lightgreen' : comp.clickEvents == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.clickEvents}" labelLayout="skip"/>
- </tc:column>
- <tc:column label="focus events" align="center"
- markup="#{comp.focusEvents == 'x' ? 'lightgreen' : comp.focusEvents == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.focusEvents}" labelLayout="skip"/>
- </tc:column>
- <tc:column label="mouse events" align="center"
- markup="#{comp.mouseEvents == 'x' ? 'lightgreen' : comp.mouseEvents == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.mouseEvents}" labelLayout="skip"/>
- </tc:column>
- <tc:column label="key events" align="center"
- markup="#{comp.keyEvents == 'x' ? 'lightgreen' : comp.keyEvents == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.keyEvents}" labelLayout="skip"/>
- </tc:column>
- <tc:column label="select" align="center"
- markup="#{comp.selectEvent == 'x' ? 'lightgreen' : comp.selectEvent == '-' ? 'lightred' : ''}">
- <tc:out value="#{comp.selectEvent}" labelLayout="skip"/>
+ <tc:column label="change" align="center" markup="#{comp.hasChangeEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="changeBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasChangeEvent()}">
+ <f:attribute name="eventName" value="change"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasChangeEvent()}"/>
+ </tc:column>
+ <tc:column label="click" align="center" markup="#{comp.hasClickEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="clickBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasClickEvent()}">
+ <f:attribute name="eventName" value="click"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasClickEvent()}"/>
+ </tc:column>
+ <tc:column label="dblclick" align="center" markup="#{comp.hasDblclickEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="dblclickBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasDblclickEvent()}">
+ <f:attribute name="eventName" value="dblclick"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasDblclickEvent()}"/>
+ </tc:column>
+ <tc:column label="focus" align="center" markup="#{comp.hasFocusEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="focusBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasFocusEvent()}">
+ <f:attribute name="eventName" value="focus"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasFocusEvent()}"/>
+ </tc:column>
+ <tc:column label="blur" align="center" markup="#{comp.hasBlurEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="blurBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasBlurEvent()}">
+ <f:attribute name="eventName" value="blur"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasBlurEvent()}"/>
+ </tc:column>
+ <tc:column label="key down" align="center" markup="#{comp.hasKeydownEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="keydownBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasKeydownEvent()}">
+ <f:attribute name="eventName" value="keydown"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasKeydownEvent()}"/>
+ </tc:column>
+ <tc:column label="key press" align="center" markup="#{comp.hasKeypressEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="keypressBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasKeypressEvent()}">
+ <f:attribute name="eventName" value="keypress"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasKeypressEvent()}"/>
+ </tc:column>
+ <tc:column label="key up" align="center" markup="#{comp.hasKeyupEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="keyupBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasKeyupEvent()}">
+ <f:attribute name="eventName" value="keyup"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasKeyupEvent()}"/>
+ </tc:column>
+ <tc:column label="mouse down" align="center" markup="#{comp.hasMousedownEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="mousedownBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasMousedownEvent()}">
+ <f:attribute name="eventName" value="mousedown"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasMousedownEvent()}"/>
+ </tc:column>
+ <tc:column label="mouse move" align="center" markup="#{comp.hasMousemoveEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="mousemoveBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasMousemoveEvent()}">
+ <f:attribute name="eventName" value="mousemove"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasMousemoveEvent()}"/>
+ </tc:column>
+ <tc:column label="mouse out" align="center" markup="#{comp.hasMouseoutEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="mouseoutBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasMouseoutEvent()}">
+ <f:attribute name="eventName" value="mouseout"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasMouseoutEvent()}"/>
+ </tc:column>
+ <tc:column label="mouse over" align="center" markup="#{comp.hasMouseoverEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="mouseoverBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasMouseoverEvent()}">
+ <f:attribute name="eventName" value="mouseover"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasMouseoverEvent()}"/>
+ </tc:column>
+ <tc:column label="mouse up" align="center" markup="#{comp.hasMouseupEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="mouseupBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasMouseupEvent()}">
+ <f:attribute name="eventName" value="mouseup"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasMouseupEvent()}"/>
+ </tc:column>
+ <tc:column label="select" align="center" markup="#{comp.hasSelectEvent() ? 'lightgreen' : 'lightred'}">
+ <tc:button id="selectBehavior" label="X"
+ actionListener="#{eventController.selectComponent}" rendered="#{comp.hasSelectEvent()}">
+ <f:attribute name="eventName" value="select"/>
+ </tc:button>
+ <tc:out value="-" labelLayout="skip" rendered="#{!comp.hasSelectEvent()}"/>
</tc:column>
<tc:column label="special events">
<tc:out value="#{comp.specialEvents}" labelLayout="skip"/>
</tc:column>
- <tc:row id="selectComponent">
- <tc:event event="click" actionListener="#{eventController.selectComponent}"/>
- </tc:row>
</tc:sheet>
</ui:composition>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-.xhtml?rev=1782340&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-.xhtml Thu Feb 9 15:00:48 2017
@@ -0,0 +1,22 @@
+<?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 xmlns:ui="http://java.sun.com/jsf/facelets">
+ <!-- This is to prevent a FileNotFoundException if the value of ui:include evaluated and no component is selected. -->
+</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-bar.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-bar.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-bar.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-bar.xhtml Thu Feb 9 15:00:48 2017
@@ -20,8 +20,6 @@
<ui:composition xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns="http://www.w3.org/1999/xhtml">
- <tc:section label="#{event}">
- <tc:bar id="bar#{type}#{event}"></tc:bar>
- <p>Not implemented yet!</p>
- </tc:section>
+ <tc:bar/>
+ <p>Not implemented yet!</p>
</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-button.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-button.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-button.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-button.xhtml Thu Feb 9 15:00:48 2017
@@ -17,15 +17,31 @@
* limitations under the License.
-->
-<ui:composition xmlns:tc="http://myfaces.apache.org/tobago/component"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns="http://www.w3.org/1999/xhtml">
- <tc:section label="#{event}">
- <tc:button id="button#{type}#{event}" label="Button">
- <ui:include src="x-event-component-content.xhtml">
- <ui:param name="type" value="#{type}"/>
- <ui:param name="event" value="#{event}"/>
- </ui:include>
- </tc:button>
- </tc:section>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:button id="button#{eventType}" label="Button">
+ <c:if test="#{eventType == 'ajax'}">
+ <f:ajax event="click" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'click'}"/>
+ <f:ajax event="dblclick" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'dblclick'}"/>
+ <f:ajax event="focus" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'focus'}"/>
+ <f:ajax event="blur" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'blur'}"/>
+ </c:if>
+ <c:if test="#{eventType == 'event'}">
+ <tc:event event="click" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'click'}"/>
+ <tc:event event="dblclick" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'dblclick'}"/>
+ <tc:event event="focus" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'focus'}"/>
+ <tc:event event="blur" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'blur'}"/>
+ </c:if>
+ </tc:button>
</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-in.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-in.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-in.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-in.xhtml Thu Feb 9 15:00:48 2017
@@ -17,15 +17,35 @@
* limitations under the License.
-->
-<ui:composition xmlns:tc="http://myfaces.apache.org/tobago/component"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns="http://www.w3.org/1999/xhtml">
- <tc:section label="#{event}">
- <tc:in id="in#{type}#{event}" valueChangeListener="#{eventController.valueChangeListener}">
- <ui:include src="x-event-component-content.xhtml">
- <ui:param name="type" value="#{type}"/>
- <ui:param name="event" value="#{event}"/>
- </ui:include>
- </tc:in>
- </tc:section>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:in id="in#{eventType}" valueChangeListener="#{eventController.valueChangeListener}">
+ <c:if test="#{eventType == 'ajax'}">
+ <f:ajax event="change" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'change'}"/>
+ <f:ajax event="click" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'click'}"/>
+ <f:ajax event="dblclick" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'dblclick'}"/>
+ <f:ajax event="focus" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'focus'}"/>
+ <f:ajax event="blur" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'blur'}"/>
+ </c:if>
+ <c:if test="#{eventType == 'event'}">
+ <tc:event event="change" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'change'}"/>
+ <tc:event event="click" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'click'}"/>
+ <tc:event event="dblclick" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'dblclick'}"/>
+ <tc:event event="focus" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'focus'}"/>
+ <tc:event event="blur" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'blur'}"/>
+ </c:if>
+ </tc:in>
</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-row.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-row.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-row.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-row.xhtml Thu Feb 9 15:00:48 2017
@@ -17,140 +17,29 @@
* limitations under the License.
-->
-<ui:composition 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:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
- xmlns="http://www.w3.org/1999/xhtml">
- <tc:section label="#{event}">
- <tc:sheet id="sheet#{type}#{event}" value="#{eventController.planets}" var="planet" markup="small">
- <tc:style maxHeight="200px"/>
- <tc:column label="Planet">
- <tc:out value="#{planet.name}" labelLayout="skip"/>
- </tc:column>
- <tc:row id="selectPlanet">
- <c:if test="#{type=='event'}">
- <c:if test="#{event=='blur'}">
- <tc:event event="blur" action="#{eventController.action}" actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='change'}">
- <tc:event event="change" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='click'}">
- <tc:event event="click" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='complete'}">
- <tc:event event="complete" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='dblclick'}">
- <tc:event event="dblclick" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='focus'}">
- <tc:event event="focus" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keydown'}">
- <tc:event event="keydown" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keypress'}">
- <tc:event event="keypress" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keyup'}">
- <tc:event event="keyup" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='load'}">
- <tc:event event="load" action="#{eventController.action}" actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mousedown'}">
- <tc:event event="mousedown" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mousemove'}">
- <tc:event event="mousemove" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseout'}">
- <tc:event event="mouseout" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseover'}">
- <tc:event event="mouseover" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseup'}">
- <tc:event event="mouseup" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='resize'}">
- <tc:event event="resize" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='select'}">
- <tc:event event="select" action="#{eventController.action}"
- actionListener="#{eventController.selectPlanet}"/>
- </c:if>
- </c:if>
- <c:if test="#{type=='ajax'}">
- <c:if test="#{event=='blur'}">
- <f:ajax event="blur" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='change'}">
- <f:ajax event="change" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='click'}">
- <f:ajax event="click" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='complete'}">
- <f:ajax event="complete" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='dblclick'}">
- <f:ajax event="dblclick" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='focus'}">
- <f:ajax event="focus" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keydown'}">
- <f:ajax event="keydown" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keypress'}">
- <f:ajax event="keypress" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='keyup'}">
- <f:ajax event="keyup" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='load'}">
- <f:ajax event="load" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mousedown'}">
- <f:ajax event="mousedown" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mousemove'}">
- <f:ajax event="mousemove" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseout'}">
- <f:ajax event="mouseout" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseover'}">
- <f:ajax event="mouseover" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='mouseup'}">
- <f:ajax event="mouseup" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='resize'}">
- <f:ajax event="resize" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- <c:if test="#{event=='select'}">
- <f:ajax event="select" render=":page:mainForm:metrics" listener="#{eventController.selectPlanet}"/>
- </c:if>
- </c:if>
- </tc:row>
- </tc:sheet>
- </tc:section>
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:sheet id="sheet#{eventType}" value="#{eventController.planets}" var="planet" markup="small">
+ <tc:style maxHeight="200px"/>
+ <tc:column label="Planet">
+ <tc:out value="#{planet.name}" labelLayout="skip"/>
+ </tc:column>
+ <tc:row id="selectPlanet">
+ <c:if test="#{eventType == 'ajax'}">
+ <f:ajax event="click" render=":::metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'click'}"/>
+ <f:ajax event="dblclick" render=":::metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'dblclick'}"/>
+ </c:if>
+ <c:if test="#{eventType == 'event'}">
+ <tc:event event="click" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'click'}"/>
+ <tc:event event="dblclick" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'dblclick'}"/>
+ </c:if>
+ </tc:row>
+ </tc:sheet>
</ui:composition>
Added: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-selectBooleanCheckbox.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-selectBooleanCheckbox.xhtml?rev=1782340&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-selectBooleanCheckbox.xhtml (added)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-selectBooleanCheckbox.xhtml Thu Feb 9 15:00:48 2017
@@ -0,0 +1,52 @@
+<?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 xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:selectBooleanCheckbox id="selectBooleanCheckbox#{eventType}"
+ valueChangeListener="#{eventController.valueChangeListener}" value="true">
+ <c:if test="#{eventType == 'ajax'}">
+ <f:ajax event="change" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'change'}"/>
+ <f:ajax event="click" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'click'}"/>
+ <f:ajax event="dblclick" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'dblclick'}"/>
+ <f:ajax event="focus" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'focus'}"/>
+ <f:ajax event="blur" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'blur'}"/>
+ </c:if>
+ <c:if test="#{eventType == 'event'}">
+ <tc:event event="change" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'change'}"/>
+ <tc:event event="click" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'click'}"/>
+ <tc:event event="dblclick" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'dblclick'}"/>
+ <tc:event event="focus" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'focus'}"/>
+ <tc:event event="blur" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'blur'}"/>
+ </c:if>
+ </tc:selectBooleanCheckbox>
+</ui:composition>
Modified: myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-textarea.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-textarea.xhtml?rev=1782340&r1=1782339&r2=1782340&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-textarea.xhtml (original)
+++ myfaces/tobago/trunk/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/6000-event/x-event-textarea.xhtml Thu Feb 9 15:00:48 2017
@@ -17,15 +17,35 @@
* limitations under the License.
-->
-<ui:composition xmlns:tc="http://myfaces.apache.org/tobago/component"
- xmlns:ui="http://java.sun.com/jsf/facelets"
- xmlns="http://www.w3.org/1999/xhtml">
- <tc:section label="#{event}">
- <tc:textarea id="textarea#{type}#{event}" valueChangeListener="#{eventController.valueChangeListener}">
- <ui:include src="x-event-component-content.xhtml">
- <ui:param name="type" value="#{type}"/>
- <ui:param name="event" value="#{event}"/>
- </ui:include>
- </tc:textarea>
- </tc:section>
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tc="http://myfaces.apache.org/tobago/component"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <tc:textarea id="textarea#{eventType}" valueChangeListener="#{eventController.valueChangeListener}">
+ <c:if test="#{eventType == 'ajax'}">
+ <f:ajax event="change" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'change'}"/>
+ <f:ajax event="click" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'click'}"/>
+ <f:ajax event="dblclick" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'dblclick'}"/>
+ <f:ajax event="focus" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'focus'}"/>
+ <f:ajax event="blur" render="metrics" listener="#{eventController.ajaxListener}"
+ disabled="#{eventName != 'blur'}"/>
+ </c:if>
+ <c:if test="#{eventType == 'event'}">
+ <tc:event event="change" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'change'}"/>
+ <tc:event event="click" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'click'}"/>
+ <tc:event event="dblclick" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'dblclick'}"/>
+ <tc:event event="focus" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'focus'}"/>
+ <tc:event event="blur" action="#{eventController.action}" actionListener="#{eventController.actionListener}"
+ rendered="#{eventName == 'blur'}"/>
+ </c:if>
+ </tc:textarea>
</ui:composition>