JBoss Rich Faces SVN: r10724 - in trunk/test-applications/seleniumTest/richfaces/src: main/java/org/ajax4jsf/listener and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-10-10 16:14:24 -0400 (Fri, 10 Oct 2008)
New Revision: 10724
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java
Log:
a4j support tests
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java 2008-10-10 16:37:00 UTC (rev 10723)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/A4JSupport.java 2008-10-10 20:14:24 UTC (rev 10724)
@@ -19,15 +19,17 @@
public static final String NO_DATA = "nodata";
+ public static final String TEST_PASSED = "test passed";
+
public static final String VALID_MESSAGE = "field is required";
}
public void linkListener (ActionEvent event) {
- data = Messages.FOR_LINK;
+ data = Messages.TEST_PASSED;
}
public void checkBoxListener (ActionEvent event) {
- data = Messages.FOR_CHECKBOX;
+ data = Messages.TEST_PASSED;
}
public void commandListener (ActionEvent event) {
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-10 16:37:00 UTC (rev 10723)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/TemplateBean.java 2008-10-10 20:14:24 UTC (rev 10724)
@@ -42,6 +42,8 @@
private Template template = Template.SIMPLE;
+ private Template templatePath = Template.SIMPLE;
+
private String methodName;
@@ -63,6 +65,13 @@
public String getTemplate() {
return "../../template/" + template.getName() + ".xhtml";
}
+
+ /**
+ * @return the template
+ */
+ public String getTemplatePath() {
+ return template.getName() + ".xhtml";
+ }
/**
* @param template
@@ -71,6 +80,10 @@
public void setTemplate(Template template) {
this.template = template;
}
+
+ public void setTemplatePath(Template templatePath) {
+ this.templatePath = templatePath;
+ }
public List<SelectItem> getAvailableTemplates() {
List<SelectItem> retVal = new ArrayList<SelectItem>();
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java 2008-10-10 16:37:00 UTC (rev 10723)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/listener/AjaxSupportActionListener.java 2008-10-10 20:14:24 UTC (rev 10724)
@@ -12,11 +12,11 @@
public class AjaxSupportActionListener implements ActionListener, ValueChangeListener {
public void processAction(ActionEvent e) {
- process(Messages.FOR_LINK);
+ process(Messages.TEST_PASSED);
}
public void processValueChange(ValueChangeEvent ce) {
- process(Messages.FOR_CHECKBOX);
+ process(Messages.TEST_PASSED);
}
private void process(String str) {
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/ajaxSupport.xhtml
===================================================================
(Binary files differ)
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/includes/testBody.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,56 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+ <h:form id="_form">
+ <h:inputText id="validManager" required="true" value="1" requiredMessage="field is required"/> 
+ <table cellpadding="5" >
+ <tr>
+ <td>1.1</td>
+ <td>
+ <h:outputLink id="link_#{test_prefix}" style="text-decoration: none; color: blue;" value="#">
+ attribute actionListener
+ <a4j:support event="onclick" reRender="data1_#{test_prefix}" actionListener="#{ajaxSupport.linkListener}" immediate="#{immediate}" ajaxSingle="#{ajaxSingle}" enabled="#{enabled}"></a4j:support>
+ </h:outputLink>
+ </td>
+ <td><div><h:outputText style="font-weight: bold; border: 1px solid green" value="#{ajaxSupport.data}" id="data1_#{test_prefix}"></h:outputText></div></td>
+ </tr>
+ <tr>
+ <td>1.2</td>
+ <td>
+ <h:outputLink id="linkAL_#{test_prefix}" style="text-decoration: none; color: blue;" value="#">
+ tag actionListener
+ <a4j:support event="onclick" reRender="data1AL_#{test_prefix}" immediate="#{immediate}" ajaxSingle="#{ajaxSingle}" enabled="#{enabled}">
+ <f:actionListener type="org.ajax4jsf.listener.AjaxSupportActionListener" />
+ </a4j:support>
+ </h:outputLink>
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid green" value="#{ajaxSupport.data}" id="data1AL_#{test_prefix}"></h:outputText></td>
+ </tr>
+ <tr>
+ <td>2.1</td>
+ <td>
+ <h:selectBooleanCheckbox id="checkbox_#{test_prefix}">
+ <a4j:support event="onchange" reRender="data2_#{test_prefix}" actionListener="#{ajaxSupport.checkBoxListener}" immediate="#{immediate}" ajaxSingle="#{ajaxSingle}" enabled="#{enabled}"></a4j:support>
+ </h:selectBooleanCheckbox>
+ attribute actionListener
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid green" value="#{ajaxSupport.data}" id="data2_#{test_prefix}"></h:outputText></td>
+ </tr>
+ <tr>
+ <td>2.2</td>
+ <td>
+ <h:selectBooleanCheckbox id="checkboxAL_#{test_prefix}">
+ <a4j:support event="onchange" reRender="data2AL_#{test_prefix}" immediate="#{immediate}" ajaxSingle="#{ajaxSingle}" enabled="#{enabled}">
+ <f:actionListener type="org.ajax4jsf.listener.AjaxSupportActionListener" />
+ </a4j:support>
+ </h:selectBooleanCheckbox>
+ tag actionListener
+ </td>
+ <td><h:outputText style="font-weight: bold; border: 1px solid green" value="#{ajaxSupport.data}" id="data2AL_#{test_prefix}"></h:outputText></td>
+ </tr>
+ </table>
+ </h:form>
+</ui:composition>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute1.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testAjaxSingleAttribute1</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="asa1"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="true"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testAjaxSingleAttribute2.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testAjaxSingleAttribute2</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="asa2"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="true"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testDefaultBehaviour.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testDefaultBehaviour</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="db"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testEnabledAttribute.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testDefaultBehaviour</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ea"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="false"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute1.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testImmediateAttribute1</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ia1"/>
+ <ui:param name="immediate" value="true"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testImmediateAttribute2.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testImmediateAttribute2</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ia2"/>
+ <ui:param name="immediate" value="true"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testRerenderFunctionality.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testRerenderFunctionality</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="ra"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/ajaxSupport/testValidationFailed.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,19 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+<ui:composition template="../../template/caseTemplate.xhtml">
+ <ui:define name="caseName">testValidationFailed</ui:define>
+ <ui:define name="caseBody">
+ <ui:include src="includes/testBody.xhtml">
+ <ui:param name="test_prefix" value="vf"/>
+ <ui:param name="immediate" value="false"/>
+ <ui:param name="ajaxSingle" value="false"/>
+ <ui:param name="enabled" value="true"/>
+ </ui:include>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/webapp/template/caseTemplate.xhtml 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:ui="http://java.sun.com/jsf/facelets">
+
+<ui:composition template="#{templateBean.templatePath}">
+ <ui:define name="component">
+ <table width="100%">
+ <colgroup>
+ <col width="30%"/>
+ <col width="70%"/>
+ </colgroup>
+ <tr>
+ <td><ui:insert name="caseName"/></td>
+ <td>
+ <ui:insert name="caseBody"/>
+ </td>
+ </tr>
+ </table>
+ </ui:define>
+</ui:composition>
+</html>
\ No newline at end of file
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java 2008-10-10 16:37:00 UTC (rev 10723)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/AjaxSupportTest.java 2008-10-10 20:14:24 UTC (rev 10724)
@@ -6,6 +6,7 @@
import org.ajax4jsf.bean.A4JSupport;
import org.ajax4jsf.template.Template;
import org.richfaces.SeleniumTestBase;
+import org.richfaces.testng.util.CommonUtils;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -14,134 +15,267 @@
*
*/
public class AjaxSupportTest extends SeleniumTestBase {
+
+ private static final String COMMON_ALISTENER_PREFIX = "AL";
- private static final String ALISTENER_PREFIX = "AL";
+ private static final String DEFAULT_BEHAVIOUR_PAGE = "testDefaultBehaviour.xhtml";
+ private static final String VALIDATION_FAILED_PAGE = "testValidationFailed.xhtml";
+
+ private static final String IMMEDIATE_ATTRIBUTE1_PAGE = "testImmediateAttribute1.xhtml";
+
+ private static final String IMMEDIATE_ATTRIBUTE2_PAGE = "testImmediateAttribute2.xhtml";
+
+ private static final String AJAXSINGLE_ATTRIBUTE1_PAGE = "testAjaxSingleAttribute1.xhtml";
+
+ private static final String AJAXSINGLE_ATTRIBUTE2_PAGE = "testAjaxSingleAttribute2.xhtml";
+
+ private static final String RERENDER_ATTRIBUTE_PAGE = "testRerenderFunctionality.xhtml";
+
+ private static final String ENABLED_ATTRIBUTE_PAGE = "testEnabledAttribute.xhtml";
+
+ private static final String DEFAULT_BEHAVIOUR_ID_PREFIX = "_db";
+
+ private static final String VALIDATION_FAILED_ID_PREFIX = "_vf";
+
+ private static final String IMMEDIATE_ATTRIBUTE1_ID_PREFIX = "_ia1";
+
+ private static final String IMMEDIATE_ATTRIBUTE2_ID_PREFIX = "_ia2";
+
+ private static final String AJAXSINGLE_ATTRIBUTE1_ID_PREFIX = "_asa1";
+
+ private static final String AJAXSINGLE_ATTRIBUTE2_ID_PREFIX = "_asa2";
+
+ private static final String RERENDER_ATTRIBUTE_ID_PREFIX = "_ra";
+
+ private static final String ENABLED_ATTRIBUTE_ID_PREFIX = "_ea";
+
+ private String testUrl;
+
private String parentFormId;
private String linkId;
+ private String checkboxId;
+
+ private String commandId;
+
private String validManagerId;
- private String messageId;
+ private String dataId1;
- private String dataId;
+ private String dataId2;
/**
- * 1.action and actionListener defined as component attributes and actionListener
+ * action and actionListener defined as component attributes and actionListener
* defined as nested tag are invoked on the server after event of attached
* to component occurs, navigation occurs
*/
@Test
- public void testAjaxSupportComponent(Template template) {
- checkBasicFunctionality(template);
+ public void testDefaultBehaviour(Template template) {
+ setTestUrl(DEFAULT_BEHAVIOUR_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, DEFAULT_BEHAVIOUR_ID_PREFIX, true);
}
+ /** component re-renders another component (h:outputText) */
+ @Test
+ public void testRerenderFunctionality(Template template) {
+ setTestUrl(RERENDER_ATTRIBUTE_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, RERENDER_ATTRIBUTE_ID_PREFIX, true);
+ }
+
/**
- * @see #testAjaxSupportComponent(Template template)
+ * @see #testDefaultBehaviour(Template template)
*
* the same for the case of external validation
* failure - listeners and navigation do not work
*/
@Test
public void testValidationFailed(Template template) {
+ setTestUrl(VALIDATION_FAILED_PAGE);
init(template);
-
- setValueById(validManagerId, "");
-
- clickById(linkId);
- waitForAjaxCompletion();
- String data = getTextById(dataId);
- if (!A4JSupport.Messages.NO_DATA.equals(data)) {
- Assert.fail();
- }
-
- clickById(linkId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- if (!A4JSupport.Messages.NO_DATA.equals(data)) {
- Assert.fail();
- }
+ breakExternalValidation();
+ checkBasicFunctionality(template, VALIDATION_FAILED_ID_PREFIX, false);
}
+ /**
+ * @see #testDefaultBehaviour(Template template)
+ *
+ * the same for immediate = true component
+ */
+ @Test
+ public void testImmediateAttribute1(Template template) {
+ setTestUrl(IMMEDIATE_ATTRIBUTE1_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, IMMEDIATE_ATTRIBUTE1_ID_PREFIX, true);
+ }
- private void checkBasicFunctionality(Template template) {
+ /**
+ * @see #testDefaultBehaviour(Template template)
+ *
+ * the same for immediate = true component for
+ * the case of external validation failure
+ */
+ @Test
+ public void testImmediateAttribute2(Template template) {
+ setTestUrl(IMMEDIATE_ATTRIBUTE2_PAGE);
init(template);
-
- String data = checkInputComponent();
- checkRequestDelayAttribute(data);
- checkCommandComponent();
+ breakExternalValidation();
+ checkBasicFunctionality(template, IMMEDIATE_ATTRIBUTE2_ID_PREFIX, true);
}
- private void checkCommandComponent() {
- setValueById(validManagerId, "1");
+ /**
+ * @see #testDefaultBehaviour()
+ *
+ * the same for ajaxSingle = true component
+ */
+ @Test
+ public void testAjaxSingleAttribute1(Template template) {
+ setTestUrl(AJAXSINGLE_ATTRIBUTE1_PAGE);
+ init(template);
+ passExternalValidation();
+ checkBasicFunctionality(template, AJAXSINGLE_ATTRIBUTE1_ID_PREFIX, true);
+ }
+
+ /**
+ * @see #testDefaultBehaviour()
+ *
+ * the same for ajaxSingle = true component for the case
+ * of external validation failure
+ */
+ @Test
+ public void testAjaxSingleAttribute2(Template template) {
+ setTestUrl(AJAXSINGLE_ATTRIBUTE2_PAGE);
+ init(template);
+ breakExternalValidation();
+ checkBasicFunctionality(template, AJAXSINGLE_ATTRIBUTE2_ID_PREFIX, true);
+ }
+
+// /**
+// * component encodes nested f:param tags and their values are present as request parameters
+// */
+// @Test
+// public void testFParamTag() {
+//
+// }
+//
+// /** component with bypassUpdates = true skips update model values phase */
+// @Test
+// public void testByPassAttribute() {
+//
+// }
+//
+//
+//
+// /** component with limitToList = true skips ajaxRendered areas update */
+// @Test
+// public void testLimitToListAttribute() {
+//
+// }
+//
+// /** component with rendered = false is not present on the page */
+// @Test
+// public void testRenderedAttribute() {
+//
+// }
+//
+// /**
+// * onsubmit event fires on component activation then
+// * oncomplete with proper request data
+// */
+// @Test
+// public void testOnSubmitEvent1() {
+//
+// }
+// /** component with enabled = false do not fire ajax requests */
+// @Test
+// public void testEnabledAttribute(Template template) {
+// setTestUrl(ENABLED_ATTRIBUTE_PAGE);
+// init(template);
+// passExternalValidation();
+// checkBasicFunctionality(template, ENABLED_ATTRIBUTE_ID_PREFIX, false);
+// }
+
+// /**
+// * @see #testAjaxSupportComponent()
+// *
+// * the same for ajaxSingle = true component for the case
+// * of external validation failure + process for validation failed
+// * field - listeners and navigation do not work
+// */
+// @Test
+// public void testAjaxSingleAttribute3() {
+//
+// }
+
+ private void checkBasicFunctionality(Template template, String casePrefix, boolean isDataAvailable) {
+ processingElement(linkId + casePrefix, dataId1 + casePrefix, isDataAvailable);
+ processingElement(linkId + COMMON_ALISTENER_PREFIX + casePrefix, dataId1 + COMMON_ALISTENER_PREFIX + casePrefix, isDataAvailable);
+
+ processingElement(checkboxId + casePrefix, dataId2 + casePrefix, isDataAvailable);
+ processingElement(checkboxId + COMMON_ALISTENER_PREFIX + casePrefix, dataId2 + COMMON_ALISTENER_PREFIX + casePrefix, isDataAvailable);
+ }
+
+ private void processingElement(String linkId, String dataId,
+ boolean isValidationFailed) {
clickById(linkId);
waitForAjaxCompletion();
String data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_LINK,
- "'onclick' ajax support for link[id='_form:link'] failed.",
- A4JSupport.Messages.FOR_LINK + " successful");
-
- clickById(linkId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_LINK,
- "'onclick' ajax support for link[id='_form:linkAL'] failed.",
- A4JSupport.Messages.FOR_LINK + " successful");
+ checkMessage(data, A4JSupport.Messages.TEST_PASSED,
+ CommonUtils.getFailedTestMessage(linkId),
+ CommonUtils.getSuccessfulTestMessage(linkId),
+ isValidationFailed);
}
- private String checkInputComponent() {
+ private void breakExternalValidation() {
+ setValueById(validManagerId, "");
+ }
+
+ private void passExternalValidation() {
setValueById(validManagerId, "1");
- String checkBoxId = parentFormId + "checkbox";
-
- clickById(checkBoxId);
- waitForAjaxCompletion();
- String data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_CHECKBOX,
- "'onchange' ajax support for checkbox[id='_form:checkbox'] failed.", A4JSupport.Messages.FOR_CHECKBOX
- + " successful");
-
- clickById(checkBoxId + ALISTENER_PREFIX);
- waitForAjaxCompletion();
- data = getTextById(dataId);
- checkMessage(data, A4JSupport.Messages.FOR_CHECKBOX,
- "'onchange' ajax support for checkbox[id='_form:checkboxAL'] failed.", A4JSupport.Messages.FOR_CHECKBOX
- + " successful");
- return data;
}
- private void checkRequestDelayAttribute(String data) {
- setValueById(validManagerId, "1");
- String command = parentFormId + "command";
-
- clickById(command);
- pause(1000, command);
- if (!data.equals(getTextById(dataId))) {
- writeStatus("<a4j:support failed. 'requestDelay' attribute does not work.");
- Assert.fail("<a4j:support failed. 'requestDelay' attribute does not work.");
- }
+ /*private void checkRequestDelayAttribute(String data, String casePrefix) {
+ String comId = commandId + casePrefix;
+ clickById(comId);
+ pause(1000, comId);
+
+// if (!data.equals(getTextById(dataId))) {
+// writeStatus("<a4j:support failed. 'requestDelay' attribute does not work.");
+// Assert.fail("<a4j:support failed. 'requestDelay' attribute does not work.");
+// }
waitForAjaxCompletion();
data = getTextById(dataId);
checkMessage(data, A4JSupport.Messages.FOR_COMMAND,
- "'onclick' ajax support for command link[id='_form:command'] failed.", A4JSupport.Messages.FOR_COMMAND
- + " successful");
+ CommonUtils.getFailedTestMessage(comId), CommonUtils.getSuccessfulTestMessage(comId));
if (A4JSupport.Messages.FOR_SUBMIT.equals(data)) {
writeStatus("<a4j:support failed. 'disableDefault' attribute does not work");
Assert.fail("<a4j:support failed. 'disableDefault' attribute does not work.");
}
- }
+ }*/
- private void checkMessage(String data, String message, String errorMessage, String okMessage) {
- if (message.equals(data)) {
- writeStatus(okMessage);
- } else if (A4JSupport.Messages.NO_DATA.equals(data)) {
- writeStatus(errorMessage + " Caused by: action listener for <a4j:support> skipped", true);
- Assert.fail(errorMessage + " Caused by: action listener for <a4j:support> skipped");
- } else if ("".equals(data)) {
- writeStatus(errorMessage + "Caused by: no ajax request has been sent.", true);
- Assert.fail(errorMessage + "Caused by: no ajax request has been sent.");
- }
+ private void checkMessage(String data, String message, String errorMessage, String okMessage, boolean isDataAvailable) {
+ if (!isDataAvailable) {
+ if (!A4JSupport.Messages.NO_DATA.equals(data)) {
+ writeStatus(errorMessage, true);
+ Assert.fail(errorMessage);
+ } else {
+ writeStatus(okMessage);
+ }
+ } else {
+ if (message.equals(data)) {
+ writeStatus(okMessage);
+ } else {
+ writeStatus(errorMessage, true);
+ Assert.fail(errorMessage);
+ }
+ }
}
private void init(Template template) {
@@ -152,14 +286,20 @@
private void initIds() {
parentFormId = getParentId() + "_form:";
linkId = parentFormId + "link";
+ checkboxId = parentFormId + "checkbox";
+ commandId = parentFormId + "command";
validManagerId = parentFormId + "validManager";
- messageId = getParentId() + "message";
- dataId = parentFormId + "data";
+ dataId1 = parentFormId + "data1";
+ dataId2 = parentFormId + "data2";
}
@Override
public String getTestUrl() {
- return "pages/ajaxSupport/ajaxSupport.xhtml";
+ return testUrl;
}
+
+ public void setTestUrl(String testUrl) {
+ this.testUrl = "pages/ajaxSupport/" + testUrl;
+ }
}
Added: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java (rev 0)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/CommonUtils.java 2008-10-10 20:14:24 UTC (rev 10724)
@@ -0,0 +1,16 @@
+package org.richfaces.testng.util;
+
+public class CommonUtils {
+
+ public static String getFailedTestMessage(String targetId) {
+ return getFinishedTestMessage(targetId) + "failed.";
+ }
+
+ public static String getSuccessfulTestMessage(String targetId) {
+ return getFinishedTestMessage(targetId) + "successful.";
+ }
+
+ private static String getFinishedTestMessage(String targetId) {
+ return "test for element [id= " + targetId + "] ";
+ }
+}
16 years, 3 months
JBoss Rich Faces SVN: r10723 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-10-10 12:37:00 -0400 (Fri, 10 Oct 2008)
New Revision: 10723
Added:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/menuPanelCosmeticTest.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
Log:
an attempt to speed the test up
Added: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/menuPanelCosmeticTest.xhtml
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/menuPanelCosmeticTest.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2008-10-10 15:51:16 UTC (rev 10722)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2008-10-10 16:37:00 UTC (rev 10723)
@@ -11,6 +11,8 @@
private final static String[] ITEM_HIGHLIGHTS = {"dr-pmenu-selected-item", "rich-pmenu-selected-element"};
+ private final static String COSMETIC_TEST_URL = "pages/panelMenu/menuPanelCosmeticTest.xhtml";
+
@Test
public void testPanelMenuClientAPI(Template template) {
renderPage(template, RESET_METHOD_NAME);
@@ -255,7 +257,7 @@
@Test
public void testIconsAttributesAreApplied(Template template) {
- renderPage(template, RESET_METHOD_NAME);
+ renderPage(COSMETIC_TEST_URL, template, RESET_METHOD_NAME);
writeStatus("Check icons attributes applied: are output to client and images are accessible");
@@ -274,7 +276,7 @@
@Test
public void testRenderedComponentAttribute(Template template) {
- renderPage(template, RESET_METHOD_NAME);
+ renderPage(COSMETIC_TEST_URL, template, RESET_METHOD_NAME);
writeStatus("Check the component with rendered = false is not present on the page");
@@ -285,7 +287,7 @@
@Test
public void testStyleAndClassesStandardHTMLAttributesAreOutputToClient(Template template) {
- renderPage(template, RESET_METHOD_NAME);
+ renderPage(COSMETIC_TEST_URL, template, RESET_METHOD_NAME);
writeStatus("Check style and classes, standard HTML attributes are output to client");
@@ -308,7 +310,7 @@
@Test
public void testSelectedChildAttributeIsReadOnRenderingAndUpdatedOnFormSubmit(Template template) {
- renderPage(template, RESET_METHOD_NAME);
+ renderPage(COSMETIC_TEST_URL, template, RESET_METHOD_NAME);
writeStatus("Check selectedChild attribute is read on rendering and updated on form submit");
16 years, 3 months
JBoss Rich Faces SVN: r10722 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-10-10 11:51:16 -0400 (Fri, 10 Oct 2008)
New Revision: 10722
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
refactoring
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-10 15:31:09 UTC (rev 10721)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-10-10 15:51:16 UTC (rev 10722)
@@ -174,29 +174,22 @@
* Renders page
*/
protected void renderPage(Template template) {
- selenium.open(protocol + "://" + host + ":" + port + "/" + APPLICATION_NAME + filterPrefix + getTestUrl());
- selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
-
- setParentId(template.getPrefix());
- runScript("loadTemplate('" + template + "');", false);
- waitForPageToLoad();
-
- checkPageRendering(); // At the first we check if page has been
- // rendered
- checkJSError(); // At the second we check if JS errors occurred
-
- reRenderForm(); // ReRender component
-
- checkPageRendering(); // Check all again
- checkJSError();
-
+ renderPage(template, null);
}
-
+
/**
* Renders page
*/
protected void renderPage(Template template, String resetMethodName) {
- selenium.open(protocol + "://" + host + ":" + port + "/" + APPLICATION_NAME + filterPrefix + getTestUrl());
+ renderPage(null, template, resetMethodName);
+ }
+
+ protected void renderPage(String url, Template template, String resetMethodName) {
+ String postfix = url;
+ if (null == url) {
+ postfix = getTestUrl();
+ }
+ selenium.open(protocol + "://" + host + ":" + port + "/" + APPLICATION_NAME + filterPrefix + postfix);
selenium.waitForPageToLoad(String.valueOf(pageRenderTime));
setParentId(template.getPrefix());
@@ -211,9 +204,8 @@
checkPageRendering(); // Check all again
checkJSError();
-
}
-
+
/**
* Writes status message on client side
*
@@ -244,16 +236,18 @@
* ReRenders the component
*/
public void reRenderForm() {
- selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll();");
- // clickById("_Selenium_Test_ReRender_Form:_reRender");
- waitForAjaxCompletion(3000);
+ reRenderForm(null);
}
-
+
/**
* ReRenders the component
*/
private void reRenderForm(String resetMethodName) {
- selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll('"+resetMethodName+"');");
+ if (null != resetMethodName) {
+ selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll('" + resetMethodName + "');");
+ } else {
+ selenium.getEval("selenium.browserbot.getCurrentWindow().reRenderAll();");
+ }
waitForAjaxCompletion(3000);
}
16 years, 3 months
JBoss Rich Faces SVN: r10721 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/listShuttle and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-10-10 11:31:09 -0400 (Fri, 10 Oct 2008)
New Revision: 10721
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java
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:
Check 'showButtonsLabel' attribute
Check 'switchByClick' attribute
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-10 15:11:46 UTC (rev 10720)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/ListShuttleBean.java 2008-10-10 15:31:09 UTC (rev 10721)
@@ -15,6 +15,8 @@
private boolean sourceRequired;
private boolean targetRequired;
+ private boolean showButtonLabels;
+ private boolean switchByClick;
public ListShuttleBean() {
init();
@@ -23,6 +25,8 @@
public void init() {
sourceRequired = false;
targetRequired = false;
+ showButtonLabels = true;
+ switchByClick = false;
items = new ArrayList<ListShuttleItem>();
freeItems = new ArrayList<ListShuttleItem>();
for (int i = 0; i < 5; i++) {
@@ -84,4 +88,20 @@
public void setTargetRequired(boolean targetRequired) {
this.targetRequired = targetRequired;
}
+
+ public boolean isShowButtonLabels() {
+ return showButtonLabels;
+ }
+
+ public void setShowButtonLabels(boolean showButtonLabels) {
+ this.showButtonLabels = showButtonLabels;
+ }
+
+ public boolean isSwitchByClick() {
+ return switchByClick;
+ }
+
+ public void setSwitchByClick(boolean switchByClick) {
+ this.switchByClick = switchByClick;
+ }
}
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-10 15:11:46 UTC (rev 10720)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/ListShuttleTest.java 2008-10-10 15:31:09 UTC (rev 10721)
@@ -46,12 +46,16 @@
String msgId;
- String reqFormId;
+ String attrFormId;
String sourceRequiredId;
String targetRequiredId;
+ String showButtonLabelsId;
+
+ String switchByClickId;
+
private void init(Template template) {
renderPage(template, initMethod);
parentId = getParentId() + "_form:";
@@ -69,12 +73,62 @@
resetId = parentId + "reset";
hideId = parentId + "hide";
msgId = getParentId() + "msgId";
- reqFormId = getParentId() + "reqFormId";
- sourceRequiredId = reqFormId + ":sourceRequiredId";
- targetRequiredId = reqFormId + ":targetRequiredId";
+ attrFormId = getParentId() + "attrFormId";
+ sourceRequiredId = attrFormId + ":sourceRequiredId";
+ targetRequiredId = attrFormId + ":targetRequiredId";
+ showButtonLabelsId = attrFormId + ":showButtonLabelsId";
+ switchByClickId = attrFormId + ":switchByClickId";
}
+
+
/**
+ * Check 'switchByClick' attribute
+ */
+ @Test
+ public void testSwitchByClick(Template template) {
+ init(template);
+ _selectItem(parentId + "ls:0");
+ Assert.assertEquals(getTextById(targetListId), "", "Target list must be empty.");
+
+ selenium.click(switchByClickId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+
+ _selectItem(parentId + "ls:0");
+ Assert.assertEquals(getTextById(targetListId), "1Item1", "Target list mustn't be empty.");
+ }
+
+ /**
+ * Check 'showButtonsLabel' attribute
+ */
+ @Test
+ public void testShowButtonsLabel(Template template) {
+ init(template);
+ Assert.assertEquals(getTextById(copyAllId), "Copy all", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(copyId), "Copy", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(removeId), "Remove", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(removeAllId), "Remove All", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(firstId), "First", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(upId), "Up", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(downId), "Down", "The text on the button must be visible.");
+ Assert.assertEquals(getTextById(lastId), "Last", "The text on the button must be visible.");
+
+ selenium.click(showButtonLabelsId);
+ waitForAjaxCompletion();
+ clickAjaxCommandAndWait(submitId);
+
+ Assert.assertEquals(getTextById(copyAllId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(copyId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(removeId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(removeAllId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(firstId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(upId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(downId), "", "The text on the button mustn't be visible.");
+ Assert.assertEquals(getTextById(lastId), "", "The text on the button mustn't be visible.");
+ }
+
+ /**
* 'sourceRequired' and 'targetRequired' attributes work
*/
@Test
16 years, 3 months
JBoss Rich Faces SVN: r10720 - trunk/docs/cdkguide/en/src/main/docbook/modules.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2008-10-10 11:11:46 -0400 (Fri, 10 Oct 2008)
New Revision: 10720
Modified:
trunk/docs/cdkguide/en/src/main/docbook/modules/overview.xml
Log:
https://jira.jboss.org/jira/browse/RF-3692 - "Component usage overview" chapter done
Modified: trunk/docs/cdkguide/en/src/main/docbook/modules/overview.xml
===================================================================
--- trunk/docs/cdkguide/en/src/main/docbook/modules/overview.xml 2008-10-10 14:52:46 UTC (rev 10719)
+++ trunk/docs/cdkguide/en/src/main/docbook/modules/overview.xml 2008-10-10 15:11:46 UTC (rev 10720)
@@ -11,19 +11,172 @@
</chapterinfo>
<title>Component usage overview</title>
<para>
- After the <emphasis role="bold"><property><inputDate></property></emphasis> component creation you could use it on a page.
- Let's create a simple JSF project with the help of <code>maven-archetype-jsfwebapp</code> archetype.
+ After the <emphasis role="bold"><property><inputDate></property></emphasis> component has been created you could use it on a page.
+ Create a simple JSF project with only one JSP page that has a form with our
+ <emphasis role="bold"><property><inputDate></property></emphasis> component.
+
</para>
- <para>
- </para>
+ <section id="jsppage">
+ <title>JSP Page</title>
+ <para>
+ Here is the necessary page (index.jsp):
+ </para>
+
+ <programlisting role="XML"><![CDATA[
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib uri="http://mycompany.org/inputDate" prefix="my"%>
+<html>
+ <head>
+ <title>My inputDate</title>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <my:inputDate value="#{bean.text}">
+ <f:facet name="caption">
+ <f:verbatim>
+ Calendar:
+ </f:verbatim>
+ </f:facet>
+ </my:inputDate>
+ <h:commandButton value="Submit" />
+ </h:form>
+ </f:view>
+ </body>
+</html>
+]]></programlisting>
+ </section>
+ <section id="dataBean">
+ <title>Data Bean</title>
+ <para>
+ In order to build this application, you should create a managed bean:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[
+package myapp;
+import java.util.Date;
+public class Bean {
+
+ private Date text = null;
+
+ public Bean() {
- <section id="devsample">
+ }
+
+ public Date getText() {
+ return text;
+ }
+
+ public void setText(Date text) {
+ this.text = text;
+ }
+}
+]]></programlisting>
+ </section>
+ <section id="facesconfig">
+ <title>faces-config.xml</title>
+ <para>
+ It is necessary to register your bean inside of the <property>faces-config.xml</property> file:
+ </para>
+
+ <programlisting role="XML"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+ <managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>myapp.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+</faces-config>
+]]></programlisting>
+ </section>
+ <section id="Webxml">
+ <title>Web.xml</title>
+ <para>
+ It is also necessary to take following steps:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ add necessary jar files
+ (inputDate-1.0-SNAPSHOT.jar, jsf-api.jar, jsf-impl.jar, jstl-api-1.2.jar, richfaces-api-3.3.0.jar, richfaces-impl-3.3.0.jar, richfaces-ui-3.3.0.jar, commons-logging.jar, commons-digester.jar, commons-collections.jar, commons-beanutils.jar, common-annotations.jar)
+ into the <property>WEB-INF/lib</property> folder
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ modify the <property>web.xml</property> file:
+ </para>
+ <programlisting role="XML"><![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
+ <display-name>app</display-name>
+ <context-param>
+ <param-name>javax.faces.CONFIG_FILES</param-name>
+ <param-value>/WEB-INF/faces-config.xml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ </login-config>
+ <filter>
+ <display-name>RichFaces Filter</display-name>
+ <filter-name>richfaces</filter-name>
+ <filter-class>org.ajax4jsf.Filter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>richfaces</filter-name>
+ <servlet-name>Faces Servlet</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+</web-app>
+]]></programlisting>
+ </listitem>
+ </itemizedlist>
+ </section>
+ <section id="deployment">
+ <title>Deployment</title>
+ <para>
+ Finally, you should be able to place this application on your Web server.
+ To start your project, point your browser at <ulink url="http://localhost:8080/myapp/index.jsf">http://localhost:8080/myapp/index.jsf</ulink>.
+ </para>
+ </section>
+
+ <!-- section id="devsample">
<title>Developer sample creation</title>
<para>
- Work in progress...
+ Let's create a simple JSF project, called <property>myapp</property> for example,
+ with the help of <code>maven-archetype-jsfwebapp</code> archetype.
</para>
- </section>
+ <para>
+ It is necessary to proceed to your <property>Sandbox</property> directory and launch the following command (all in one line):
+ </para>
+ <programlisting role="XML"><![CDATA[mvn archetype:create -DarchetypeGroupId=org.richfaces.cdk -DarchetypeArtifactId=maven-archetype-jsfwebapp -DarchetypeVersion=3.3.0-SNAPSHOT -DgroupId=org.mycompany -DartifactId=myapp]]></programlisting>
+ <para>
+ As easy to see a new directory <property>myapp</property> is created with the predefined JSF project structure:
+ </para>
+ </section-->
</chapter>
16 years, 3 months
JBoss Rich Faces SVN: r10719 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/panelMenu and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-10-10 10:52:46 -0400 (Fri, 10 Oct 2008)
New Revision: 10719
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
Log:
PanelMenu: test selectedChild attribute is read on rendering and updated on form submit
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2008-10-10 12:49:06 UTC (rev 10718)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/RichPanelTestBean.java 2008-10-10 14:52:46 UTC (rev 10719)
@@ -34,14 +34,11 @@
private String itemAction;
- private String selectedChild;
-
private boolean rendered;
public RichPanelTestBean() {
value = "";
value2 = 0;
- selectedChild = "Group1";
rendered = true;
}
@@ -97,22 +94,6 @@
}
/**
- * Gets value of selectedChild field.
- * @return value of selectedChild field
- */
- public String getSelectedChild() {
- return selectedChild;
- }
-
- /**
- * Set a new value for selectedChild field.
- * @param selectedChild a new value for selectedChild field
- */
- public void setSelectedChild(String selectedChild) {
- this.selectedChild = selectedChild;
- }
-
- /**
* Gets value of rendered field.
* @return value of rendered field
*/
@@ -152,16 +133,6 @@
return null;
}
- public void switchSelectedChild() {
- if("Group1".equals(selectedChild)) {
- selectedChild = "Group2";
- } else if("Group2".equals(selectedChild)) {
- selectedChild = "Group3";
- } else {
- selectedChild = "Group1";
- }
- }
-
public void hide() {
rendered = false;
}
@@ -172,7 +143,6 @@
panelValue = null;
panelValue2 = null;
itemAction = "";
- selectedChild = "Group1";
rendered = true;
}
}
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/panelMenu/panelMenuTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2008-10-10 12:49:06 UTC (rev 10718)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/PanelMenuTest.java 2008-10-10 14:52:46 UTC (rev 10719)
@@ -9,6 +9,8 @@
private final static String RESET_METHOD_NAME = "#{panelBean.cleanValues}";
+ private final static String[] ITEM_HIGHLIGHTS = {"dr-pmenu-selected-item", "rich-pmenu-selected-element"};
+
@Test
public void testPanelMenuClientAPI(Template template) {
renderPage(template, RESET_METHOD_NAME);
@@ -304,6 +306,31 @@
assertClassNames(menuItemId, new String[] { "itemClass" }, "itemClass attribute was not output to client", true);
}
+ @Test
+ public void testSelectedChildAttributeIsReadOnRenderingAndUpdatedOnFormSubmit(Template template) {
+ renderPage(template, RESET_METHOD_NAME);
+
+ writeStatus("Check selectedChild attribute is read on rendering and updated on form submit");
+
+ String parentId = getParentId() + "row__form3:";
+ assertClassNames(parentId + "pGroup2_selected", ITEM_HIGHLIGHTS, "Group 2 must be highlighted", true);
+
+ writeStatus("Click group 1");
+ String group1 = parentId + "pGroup1_selected";
+ clickById(group1);
+ assertClassNames(group1, ITEM_HIGHLIGHTS, "Group 1 must be highlighted", true);
+
+ writeStatus("Click group 1.1");
+ String group11 = parentId + "pGroup11_selected";
+ clickById(group11);
+ assertClassNames(group11, ITEM_HIGHLIGHTS, "Group 1.1 must be highlighted", true);
+
+ writeStatus("Click item 1.1 Submit is being initiated");
+ String item11 = parentId + "pItem11_selected";
+ clickCommandAndWait(item11);
+ assertClassNames(item11, ITEM_HIGHLIGHTS, "Item 1.1 must be highlighted", true);
+ }
+
/**
* Test an icon.
*
16 years, 3 months
JBoss Rich Faces SVN: r10718 - trunk/ui/extendedDataTable/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-10-10 08:49:06 -0400 (Fri, 10 Oct 2008)
New Revision: 10718
Modified:
trunk/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
Log:
adapt component to work with new ExtendedTableDataModel and ExtendedTableDataModifiableModel classes
Modified: trunk/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java
===================================================================
--- trunk/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-10-10 12:46:34 UTC (rev 10717)
+++ trunk/ui/extendedDataTable/src/main/java/org/richfaces/component/UIExtendedDataTable.java 2008-10-10 12:49:06 UTC (rev 10718)
@@ -16,6 +16,7 @@
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import javax.faces.event.PhaseId;
+import javax.faces.model.DataModel;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.event.AjaxEvent;
@@ -26,9 +27,10 @@
import org.richfaces.event.extdt.DragDropEvent;
import org.richfaces.event.extdt.ExtTableFilterEvent;
import org.richfaces.event.extdt.ExtTableSortEvent;
-import org.richfaces.model.ExtendedDataTableModifiableModel;
import org.richfaces.model.ExtendedTableDataModel;
+import org.richfaces.model.ExtendedTableDataModifiableModel;
import org.richfaces.model.FilterField;
+import org.richfaces.model.Modifiable;
import org.richfaces.model.ModifiableModel;
import org.richfaces.model.SortField2;
@@ -136,12 +138,24 @@
}// processChangeColumnVisibility
public void processSortingChange(ExtTableSortEvent event) {
- resetModel();
+ DataModel dataModel = getDataModel();
+ if (dataModel instanceof ExtendedTableDataModifiableModel<?>) {
+ ((ExtendedTableDataModifiableModel<?>)dataModel).resetSort();
+ }
+ else{
+ super.resetDataModel();
+ }
getFacesContext().renderResponse();
}
public void processFilteringChange(ExtTableFilterEvent event) {
- resetModel();
+ DataModel dataModel = getDataModel();
+ if (dataModel instanceof ExtendedTableDataModifiableModel<?>) {
+ ((ExtendedTableDataModifiableModel<?>)dataModel).resetFilter();
+ }
+ else{
+ super.resetDataModel();
+ }
resetGroupVisibilityState();
getFacesContext().renderResponse();
}
@@ -300,18 +314,31 @@
sortFields.addAll(sortFieldsMap.values());
setFilterFields(filterFields);
setSortFields(sortFields);
- ExtendedDataModel dataModel = (ExtendedDataModel) super.getDataModel();
- if (dataModel instanceof ExtendedTableDataModel<?>) {
- ExtendedTableDataModel<?> tableDataModel = (ExtendedTableDataModel<?>) dataModel;
- return new ExtendedDataTableModifiableModel(tableDataModel,
- getVar(), getFilterFields(), getSortFields());
- } else {
- ModifiableModel modifiableModel = new ModifiableModel(dataModel,
- getVar());
- modifiableModel.modify(getFilterFields(), getSortFields());
-
- return modifiableModel;
+
+ ExtendedDataModel dataModel = (ExtendedDataModel)getDataModel();
+ if (dataModel instanceof ExtendedTableDataModifiableModel<?>) {
+ ((ExtendedTableDataModifiableModel<?>) dataModel).setVar(getVar());
}
+ if ((filterFields != null && !filterFields.isEmpty())
+ || (sortFields != null && !sortFields.isEmpty())) {
+ Modifiable modifiable = null;
+ if (dataModel instanceof Modifiable) {
+ modifiable = (Modifiable) dataModel;
+ } else if (dataModel instanceof ExtendedTableDataModel<?>) {
+ ExtendedTableDataModel<?> tableDataModel = (ExtendedTableDataModel<?>) dataModel;
+ //ExtendedTableDataModifiableModelOld<?> modifiableModel = new ExtendedTableDataModifiableModelOld(tableDataModel, getVar());
+ ExtendedTableDataModifiableModel<?> modifiableModel = new ExtendedTableDataModifiableModel(tableDataModel, getVar());
+ dataModel = modifiableModel;
+ modifiable = modifiableModel;
+ }
+ else {
+ ModifiableModel modifiableModel = new ModifiableModel(dataModel, getVar());
+ dataModel = modifiableModel;
+ modifiable = modifiableModel;
+ }
+ modifiable.modify(filterFields, sortFields);
+ }
+ return dataModel;
}
/**
@@ -327,15 +354,6 @@
super.resetDataModel();
}
}
-
- /**
- * Method resets data model by calling
- * {@link org.ajax4jsf.component.UIDataAdaptor#resetDataModel()}. This
- * method is called on sort and filter action.
- */
- protected void resetModel() {
- super.resetDataModel();
- }
@SuppressWarnings("unchecked")
public Iterator<UIComponent> fixedChildren() {
16 years, 3 months
JBoss Rich Faces SVN: r10717 - trunk/framework/impl/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-10-10 08:46:34 -0400 (Fri, 10 Oct 2008)
New Revision: 10717
Removed:
trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedDataTableModifiableModel.java
trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModelWrapper.java
Log:
remove unneeded classes
Deleted: trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedDataTableModifiableModel.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedDataTableModifiableModel.java 2008-10-10 12:45:38 UTC (rev 10716)
+++ trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedDataTableModifiableModel.java 2008-10-10 12:46:34 UTC (rev 10717)
@@ -1,196 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.model.FilterField;
-import org.richfaces.model.SortField2;
-import org.richfaces.model.impl.expressive.JavaBeanWrapper;
-import org.richfaces.model.impl.expressive.ObjectWrapperFactory;
-import org.richfaces.model.impl.expressive.WrappedBeanComparator2;
-import org.richfaces.model.impl.expressive.WrappedBeanFilter;
-
-/**
- * @author pawelgo
- *
- */
-public class ExtendedDataTableModifiableModel<T> extends ExtendedDataModel {
-
- private static final Log log = LogFactory.getLog(ExtendedDataTableModifiableModel.class);
-
- private ExtendedDataModel delegate;
-
- private ExtendedTableDataModel<T> originalModel;
-
- private ExtendedDataModel modifiedModel;
-
- private String var;
-
- private List<FilterField> filterFields;
- private List<SortField2> sortFields;
-
- /**
- * @param originalModel
- * @param var
- * @param filterFields
- * @param sortFields
- */
- public ExtendedDataTableModifiableModel(ExtendedTableDataModel<T> originalModel,
- String var, List<FilterField> filterFields,
- List<SortField2> sortFields) {
- this.originalModel = originalModel;
- this.delegate = originalModel;
- this.var = var;
- this.filterFields = filterFields;
- this.sortFields = sortFields;
- }
-
- public void addDataModelListener(DataModelListener listener) {
- originalModel.addDataModelListener(listener);
- }
-
- public DataModelListener[] getDataModelListeners() {
- return originalModel.getDataModelListeners();
- }
-
- public int getRowCount() {
- return delegate.getRowCount();
- }
-
- public Object getRowData() {
- return delegate.getRowData();
- }
-
- public int getRowIndex() {
- return delegate.getRowIndex();
- }
-
- public Object getRowKey() {
- return delegate.getRowKey();
- }
-
- public SerializableDataModel getSerializableModel(Range range) {
- return delegate.getSerializableModel(range);
- }
-
- public Object getWrappedData() {
- return delegate.getWrappedData();
- }
-
- public boolean isRowAvailable() {
- return delegate.isRowAvailable();
- }
-
- public void removeDataModelListener(DataModelListener listener) {
- delegate.removeDataModelListener(listener);
- }
-
- public void setRowIndex(int rowIndex) {
- delegate.setRowIndex(rowIndex);
- }
-
- public void setRowKey(Object key) {
- delegate.setRowKey(key);
- }
-
- public void setWrappedData(Object data) {
- delegate.setWrappedData(data);
- }
-
- @SuppressWarnings("unchecked")
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- if (shouldSort() || shouldFilter()) {
- if (modifiedModel == null) {
- modifiedModel = new ExtendedTableDataModelWrapper<T>(originalModel.getDataProvider(), (List<T>) prepareCollection());
- }
- delegate = modifiedModel;
- } else {
- delegate = originalModel;
- }
-
- delegate.walk(context, visitor, range, argument);
- }
-
- private boolean shouldSort() {
- return sortFields != null && !sortFields.isEmpty();
- }
-
- private boolean shouldFilter() {
- return filterFields != null && !filterFields.isEmpty();
- }
-
- private List<?> prepareCollection() {
- int rowCount = originalModel.getRowCount();
- final List<Object> collection;
-
- if (rowCount > 0) {
- collection = new ArrayList<Object>(rowCount);
- } else {
- collection = new ArrayList<Object>();
- }
-
- FacesContext context = FacesContext.getCurrentInstance();
- try {
-
- originalModel.walk(context, new DataVisitor() {
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- originalModel.setRowKey(rowKey);
- if (originalModel.isRowAvailable()) {
- collection.add(originalModel.getRowData());
- }
- }
- }, new SequenceRange(0, -1),
- null);
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- }
-
- List<Object> modifedcollection = collection;
-
- if (shouldFilter()) {
- List <Object> filteredCollection = new ArrayList<Object>();
- ObjectWrapperFactory wrapperFactory = new ObjectWrapperFactory(
- context, var, filterFields);
- WrappedBeanFilter wrappedBeanFilter = new WrappedBeanFilter(filterFields);
- wrapperFactory.wrapList(modifedcollection);
- for (Object object : modifedcollection) {
- if(wrappedBeanFilter.accept((JavaBeanWrapper)object)) {
- filteredCollection.add(object);
- }
- }
- modifedcollection = filteredCollection;
- wrapperFactory.unwrapList(modifedcollection);
- }
-
- if (shouldSort()) {
- ObjectWrapperFactory wrapperFactory = new ObjectWrapperFactory(
- context, var, sortFields);
- WrappedBeanComparator2 wrappedBeanComparator = new WrappedBeanComparator2(
- sortFields);
- wrapperFactory.wrapList(modifedcollection);
- Collections.sort(modifedcollection, wrappedBeanComparator);
- wrapperFactory.unwrapList(modifedcollection);
- }
- return modifedcollection;
-
- }
-
-}
Deleted: trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModelWrapper.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModelWrapper.java 2008-10-10 12:45:38 UTC (rev 10716)
+++ trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModelWrapper.java 2008-10-10 12:46:34 UTC (rev 10717)
@@ -1,40 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.util.List;
-
-/**
- * @author pawelgo
- *
- */
-public class ExtendedTableDataModelWrapper<T> extends ExtendedTableDataModel<T> {
-
- private static final long serialVersionUID = 6932958007982793632L;
-
- protected List<T> wrappedList;
-
- /**
- *
- * @param dataProvider
- * @param wrappedList
- */
- public ExtendedTableDataModelWrapper(DataProvider<T> dataProvider, List<T> wrappedList) {
- super(dataProvider);
- this.wrappedList = wrappedList;
- }
-
- protected List<T> loadData(int startRow, int endRow) {
- //return super.loadData(startRow, endRow);
- return wrappedList.subList(startRow, endRow);
- }
-
- public int getRowCount() {
- return wrappedList.size();
- }
-
-
-
-
-}
16 years, 3 months
JBoss Rich Faces SVN: r10716 - trunk/framework/impl/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-10-10 08:45:38 -0400 (Fri, 10 Oct 2008)
New Revision: 10716
Modified:
trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
Log:
cache internal data to do not load data from provider every time
Modified: trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2008-10-10 12:44:41 UTC (rev 10715)
+++ trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2008-10-10 12:45:38 UTC (rev 10716)
@@ -12,9 +12,9 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
import org.ajax4jsf.model.Range;
import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SerializableDataModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -22,115 +22,23 @@
* Data model class for table components.<br>
* Usage:
* <pre>
- * G3TableDataModel<SomeDataType> dataModel = new G3TableDataModel<SomeDataType>(new G3DataProvider <SomeDataType>());
+ * ExtendedTableDataModel<SomeDataType> dataModel = new ExtendedTableDataModel<SomeDataType>(new DataProvider <SomeDataType>());
* </pre>
* @author pawelgo
*
*/
-public class ExtendedTableDataModel<T> extends SerializableDataModel {
+public class ExtendedTableDataModel<T> extends ExtendedDataModel {
-// /**
-// * Cache container for data presented in data model.
-// * It prevents load the same data many times.
-// * @author pawelgo
-// *
-// * @param <T> data type
-// */
-// private static class DataCache<T> implements Serializable {
-// private static final long serialVersionUID = 8409239905346930920L;
-// private int startRow;
-// private int endRow;
-// //private SortOrder sortOrder;
-// private List<T> loadedData;
-//
-// public DataCache(int startRow, int endRow,
-// List<T> loadedData) {
-// super();
-// this.startRow = startRow;
-// this.endRow = endRow;
-// //this.sortOrder = deepCopy(sortOrder);
-// this.loadedData = loadedData;
-// }
-//
-// /**
-// * Returns a deep copy of an object
-// */
-// @SuppressWarnings("unused")
-// private SortOrder deepCopy(SortOrder sortOrder) {
-// if (sortOrder == null)
-// return null;
-// SortOrder order = new SortOrder();
-// if (sortOrder.getFields() != null) {
-// SortField[] fields = new SortField[sortOrder.getFields().length];
-// for (int i = 0; i < sortOrder.getFields().length; i++) {
-// SortField f = sortOrder.getFields()[i];
-// fields[i] = new SortField(f.getName(), f.getIndex(), f
-// .getAscending());
-// }//for
-// order.setFields(fields);
-// }//if
-// return order;
-// }//deepCopy
-//
-// /**
-// * Returns a deep copy of an object using serialization.
-// */
-// static public Object deepCopy(Object oldObj) throws Exception {
-// ObjectOutputStream oos = null;
-// ObjectInputStream ois = null;
-// try {
-// ByteArrayOutputStream bos = new ByteArrayOutputStream();
-// oos = new ObjectOutputStream(bos);
-// // serialize and pass the object
-// oos.writeObject(oldObj);
-// oos.flush();
-// ByteArrayInputStream bin = new ByteArrayInputStream(bos
-// .toByteArray());
-// ois = new ObjectInputStream(bin);
-// // return the new object
-// return ois.readObject();
-// } catch (Exception e) {
-// if (log.isErrorEnabled())
-// log.error("Exception in ObjectCloner = " + e);
-// throw (e);
-// } finally {
-// oos.close();
-// ois.close();
-// }
-// }//deepCopy
-//
-// public boolean match(int s, int e) {
-// return s == startRow && e == endRow;
-// //&& sortOrdersMatch(sortOrder, this.sortOrder);
-// }//match
-//
-// @SuppressWarnings("unused")
-// private boolean sortOrdersMatch(SortOrder sortOrder1,
-// SortOrder sortOrder2) {
-// boolean result = sortOrder1 == sortOrder2;
-//
-// if (sortOrder1 != null && sortOrder2 != null) {
-// result = sortOrder1.equals(sortOrder2);
-// }
-//
-// return result;
-// }//sortOrdersMatch
-//
-// }//DataCache
-
private static final long serialVersionUID = 7374505108088114161L;
private static final Log log = LogFactory.getLog(ExtendedTableDataModel.class);
private DataProvider<T> dataProvider;
private Object rowKey;
- //private Map<Object,T> wrappedData = new HashMap<Object,T>();
private List<Object> wrappedKeys = null;
- private boolean detached = false;
+ //private boolean detached = false;
private Map<Object, T> wrappedData = new HashMap<Object, T>();
- //private DataCache<T> dataCache;
-
public ExtendedTableDataModel(DataProvider<T> dataProvider) {
this.dataProvider = dataProvider;
}
@@ -138,9 +46,9 @@
/* (non-Javadoc)
* @see org.ajax4jsf.model.SerializableDataModel#update()
*/
- public void update() {
- ;
- }
+// public void update() {
+// ;
+// }
/**
* This method never called from framework.
@@ -173,7 +81,7 @@
if (numberOfRows <= 0) {
numberOfRows = rowC;
}
- if (detached) { // Is this serialized model
+ if (wrappedKeys != null) { // Is this serialized model
// Here we just ignore current Rage and use whatever data was saved in serialized model.
// Such approach uses much more getByPk() operations, instead of just one request by range.
// Concrete case may be different from that, so you can just load data from data provider by range.
@@ -216,17 +124,9 @@
endRow = rowCount;
throw new IllegalArgumentException("Illegal end index value: " + endRow);
}
- /*
- if (dataCache == null || !dataCache.match(startRow, endRow)) {
- if (log.isDebugEnabled())
- log.debug("load and store in cache");
- List<T> data = dataProvider.getItemsByRange(startRow, endRow);
- dataCache = new DataCache<T>(startRow, endRow, data);
- }
- return dataCache.loadedData;
- */
//load all from provider and get sublist
- return dataProvider.getItemsByRange(0, rowCount).subList(startRow, endRow);
+ return dataProvider.getItemsByRange(startRow, endRow);
+ //return dataProvider.getItemsByRange(0, rowCount).subList(startRow, endRow);
}//loadData
/**
@@ -331,15 +231,27 @@
* complicated cases we may need to transform data to actually serialized
* form.
*/
- public SerializableDataModel getSerializableModel(Range range) {
- if (wrappedKeys != null) {
- detached = true;
- // Some activity to detach persistent data from wrappedData map may be taken here.
- // In that specific case we are doing nothing.
- return this;
- } else {
- return null;
- }
+// public SerializableDataModel getSerializableModel(Range range) {
+// if (wrappedKeys != null) {
+// detached = true;
+// // Some activity to detach persistent data from wrappedData map may be taken here.
+// // In that specific case we are doing nothing.
+// return this;
+// } else {
+// return null;
+// }
+// }
+
+ /**
+ * Resets internal cached data. Call this method to reload data from data
+ * provider on first access for data.
+ */
+ public void reset(){
+ wrappedKeys = null;
+ wrappedData.clear();
+ rowCount = null;
+ rowIndex = -1;
+ rowKey = null;
}
public DataProvider<T> getDataProvider() {
16 years, 3 months
JBoss Rich Faces SVN: r10715 - trunk/framework/impl/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: pgolawski
Date: 2008-10-10 08:44:41 -0400 (Fri, 10 Oct 2008)
New Revision: 10715
Added:
trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
Log:
new modifiable data model for extendedDataTable component
Added: trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java (rev 0)
+++ trunk/framework/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2008-10-10 12:44:41 UTC (rev 10715)
@@ -0,0 +1,113 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author pawelgo
+ *
+ */
+public class ExtendedTableDataModifiableModel<T> extends ModifiableModel {
+
+ //private static final Log log = LogFactory.getLog(ExtendedTableDataModifiableModel.class);
+
+ private ExtendedTableDataModel<T> orgModel;
+ private boolean sortNeeded = true;
+ private boolean filterNeeded = true;
+
+ @SuppressWarnings("unchecked")
+ public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider, String var) {
+ super(new ExtendedTableDataModel<T>(dataProvider), var);
+ this.orgModel = (ExtendedTableDataModel<T>)this.originalModel;
+ }
+
+ public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider) {
+ this(dataProvider, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ExtendedTableDataModifiableModel(ExtendedTableDataModel<T> dataModel, String var) {
+ super(dataModel, var);
+ this.orgModel = dataModel;
+ }
+
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /**
+ * Resets internal cached data. Call this method to reload data from data
+ * provider on first access for data.
+ */
+ public void reset(){
+ orgModel.reset();
+ rowKeys = null;
+ sortNeeded = true;
+ filterNeeded = true;
+ }
+
+ public Object getKey(T o) {
+ return orgModel.getKey(o);
+ }
+
+ public T getObjectByKey(Object key) {
+ return orgModel.getObjectByKey(key);
+ }
+
+ @Override
+ public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
+ if (sortNeeded || filterNeeded){
+ if (var == null){
+ throw new IllegalStateException("\"var\" model attribute can not be null.");
+ }
+ super.modify(filterFields, sortFields);
+ sortNeeded = false;
+ filterNeeded = false;
+ }
+ }
+
+ public void resetSort(){
+ sortNeeded = true;
+ }
+
+ public void resetFilter(){
+ filterNeeded = true;
+ }
+
+ public void setVar(String var){
+ this.var = var;
+ }
+}
16 years, 3 months