Author: konstantin.mishin
Date: 2008-10-31 13:20:55 -0400 (Fri, 31 Oct 2008)
New Revision: 10994
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/ValidatorWithAttribute.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java
Log:
RF-4722
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-10-31
16:48:31 UTC (rev 10993)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-10-31
17:20:55 UTC (rev 10994)
@@ -4,8 +4,12 @@
import java.util.List;
import java.util.Set;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
+import javax.faces.validator.ValidatorException;
import org.ajax4jsf.model.ListShuttleItem;
@@ -27,6 +31,8 @@
private boolean immediate;
private String string;
private boolean valueChangeListener;
+ private boolean attrValidator;
+ private boolean tagValidator;
public ListShuttleBean() {
init();
@@ -44,6 +50,8 @@
valueChangeListener = false;
sourceSelection = null;
targetSelection = null;
+ attrValidator = false;
+ tagValidator = false;
items = new ArrayList<ListShuttleItem>();
freeItems = new ArrayList<ListShuttleItem>();
for (int i = 0; i < 5; i++) {
@@ -187,4 +195,27 @@
return null;
}
}
+
+ public void validate(FacesContext context, UIComponent component,
+ Object value) throws ValidatorException {
+ if (attrValidator) {
+ throw new ValidatorException(new FacesMessage("attrValidator"));
+ }
+ }
+
+ public void setAttrValidator(boolean attrValidator) {
+ this.attrValidator = attrValidator;
+ }
+
+ public boolean isAttrValidator() {
+ return attrValidator;
+ }
+
+ public void setTagValidator(boolean tagValidator) {
+ this.tagValidator = tagValidator;
+ }
+
+ public boolean isTagValidator() {
+ return tagValidator;
+ }
}
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/ValidatorWithAttribute.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/ValidatorWithAttribute.java
(rev 0)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/validators/ValidatorWithAttribute.java 2008-10-31
17:20:55 UTC (rev 10994)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * 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 org.ajax4jsf.validators;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
+
+/**
+ *
+ * @author Konstantin Mishin
+ *
+ */
+public class ValidatorWithAttribute implements Validator {
+
+ static public final String MESSAGE = "ValidatorWithAttribute is failed";
+ /* (non-Javadoc)
+ * @see javax.faces.validator.Validator#validate(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.Object)
+ */
+ public void validate(FacesContext context, UIComponent component, Object value) throws
ValidatorException {
+ if ((Boolean)component.getAttributes().get("failed")) {
+ throw new ValidatorException(new FacesMessage(MESSAGE));
+ }
+ }
+}
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-10-31
16:48:31 UTC (rev 10993)
+++
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/WEB-INF/faces-config.xml 2008-10-31
17:20:55 UTC (rev 10994)
@@ -21,10 +21,15 @@
</converter>
<validator>
- <validator-id>autoTestValidator</validator-id>
-
<validator-class>org.ajax4jsf.autotest.bean.AutoTestValidator</validator-class>
+ <validator-id>validatorWithAttribute</validator-id>
+
<validator-class>org.ajax4jsf.validators.ValidatorWithAttribute</validator-class>
</validator>
+ <validator>
+ <validator-id>autoTestValidator</validator-id>
+
<validator-class>org.ajax4jsf.autotest.bean.AutoTestValidator</validator-class>
+ </validator>
+
<validator>
<validator-id>autoTestDefaultValidator</validator-id>
<validator-class>org.ajax4jsf.autotest.bean.AutoTestDefaultValidator</validator-class>
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/listShuttle/listShuttleTest.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java
===================================================================
---
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-10-31
16:48:31 UTC (rev 10993)
+++
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-10-31
17:20:55 UTC (rev 10994)
@@ -9,6 +9,7 @@
import java.util.Map;
import org.ajax4jsf.template.Template;
+import org.ajax4jsf.validators.ValidatorWithAttribute;
import org.richfaces.SeleniumEvent;
import org.richfaces.SeleniumTestBase;
import org.testng.Assert;
@@ -78,6 +79,10 @@
String immediateId;
+ String attrValidatorId;
+
+ String tagValidatorId;
+
private void init(Template template) {
renderPage(template, initMethod);
parentId = getParentId() + "_form:";
@@ -108,9 +113,32 @@
switchByClickId = attrFormId + ":switchByClickId";
renderedId = attrFormId + ":renderedId";
immediateId = attrFormId + ":immediateId";
+ attrValidatorId = attrFormId + ":attrValidatorId";
+ tagValidatorId = attrFormId + ":tagValidatorId";
}
/**
+ * validator defined by component attribute and nested tags work
+ */
+ @Test
+ public void testValidators(Template template) {
+ init(template);
+ Assert.assertFalse(selenium.isElementPresent(msgId), "Message mustn't be
rendered.");
+ selenium.click(attrValidatorId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+ Assert.assertEquals(selenium.getText(msgId), "attrValidator");
+ selenium.click(attrValidatorId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+ Assert.assertFalse(selenium.isElementPresent(msgId), "Message mustn't be
rendered.");
+ selenium.click(tagValidatorId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+ Assert.assertEquals(selenium.getText(msgId), ValidatorWithAttribute.MESSAGE);
+ }
+
+ /**
* sourceValue/targetValue not updated, listeners not call using multiple selection
with external validation failure after form submission
*/
@Test
Show replies by date