[richfaces-svn-commits] JBoss Rich Faces SVN: r18832 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest and 1 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Thu Aug 19 19:23:34 EDT 2010


Author: lfryc at redhat.com
Date: 2010-08-19 19:23:34 -0400 (Thu, 19 Aug 2010)
New Revision: 18832

Modified:
   modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/simple.xhtml
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
   modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java
Log:
a4j:status - fixed simple facets sample and tests (RFPL-735)

Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/simple.xhtml	2010-08-19 23:22:47 UTC (rev 18831)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jStatus/simple.xhtml	2010-08-19 23:23:34 UTC (rev 18832)
@@ -39,22 +39,22 @@
         <ui:define name="outOfTemplateBefore">
         	<fieldset>
         		<legend>Facets Settings</legend>
-                <a4j:ajax event="change" render="status" execute="facetsSettings">
-                	<h:panelGrid id="facetsSettings" columns="2">
-    	            	<h:outputText value="Facet Start: " />
-    	            	<h:inputText id="facetStartTextInput" value="#{a4jStatusBean.facetStartValue}" />
-    	            	
-    	            	<h:outputText value="Facet Stop: " />
-    	            	<h:inputText id="facetStopTextInput" value="#{a4jStatusBean.facetStopValue}" />
-    	            	
-    	            	<h:outputText value="Facet Error: " />
-    	            	<h:inputText id="facetErrorTextInput" value="#{a4jStatusBean.facetErrorValue}" />
-                	</h:panelGrid>
-                </a4j:ajax>
+            	<h:panelGrid id="facetsSettings" columns="2">
+	            	<h:outputText value="Facet Start: " />
+	            	<h:inputText id="facetStartTextInput" value="#{a4jStatusBean.facetStartValue}" />
+	            	
+	            	<h:outputText value="Facet Stop: " />
+	            	<h:inputText id="facetStopTextInput" value="#{a4jStatusBean.facetStopValue}" />
+	            	
+	            	<h:outputText value="Facet Error: " />
+	            	<h:inputText id="facetErrorTextInput" value="#{a4jStatusBean.facetErrorValue}" />
+            	</h:panelGrid>
             </fieldset>
         </ui:define>
 
         <ui:define name="component">
+            <a4j:commandButton id="applyFacets" value="ApplyFacets" render="status" execute="facetsSettings" />
+        
             <fieldset style="height: 3em">
                 <legend>status (inside form)</legend>
                 <a4j:status id="status"

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java	2010-08-19 23:22:47 UTC (rev 18831)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/AbstractComponentAttributes.java	2010-08-19 23:23:34 UTC (rev 18832)
@@ -21,8 +21,6 @@
  *******************************************************************************/
 package org.richfaces.tests.metamer.ftest;
 
-import org.apache.commons.lang.Validate;
-import org.jboss.test.selenium.dom.Event;
 import org.jboss.test.selenium.framework.AjaxSelenium;
 import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
 import org.jboss.test.selenium.locator.AttributeLocator;
@@ -30,7 +28,6 @@
 import org.jboss.test.selenium.locator.JQueryLocator;
 
 import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardHttp;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
 import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
 
 /**
@@ -39,21 +36,10 @@
  */
 public class AbstractComponentAttributes {
 
-    AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+    protected AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
 
     JQueryLocator propertyLocator = pjq("input[id$={0}Input]");
 
-    ApplyType applyType;
-
-    public AbstractComponentAttributes() {
-        this(ApplyType.SERVER);
-    }
-
-    public AbstractComponentAttributes(ApplyType type) {
-        Validate.notNull(type);
-        this.applyType = type;
-    }
-
     protected String getProperty(String propertyName) {
         final ElementLocator<?> locator = propertyLocator.format(propertyName);
         return selenium.getValue(locator);
@@ -67,27 +53,21 @@
         String inputType = selenium.getAttribute(typeLocator);
 
         String valueAsString = value.toString();
-        // INPUT TEXT
+
         if ("text".equals(inputType)) {
-            if (applyType == ApplyType.SERVER) {
-                guardHttp(selenium).type(locator, valueAsString);
-            } else if (applyType == ApplyType.AJAX) {
-                guardXhr(selenium).type(locator, valueAsString);
-            }
-            // INPUT CHECKBOX
+            applyText(locator, valueAsString);
         } else if ("checkbox".equals(inputType)) {
             boolean checked = Boolean.valueOf(valueAsString);
 
-            if (applyType == ApplyType.SERVER) {
-                guardHttp(selenium).check(locator, checked);
-            } else if (applyType == ApplyType.AJAX) {
-                selenium.check(locator, checked);
-                guardXhr(selenium).fireEvent(locator, Event.CHANGE);
-            }
+            applyCheckbox(locator, checked);
         }
     }
 
-    public static enum ApplyType {
-        SERVER, AJAX
+    protected void applyText(ElementLocator<?> locator, String value) {
+        guardHttp(selenium).type(locator, value);
     }
+
+    protected void applyCheckbox(ElementLocator<?> locator, boolean checked) {
+        guardHttp(selenium).check(locator, checked);
+    }
 }

Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java	2010-08-19 23:22:47 UTC (rev 18831)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jStatus/StatusFacets.java	2010-08-19 23:23:34 UTC (rev 18832)
@@ -1,11 +1,45 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
 package org.richfaces.tests.metamer.ftest.a4jStatus;
 
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.locator.JQueryLocator;
 import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
 
+import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+
+/**
+ * @author <a href="mailto:lfryc at redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
 public class StatusFacets extends AbstractComponentAttributes {
 
-    public StatusFacets() {
-        super(AbstractComponentAttributes.ApplyType.AJAX);
+    JQueryLocator applyFacetsButton = pjq("input[id$=applyFacets]");
+
+    @Override
+    protected void applyText(ElementLocator<?> locator, String value) {
+        selenium.type(locator, value);
+        guardXhr(selenium).click(applyFacetsButton);
     }
 
     public void setStartText(String startText) {



More information about the richfaces-svn-commits mailing list