Author: adubovsky
Date: 2009-07-28 05:15:39 -0400 (Tue, 28 Jul 2009)
New Revision: 15020
Added:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Listeners.java
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/AutoGeneral.java
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Convertion.java
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/UtilListeners.java
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Validation.java
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/WEB-INF/auto/auto-config.xml
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/comboBox/comboBox.jsp
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/pickList/pickList.jsp
Log:
+ valueChangeListener test
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/AutoGeneral.java
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/AutoGeneral.java 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/AutoGeneral.java 2009-07-28
09:15:39 UTC (rev 15020)
@@ -47,7 +47,7 @@
*/
private static final String[] autoGeneralAttrs = { "immediate",
"validator", "validatorMessage", "required",
"requiredMessage",
- "converter", "converterMessage" };
+ "converter", "converterMessage", "valueChangeListener"
};
/** The result auto general grid. */
private HtmlPanelGrid resultAutoGeneralGrid = null;
@@ -139,6 +139,13 @@
.equalsIgnoreCase("converterMessage"))
// run test for "converterMessage" attribute
convertionBean.converterMessageCheck(attr);
+ } else if (attr.getName().equalsIgnoreCase("valueChangeListener")) {
+ Listeners listenersBean = (Listeners) BeanManager
+ .getManagedBeanFromSession("listeners");
+ ImmediateComponentBean compInt = (ImmediateComponentBean) BeanManager
+ .getManagedBeanFromSession(component);
+ // run test for "valueChangeListener" attribute
+ listenersBean.valueChangeListenerCheck(attr, compInt.isImmediate());
}
}
// redraw the results grid with the last test results
@@ -170,6 +177,10 @@
.getManagedBeanFromSession("convertion");
if (null != convertionBean)
convertionBean.reset();
+
+ Listeners listenersBean = (Listeners) BeanManager
+ .getManagedBeanFromSession("listeners");
+ listenersBean.reset();
UIViewRoot vr = FacesContext.getCurrentInstance().getViewRoot();
UIInput inp = (UIInput) vr
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Convertion.java
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Convertion.java 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Convertion.java 2009-07-28
09:15:39 UTC (rev 15020)
@@ -26,6 +26,7 @@
import javax.faces.component.UIComponent;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
+import javax.faces.event.PhaseId;
import util.data.Car;
import util.parser.Attribute;
@@ -54,13 +55,13 @@
* The phase converter get as object keeps the JSF phase on which
* getAsObject is triggered.
*/
- private String phaseConverterGetAsObject = "UNDEFINED";
+ private PhaseId phaseConverterGetAsObject = PhaseId.ANY_PHASE;
/**
* The phase converter get as string keeps the JSF phase on which
* getAsString is triggered.
*/
- private String phaseConverterGetAsString = "UNDEFINED";
+ private PhaseId phaseConverterGetAsString = PhaseId.ANY_PHASE;
/** The converter message test which is actual displayed on the page. */
private String converterMessageTest = "";
@@ -84,6 +85,8 @@
converterMessageTest = "";
statusConverterGetAsObject = false;
statusConverterGetAsString = false;
+ phaseConverterGetAsObject = PhaseId.ANY_PHASE;
+ phaseConverterGetAsString = PhaseId.ANY_PHASE;
}
/**
@@ -106,8 +109,7 @@
// getAsObject is called
statusConverterGetAsObject = true;
// keep phase
- phaseConverterGetAsObject = PhaseTracker.currentPhase
- .toString();
+ phaseConverterGetAsObject = PhaseTracker.currentPhase;
if (newValue.equals("converter"))
throw new ConverterException(new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Converter error",
@@ -128,8 +130,7 @@
// getAsString is called
statusConverterGetAsString = true;
// keep phase
- phaseConverterGetAsString = PhaseTracker.currentPhase
- .toString();
+ phaseConverterGetAsString = PhaseTracker.currentPhase;
return (null == value) ? null : value.toString();
}
@@ -156,8 +157,7 @@
// getAsObject is called
statusConverterGetAsObject = true;
// keep phase
- phaseConverterGetAsObject = PhaseTracker.currentPhase
- .toString();
+ phaseConverterGetAsObject = PhaseTracker.currentPhase;
if (newValue.indexOf("converter") > -1)
throw new ConverterException(new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Converter error",
@@ -179,9 +179,7 @@
// getAsString is called
statusConverterGetAsString = true;
// keep phase
- phaseConverterGetAsString = PhaseTracker.currentPhase
- .toString();
-
+ phaseConverterGetAsString = PhaseTracker.currentPhase;
if (value instanceof Car) {
Car car = (Car) value;
return (null == car) ? null : car.toString();
@@ -203,13 +201,14 @@
// converter should be called...
if ((statusConverterGetAsObject) && (statusConverterGetAsString)) {
// ... getAsObject on the 3th phase if component is not immediate...
- if (((phaseConverterGetAsObject.equals("PROCESS_VALIDATIONS(3)"))
+ if (((phaseConverterGetAsObject.equals(PhaseId.PROCESS_VALIDATIONS))
&& (!immediate)
// ... getAsObject or on the 2th phase if component is immediate...
- || (phaseConverterGetAsObject.equals("APPLY_REQUEST_VALUES(2)"))
+ || (phaseConverterGetAsObject.equals(PhaseId.APPLY_REQUEST_VALUES))
&& (immediate))
// ... and getAsString on the 6th phase
- && (phaseConverterGetAsString.equals("RENDER_RESPONSE(6)"))) {
+ && (phaseConverterGetAsString
+ .equals(PhaseId.RENDER_RESPONSE))) {
attr.setStatus(Status.PASSED);
} else {
attr.setStatus(Status.FAILED);
Added:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Listeners.java
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Listeners.java
(rev 0)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Listeners.java 2009-07-28
09:15:39 UTC (rev 15020)
@@ -0,0 +1,95 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package automateCommon;
+
+import javax.faces.event.PhaseId;
+import javax.faces.event.ValueChangeEvent;
+
+import util.parser.Attribute;
+import util.parser.Status;
+import util.phaseTracker.PhaseTracker;
+
+/**
+ * The Listeners bean provides methods for "valueChangeListener" attribute
+ * testing.
+ */
+public class Listeners {
+
+ /**
+ * The statusValueChangeListener indicates whether valueChangeListener is
+ * called or not.
+ */
+ private boolean statusValueChangeListener = false;
+
+ /**
+ * The phaseValueChangeListener keeps the JSF phase on which
+ * valueChangeListener is triggered.
+ */
+ private PhaseId phaseValueChangeListener = PhaseId.ANY_PHASE;
+
+ /**
+ * Resets test variables.
+ */
+ public void reset() {
+ statusValueChangeListener = false;
+ phaseValueChangeListener = PhaseId.ANY_PHASE;
+ }
+
+ /**
+ * Value change listener.
+ *
+ * @param e
+ * the parameter of the value change listener
+ */
+ public void valueChangeListener(ValueChangeEvent e) {
+ System.out.println("++>> TUT");
+ statusValueChangeListener = true;
+ phaseValueChangeListener = PhaseTracker.currentPhase;
+ }
+
+ /**
+ * Value change listener check.
+ *
+ * @param attr
+ * the tested attribute
+ * @param immediate
+ * the immediate attribute value of the current component
+ */
+ public void valueChangeListenerCheck(Attribute attr, boolean immediate) {
+ // validator should be called...
+ if (statusValueChangeListener) {
+ // ... on the 3th phase if component is not immediate...
+ if ((phaseValueChangeListener.equals(PhaseId.PROCESS_VALIDATIONS))
+ && (!immediate)
+ // ... or on the 2th phase if component is immediate
+ || (phaseValueChangeListener
+ .equals(PhaseId.APPLY_REQUEST_VALUES))
+ && (immediate)) {
+ attr.setStatus(Status.PASSED);
+ } else {
+ attr.setStatus(Status.FAILED);
+ }
+ } else {
+ attr.setStatus(Status.FAILED);
+ }
+ }
+}
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/UtilListeners.java
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/UtilListeners.java 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/UtilListeners.java 2009-07-28
09:15:39 UTC (rev 15020)
@@ -33,8 +33,8 @@
/**
* The Class UtilListeners is used for changing "required" and
"immediate"
- * attributes. Listeners are added to the corresponding buttons when results
- * grids are generated.
+ * attributes of the tested component. Listeners are added to the corresponding
+ * buttons when results grids are generated.
*/
public class UtilListeners {
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Validation.java
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Validation.java 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/java/automateCommon/Validation.java 2009-07-28
09:15:39 UTC (rev 15020)
@@ -26,6 +26,7 @@
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseId;
import javax.faces.validator.ValidatorException;
import util.parser.Attribute;
@@ -54,7 +55,7 @@
private boolean statusValidator = false;
/** The phase validator keeps the JSF phase on which validator is triggered. */
- private String phaseValidator = "UNDEFINED";
+ private PhaseId phaseValidator = PhaseId.ANY_PHASE;
/**
* Instantiates a new validation.
@@ -73,7 +74,7 @@
validatorMessageTest = "";
requiredMessageTest = "";
statusValidator = false;
- phaseValidator = "UNDEFINED";
+ phaseValidator = PhaseId.ANY_PHASE;
}
/**
@@ -95,7 +96,7 @@
// validator is called
statusValidator = true;
// keep phase
- phaseValidator = PhaseTracker.currentPhase.toString();
+ phaseValidator = PhaseTracker.currentPhase;
if (value != null) {
if (value instanceof List) {
List<Object> arr_value = (List<Object>) value;
@@ -133,10 +134,10 @@
// validator should be called...
if (statusValidator) {
// ... on the 3th phase if component is not immediate...
- if ((phaseValidator.equals("PROCESS_VALIDATIONS(3)"))
+ if ((phaseValidator.equals(PhaseId.PROCESS_VALIDATIONS))
&& (!immediate)
// ... or on the 2th phase if component is immediate
- || (phaseValidator.equals("APPLY_REQUEST_VALUES(2)"))
+ || (phaseValidator.equals(PhaseId.APPLY_REQUEST_VALUES))
&& (immediate)) {
attr.setStatus(Status.PASSED);
} else {
@@ -178,7 +179,7 @@
// component should be immediate...
if ((statusValidator) && (immediate)) {
// ...and validator should be called on the 2th phase
- if (phaseValidator.equals("APPLY_REQUEST_VALUES(2)")) {
+ if (phaseValidator.equals(PhaseId.APPLY_REQUEST_VALUES)) {
attr.setStatus(Status.PASSED);
} else {
attr.setStatus(Status.FAILED);
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/WEB-INF/auto/auto-config.xml
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/WEB-INF/auto/auto-config.xml 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/WEB-INF/auto/auto-config.xml 2009-07-28
09:15:39 UTC (rev 15020)
@@ -12,6 +12,13 @@
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
+ <managed-bean-name>listeners</managed-bean-name>
+ <managed-bean-class>
+ automateCommon.Listeners
+ </managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>convertion</managed-bean-name>
<managed-bean-class>
automateCommon.Convertion
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/comboBox/comboBox.jsp
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/comboBox/comboBox.jsp 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/comboBox/comboBox.jsp 2009-07-28
09:15:39 UTC (rev 15020)
@@ -9,6 +9,7 @@
<rich:comboBox id="comboBoxID" value="#{comboBox.value}"
validator="#{validation.validate}"
validatorMessage="#{validation.validatorMessage}"
+ valueChangeListener="#{listeners.valueChangeListener}"
converter="#{convertion.convert}"
converterMessage="#{convertion.converterMessage}"
onblur="markEventAsWorkable('onblur');"
@@ -42,7 +43,8 @@
inputStyle="inputStyle:inputStyle" itemClass="itemClass-itemClass"
itemSelectedClass="itemSelectedClass-itemSelectedClass"
listClass="listClass-listClass" listStyle="listStyle:listStyle"
- required="#{comboBox.required}"
requiredMessage="#{validation.requiredMessage}"
+ required="#{comboBox.required}"
+ requiredMessage="#{validation.requiredMessage}"
immediate="#{comboBox.immediate}">
<f:selectItem itemValue="validator" />
<f:selectItem itemValue="converter" />
Modified:
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/pickList/pickList.jsp
===================================================================
---
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/pickList/pickList.jsp 2009-07-28
00:32:59 UTC (rev 15019)
+++
branches/community/3.3.X/test-applications/test-jsp/src/main/webapp/components/pickList/pickList.jsp 2009-07-28
09:15:39 UTC (rev 15020)
@@ -32,6 +32,7 @@
converterMessage="#{convertion.converterMessage}"
required="#{pickList.required}"
requiredMessage="#{validation.requiredMessage}"
+ valueChangeListener="#{listeners.valueChangeListener}"
immediate="#{pickList.immediate}">
<f:selectItems value="#{pickList.selectItems}" />
<f:selectItem itemLabel="validator" itemValue="validator" />