Author: nbelaevski
Date: 2009-07-10 07:13:58 -0400 (Fri, 10 Jul 2009)
New Revision: 14876
Added:
branches/jsf2.0/ui/core/src/main/config/component/queue.xml
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
branches/jsf2.0/ui/core/src/test-new/
branches/jsf2.0/ui/core/src/test-new/java/
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AjaxFormQueuesTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/ImplicitQueuesTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadResourceComponentTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueDiscoveryTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueParallelTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSimilarityTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSizeTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueuedPollTest.java
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.js
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.xcss
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-ajax-form.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-disabled.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-discovery-base.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-both.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-form.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-view.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-implicit-global.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-legacy.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-parallel.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll-drop.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-scripted.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-similarity.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-size.xhtml
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/root
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/simulation.js
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.js
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.xcss
Removed:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
Modified:
branches/jsf2.0/ui/core/pom.xml
branches/jsf2.0/ui/core/src/main/config/component/commandLink.xml
branches/jsf2.0/ui/core/src/main/config/component/form.xml
branches/jsf2.0/ui/core/src/main/config/component/include.xml
branches/jsf2.0/ui/core/src/main/config/component/loadStyle.xml
branches/jsf2.0/ui/core/src/main/config/component/log.xml
branches/jsf2.0/ui/core/src/main/config/component/mediaOutput.xml
branches/jsf2.0/ui/core/src/main/config/component/outputPanel.xml
branches/jsf2.0/ui/core/src/main/config/component/page.xml
branches/jsf2.0/ui/core/src/main/config/component/poll.xml
branches/jsf2.0/ui/core/src/main/config/component/region.xml
branches/jsf2.0/ui/core/src/main/config/component/status.xml
branches/jsf2.0/ui/core/src/main/config/component/support.xml
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIInclude.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIPortlet.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxPushHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended.xcss
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended_classes.xcss
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/button.jspx
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/function.jspx
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/link.jspx
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/IncludeComponentTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/UIAjaxFormTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxFormRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxIncludeRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPageRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPushRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxStatusRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRendererTest.java
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/MediaOutputRendererTest.java
branches/jsf2.0/ui/pom.xml
Log:
Merged changes r10515:14694 from community/3.3.X branch
Java code updated to compile with JSF 2.0 - some TODOs added fro this
Test sources folder changed to test-new
Modified: branches/jsf2.0/ui/core/pom.xml
===================================================================
--- branches/jsf2.0/ui/core/pom.xml 2009-07-10 11:04:14 UTC (rev 14875)
+++ branches/jsf2.0/ui/core/pom.xml 2009-07-10 11:13:58 UTC (rev 14876)
@@ -1,4 +1,5 @@
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>ui</artifactId>
<groupId>org.richfaces</groupId>
@@ -8,40 +9,48 @@
<groupId>org.richfaces.ui</groupId>
<artifactId>core</artifactId>
<name>Java Server Faces AJAX framework</name>
- <build>
- <plugins>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-test-sources</id>
- <phase>generate-test-sources</phase>
- <goals>
- <goal>generate-tests</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <library>
- <prefix>org.richfaces</prefix>
- <taglib>
- <
uri>http://richfaces.org/a4j</uri>
- <shortName>a4j</shortName>
- <displayName>Core ajax components tags</displayName>
- </taglib>
- </library>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>3.3.1.GA</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <!-- execution>
+ <id>generate-test-sources</id>
+ <phase>generate-test-sources</phase>
+ <goals>
+ <goal>generate-tests</goal>
+ </goals>
+ </execution -->
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <
uri>http://richfaces.org/a4j</uri>
+ <shortName>a4j</shortName>
+ <displayName>Core ajax components tags</displayName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+
+ <testSourceDirectory>src/test-new</testSourceDirectory>
+ </build>
<dependencies>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-test-base</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: branches/jsf2.0/ui/core/src/main/config/component/commandLink.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/commandLink.xml 2009-07-10 11:04:14
UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/commandLink.xml 2009-07-10 11:13:58
UTC (rev 14876)
@@ -71,7 +71,7 @@
&ui_command_attributes;
&html_events;
&html_universal_attributes;
- &html_anchor_attributes;
+ &html_anchor_attributes;
&html_style_attributes;
&ajax_component_attributes;
<property>
@@ -88,10 +88,10 @@
<classname>int</classname>
<description>Timeout ( in ms ) for request.</description>
</property>
- <property>
- <name>disabled</name>
- <classname>boolean</classname>
- <description>If true, disable this component on page.</description>
- </property>
+ <property>
+ <name>disabled</name>
+ <classname>boolean</classname>
+ <description>Disables the component on page. Boolean.</description>
+ </property>
</component>
</components>
\ No newline at end of file
Modified: branches/jsf2.0/ui/core/src/main/config/component/form.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/form.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/form.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -42,6 +42,7 @@
&ui_component_attributes;
&html_form_attributes;
&ajax_component_attributes;
+ &html_style_attributes;
<property>
<name>ajaxSubmit</name>
<classname>boolean</classname>
Modified: branches/jsf2.0/ui/core/src/main/config/component/include.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/include.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/include.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -44,7 +44,7 @@
<property>
<name>viewId</name>
<classname>java.lang.String</classname>
- <description>viewId for included page.</description>
+ <description>Specifies the view id of a page that is
included.</description>
</property>
<property>
<name>layout</name>
@@ -58,7 +58,7 @@
where a child element has the property "rendered" set to
"false".
In this case, we create an empty <span> element with same ID
as the child element to use as a placeholder for later
- processing.
+ processing. Default value is "inline"
]]>
</description>
<defaultvalue>"inline"</defaultvalue>
Modified: branches/jsf2.0/ui/core/src/main/config/component/loadStyle.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/loadStyle.xml 2009-07-10 11:04:14
UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/loadStyle.xml 2009-07-10 11:13:58
UTC (rev 14876)
@@ -34,7 +34,7 @@
<name>src</name>
<classname>java.lang.Object</classname>
<description><![CDATA[
- name of JavaScript resource to load.
+ Defines the context relative path to the style sheet file.
]]>
</description>
</property>
Modified: branches/jsf2.0/ui/core/src/main/config/component/log.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/log.xml 2009-07-10 11:04:14 UTC (rev
14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/log.xml 2009-07-10 11:13:58 UTC (rev
14876)
@@ -40,14 +40,14 @@
<classname>java.lang.String</classname>
<description>
Keyboard key for activate ( in combination with
- CTRL+SHIFT ) log window.
+ CTRL+SHIFT ) log window. Default value is "L"
</description>
<defaultvalue>"L"</defaultvalue>
</property>
<property>
<name>name</name>
<classname>java.lang.String</classname>
- <description>name of pop-up window</description>
+ <description>Name of pop-up window. Default value is
"LogWindow"</description>
<defaultvalue>"LogWindow"</defaultvalue>
</property>
<property>
Modified: branches/jsf2.0/ui/core/src/main/config/component/mediaOutput.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/mediaOutput.xml 2009-07-10 11:04:14
UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/mediaOutput.xml 2009-07-10 11:13:58
UTC (rev 14876)
@@ -55,7 +55,7 @@
<property>
<name>usemap</name>
<classname>java.lang.String</classname>
- <description>use client-side image map</description>
+ <description>Specifies an image as a client-side image-map</description>
</property>
<property>
<name>ismap</name>
@@ -84,12 +84,12 @@
<property>
<name>codetype</name>
<classname>java.lang.String</classname>
- <description>content type for code</description>
+ <description>Defines content type for code</description>
</property>
<property>
<name>archive</name>
<classname>java.lang.String</classname>
- <description>space-separated list of URIs</description>
+ <description> Specifies a space-separated list of URIs</description>
</property>
<property>
<name>standby</name>
@@ -135,8 +135,7 @@
<classname>javax.el.MethodExpression</classname>
<description>
<![CDATA[
- Method call expression to send generated resource to OutputStream. It must have
two parameter with a type of java.io.OutputStream
- and java.lang.Object ( deserialized value of data attribute )
+ Attribute references to the method that will be used for content creating. The
method accepts two parameters. The first parameter has an OutputStream type. It is a
reference to the steam that should be used for output. The second parameter is a reference
to a 'value' attribute of the component.
]]>
</description>
<methodargs>
@@ -167,7 +166,7 @@
<property>
<name>cacheable</name>
<classname>boolean</classname>
- <description>If "true", the resource is cached (on the server and the
client sides).</description>
+ <description>Attribute is a flag that defines the caching strategy. If
'cacheable' is set to false, the response will not be cached. If it is set to
true, it will be cached and the serialized value of 'value' attribute plays the
role of a cache key.</description>
</property>
<property>
<name>expires</name>
Modified: branches/jsf2.0/ui/core/src/main/config/component/outputPanel.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/outputPanel.xml 2009-07-10 11:04:14
UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/outputPanel.xml 2009-07-10 11:13:58
UTC (rev 14876)
@@ -82,7 +82,7 @@
where a child element has the property "rendered" set to
"false".
In this case, we create an empty <span> element with same ID
as the child element to use as a placeholder for later
- processing.
+ processing. Default value is "inline"
]]>
</description>
<defaultvalue>"inline"</defaultvalue>
@@ -98,7 +98,7 @@
region all content ( By default, all content in <f:verbatim>
tags and non-jsf elements in facelets, marked as transient -
since, self-rendered ajax regions don't plain output for ajax
- processing ).
+ processing ). Default value is "true"
]]>
</description>
<defaultvalue>true</defaultvalue>
Modified: branches/jsf2.0/ui/core/src/main/config/component/page.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/page.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/page.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -89,14 +89,14 @@
<name>onload</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code to execute on a page load.
+ The client-side script method to be called before a page is loaded
</description>
</property>
<property>
<name>onunload</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code to execute on a page unload.
+ The client-side script method to be called when a page is unloaded
</description>
</property>
<property>
Modified: branches/jsf2.0/ui/core/src/main/config/component/poll.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/poll.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/poll.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -55,8 +55,7 @@
<name>onsubmit</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code for call before submission of ajax
- event
+ The client-side script method to be called before an ajax request is submitted
</description>
</property>
<property>
Copied: branches/jsf2.0/ui/core/src/main/config/component/queue.xml (from rev 14238,
trunk/ui/core/src/main/config/component/queue.xml)
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/queue.xml
(rev 0)
+++ branches/jsf2.0/ui/core/src/main/config/component/queue.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"http://labs.jboss.com/jbossrichfaces/component-config.dtd">
+<components>
+ <component>
+ <name>org.ajax4jsf.Queue</name>
+ <family>org.ajax4jsf.Queue</family>
+ <classname>org.ajax4jsf.component.html.HtmlQueue</classname>
+ <superclass>org.ajax4jsf.component.UIQueue</superclass>
+ <test />
+ <description>
+ <![CDATA[The <a4j:queue> tag.]]>
+ </description>
+ <tag generate="true" bodyContent="empty">
+ <name>queue</name>
+ <classname>org.ajax4jsf.taglib.html.jsp.QueueTag</classname>
+ <superclass>org.ajax4jsf.webapp.taglib.HtmlComponentTagBase</superclass>
+ <test/>
+ </tag>
+ <renderer generate="false">
+ <name>org.ajax4jsf.QueueRenderer</name>
+ <classname>org.ajax4jsf.renderkit.html.QueueRenderer</classname>
+ </renderer>
+ <!--
+ <taghandler>
+ <classname>org.ajax4jsf.taglib.html.facelets.QueueHandler</classname>
+ </taghandler>
+ -->
+
+ &ui_component_attributes;
+
+ <property>
+ <name>size</name>
+ <classname>int</classname>
+ <description>Defines the number of requests allowed in the queue at one
time.</description>
+ </property>
+ <property>
+ <name>name</name>
+ <classname>java.lang.String</classname>
+ <description>Specifies to name for the named queue.</description>
+ <defaultvalue>""</defaultvalue>
+ </property>
+
+ <property >
+ <name>requestDelay</name>
+ <classname>int</classname>
+ <description>Attribute defines the time (in ms) the request will be waiting
in the queue before it is ready to be sent.</description>
+ </property>
+ <property>
+ <name>ignoreDupResponses</name>
+ <classname>boolean</classname>
+ <description>Attribute allows you to ignore an Ajax response produced by a
request if the newest 'similar' request is in the queue already.
+ ignoreDupResponses="true" does not cancel the request while it is
processed on the server, but just allows avoiding unnecessary updates on the client side
if the response isn't actual now</description>
+ </property>
+ <property>
+ <name>timeout</name>
+ <classname>int</classname>
+ <description>Waiting time for response on a particular request. If no response
is received during this time, the request is aborted</description>
+ </property>
+ <property>
+ <name>disabled</name>
+ <classname>boolean</classname>
+ <description>If "true", disables this component on
page.</description>
+ </property>
+
+ <property>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called before an ajax request
is submitted</description>
+ </property>
+ <property>
+ <name>onbeforedomupdate</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called before DOM is
updated</description>
+ </property>
+ <property>
+ <name>oncomplete</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called after the request is
completed</description>
+ </property>
+ <property>
+ <name>onerror</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called whenever a JavaScript
error occurs</description>
+ </property>
+ <property>
+ <name>sizeExceededBehavior</name>
+ <classname>java.lang.String</classname>
+ <description>Defines the strategies of the queue's behavior if the number of
the requests waiting in the queue is exceeded.
+ There are four strategies: dropNext (by default), dropNew, fireNext ,
fireNew.</description>
+ </property>
+ <property>
+ <name>onsizeexceeded</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called when a size is
exceeded</description>
+ </property>
+ <property>
+ <name>onrequestqueue</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called when the request is
added to the queue</description>
+ </property>
+ <property>
+ <name>onrequestdequeue</name>
+ <classname>java.lang.String</classname>
+ <description>The client-side script method to be called after the request is
removed from the queue</description>
+ </property>
+
+ <property>
+ <name>status</name>
+ <classname>java.lang.String</classname>
+ <description>ID (in format of call UIComponent.findComponent()) of Request
status component</description>
+ </property>
+
+ <property hidden="true">
+ <name>rendered</name>
+ </property>
+ </component>
+</components>
Modified: branches/jsf2.0/ui/core/src/main/config/component/region.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/region.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/region.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -72,12 +72,8 @@
<name>renderRegionOnly</name>
<classname>boolean</classname>
<description>
- Flag to disable rendering in AJAX responses content
- outside of active region. If this attribute set to
- "true" , no one of the components outside of region will
- be included to AJAX response. If set to "false", search
- for components to include in response will be performed
- on all tree. Default value is "false".
+ Excludes all the components from the outside of the region from updating on the
page on Renderer Response phase.
+ Default value is "false".
</description>
<defaultvalue>false</defaultvalue>
</property>
Modified: branches/jsf2.0/ui/core/src/main/config/component/status.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/status.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/status.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -104,7 +104,7 @@
<name>startText</name>
<classname>java.lang.String</classname>
<description>
- Text for display on starting request.
+ Text to display on starting request.
</description>
</property>
<property>
@@ -119,15 +119,14 @@
<name>startStyle</name>
<classname>java.lang.String</classname>
<description>
- CSS style class for the element displayed on the start
- of a request.
+ CSS style rules to be applied to the element displayed when a request is in progress
</description>
</property>
<property>
<name>stopStyle</name>
<classname>java.lang.String</classname>
<description>
- CSS style for element displayed on request completion.
+ CSS style rules to be applied to the element displayed on a request completion
</description>
</property>
@@ -144,31 +143,29 @@
<name>startStyleClass</name>
<classname>java.lang.String</classname>
<description>
- CSS style class for the element displayed on the start
- of a request.
+ Assigns one or more space-separated CSS class names to the element displayed when a
request is in progress
</description>
</property>
<property>
<name>stopStyleClass</name>
<classname>java.lang.String</classname>
<description>
- CSS style class for element displayed on request
+ Assigns one or more space-separated CSS class names to the element displayed on a
request completion
</description>
</property>
<property>
<name>onstart</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code, called on the start
- of a request.
+ The client-side script method to be called at the start
+ of the request
</description>
</property>
<property>
<name>onstop</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code, called on the stop
- of a request.
+ The client-side script method to be called when the request is finished
</description>
</property>
</component>
Modified: branches/jsf2.0/ui/core/src/main/config/component/support.xml
===================================================================
--- branches/jsf2.0/ui/core/src/main/config/component/support.xml 2009-07-10 11:04:14 UTC
(rev 14875)
+++ branches/jsf2.0/ui/core/src/main/config/component/support.xml 2009-07-10 11:13:58 UTC
(rev 14876)
@@ -85,8 +85,7 @@
<name>onsubmit</name>
<classname>java.lang.String</classname>
<description>
- JavaScript code for call before submission of ajax
- event
+ The client-side script method to be called before an ajax request is submitted
</description>
</property>
<property el="false">
@@ -102,7 +101,7 @@
<name>disableDefault</name>
<classname>boolean</classname>
<description>
- <![CDATA[Disables default action for target event ( append "return
false;" to JavaScript )]]>
+ <![CDATA[Disables default action for target event ( append "return
false;" to JavaScript ). Default value is "false"]]>
</description>
<defaultvalue>false</defaultvalue>
</property>
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java
===================================================================
--- branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java 2009-07-10
11:04:14 UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/KeepAlive.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,25 +1,43 @@
-/**
- *
- */
-package org.ajax4jsf.component;
-
-import javax.faces.component.UIComponentBase;
-
-/**
- * @author asmirnov
- *
- */
-public class KeepAlive extends UIComponentBase {
-
- public static final String COMPONENT_TYPE = "org.ajax4jsf.KeepAlive";
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.KeepAlive";
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- @Override
- public String getFamily() {
- return COMPONENT_FAMILY;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+import javax.faces.component.UIComponentBase;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class KeepAlive extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.KeepAlive";
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.KeepAlive";
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+}
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxForm.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -42,7 +42,7 @@
* @version $Revision: 1.1.2.3 $ $Date: 2007/02/06 16:23:22 $
*
*/
-public abstract class UIAjaxForm extends UIForm implements AjaxComponent, AjaxSource
+public abstract class UIAjaxForm extends UIForm implements AjaxComponent, AjaxSource,
IterationStateHolder
{
public static final String COMPONENT_TYPE = "org.ajax4jsf.Form";
@@ -171,4 +171,11 @@
public abstract void setAjaxSubmit(boolean ajax);
+ public Object getIterationState() {
+ return isSubmitted() ? Boolean.TRUE : Boolean.FALSE;
+ }
+
+ public void setIterationState(Object state) {
+ setSubmitted(Boolean.TRUE.equals(state));
+ }
}
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -26,18 +26,14 @@
import java.util.Set;
import javax.el.MethodExpression;
-import javax.faces.FacesException;
import javax.faces.component.ContextCallback;
import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
-import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.context.AjaxContextImpl;
-import org.ajax4jsf.context.InvokerCallback;
import org.ajax4jsf.event.AjaxListener;
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxSupport.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -95,7 +95,7 @@
buildOnEvent.append(onsubmit).append(";");
}
buildOnEvent.append(AjaxRendererUtils.buildOnEvent(this,
- getFacesContext(), getEvent()));
+ getFacesContext(), getEvent(), true));
String script = buildOnEvent.toString();
return script;
}
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIInclude.java
===================================================================
--- branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIInclude.java 2009-07-10
11:04:14 UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIInclude.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -21,6 +21,8 @@
package org.ajax4jsf.component;
+import java.io.IOException;
+
import javax.el.ELContext;
import javax.el.ELException;
import javax.el.ValueExpression;
@@ -51,7 +53,7 @@
public static final String LAYOUT_BLOCK ="block";
public static final String LAYOUT_INLINE ="inline";
- private boolean _ajaxRendered = true;
+ private boolean _ajaxRendered = false;
private boolean _ajaxRenderedSet = false;
private boolean wasNavigation = false;
@@ -63,7 +65,7 @@
* @see org.ajax4jsf.framework.ajax.ViewIdHolder#skipNavigation(java.lang.String)
*/
public boolean skipNavigation(String ViewId) {
-// wasNavigation = true;
+ wasNavigation = true;
return true;
}
@@ -126,8 +128,12 @@
public boolean isAjaxRendered() {
Boolean value = null;
- if(!this._ajaxRenderedSet) {
- ValueExpression ve = getValueExpression("ajaxRendered");
+
+ if(this._ajaxRenderedSet) {
+ return this._ajaxRendered;
+ }
+
+ ValueExpression ve = getValueExpression("ajaxRendered");
if (ve != null) {
try {
value = (Boolean) ve.getValue(getFacesContext().getELContext());
@@ -135,10 +141,11 @@
throw new FacesException(e);
}
}
- }
+
if (null == value) {
- value = this._ajaxRendered;
+// value = this._ajaxRendered;
+ value = isWasNavigation();
}
return (!LAYOUT_NONE.equals(getLayout())) && value;
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIPortlet.java
===================================================================
--- branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIPortlet.java 2009-07-10
11:04:14 UTC (rev 14875)
+++ branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIPortlet.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,56 +1,73 @@
-/**
- *
- */
-package org.ajax4jsf.component;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov
- *
- */
-public class UIPortlet extends UIComponentBase implements NamingContainer {
-
-
- private static final Log _log = LogFactory.getLog(UIPortlet.class);
- /**
- * <p>The standard component type for this component.</p>
- */
- public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
-
-
- /**
- * <p>The standard component family for this component.</p>
- */
- public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";
-
- /* (non-Javadoc)
- * @see javax.faces.component.UIComponent#getFamily()
- */
- public String getFamily() {
- // TODO Auto-generated method stub
- return COMPONENT_FAMILY;
- }
-
- private String portletId = null;
-
- @Override
- public void setId(String id) {
- portletId = null;
- super.setId(id);
- }
-
- // ----------------------------------------------------- UIComponent Methods
- public String getClientId(FacesContext context) {
- if (portletId == null) {
- portletId =
context.getExternalContext().encodeNamespace(super.getClientId(context));
- }
- return portletId;
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.ajax4jsf.component;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class UIPortlet extends UIComponentBase implements NamingContainer {
+
+
+ private static final Log _log = LogFactory.getLog(UIPortlet.class);
+ /**
+ * <p>The standard component type for this component.</p>
+ */
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Portlet";
+
+
+ /**
+ * <p>The standard component family for this component.</p>
+ */
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Portlet";
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FAMILY;
+ }
+
+ private String portletId = null;
+
+ @Override
+ public void setId(String id) {
+ portletId = null;
+ super.setId(id);
+ }
+
+ // ----------------------------------------------------- UIComponent Methods
+ public String getClientId(FacesContext context) {
+ if (portletId == null) {
+ portletId =
context.getExternalContext().encodeNamespace(super.getClientId(context));
+ }
+ return portletId;
+ }
+
+}
Copied: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java (from
rev 14238, trunk/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java)
===================================================================
--- branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java
(rev 0)
+++ branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,124 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public abstract class UIQueue extends UIComponentBase {
+
+ public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
+
+ public static final String COMPONENT_TYPE = "org.ajax4jsf.Queue";
+
+ public static final String COMPONENT_FAMILY = "org.ajax4jsf.Queue";
+
+ public abstract String getName();
+ public abstract void setName(String name);
+
+ public abstract String getOnsubmit();
+ public abstract void setOnsubmit(String onsubmit);
+
+ public abstract String getOncomplete();
+ public abstract void setOncomplete(String oncomplete);
+
+ public abstract String getOnbeforedomupdate();
+ public abstract void setOnbeforedomupdate(String onbeforedomupdate);
+
+ public abstract String getOnerror();
+ public abstract void setOnerror(String onerror);
+
+ public abstract String getOnsizeexceeded();
+ public abstract void setOnsizeexceeded(String onsizeexceeded);
+
+ public abstract boolean isDisabled();
+ public abstract void setDisabled(boolean disabled);
+
+ public abstract int getSize();
+ public abstract void setSize(int size);
+
+ public abstract String getSizeExceededBehavior();
+ public abstract void setSizeExceededBehavior(String behavior);
+
+ public abstract int getTimeout();
+ public abstract void setTimeout(int timeout);
+
+ public abstract int getRequestDelay();
+ public abstract void setRequestDelay(int requestDelay);
+
+ public abstract boolean isIgnoreDupResponses();
+ public abstract void setIgnoreDupResponses(boolean ignoreDupResponses);
+
+ public abstract String getOnrequestqueue();
+ public abstract void setOnrequestqueue(String onrequestqueue);
+
+ public abstract String getOnrequestdequeue();
+ public abstract void setOnrequestdequeue(String onrequestdequeue);
+
+ public abstract String getStatus();
+ public abstract void setStatus(String status);
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ private UIComponent findParentForm() {
+ UIComponent component = getParent();
+ while (component != null && !(component instanceof UIForm)) {
+ component = component.getParent();
+ }
+
+ return component;
+ }
+
+ public String getClientName(FacesContext context) {
+ UIComponent form = findParentForm();
+ String name = getName();
+ String clientName;
+
+ if (form != null) {
+ String formClientId = form.getClientId(context);
+
+ if (name != null && name.length() != 0) {
+ clientName = formClientId + NamingContainer.SEPARATOR_CHAR + name;
+ } else {
+ clientName = formClientId;
+ }
+ } else {
+ if (name == null || name.length() == 0) {
+ name = GLOBAL_QUEUE_NAME;
+ }
+
+ clientName = context.getExternalContext().encodeNamespace(name);
+ }
+
+ return clientName;
+ }
+}
Modified: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/component/UISelector.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -47,7 +47,7 @@
private static final AjaxChildrenRenderer childrenRenderer = new AjaxChildrenRenderer()
{
- protected Class getComponentClass() {
+ protected Class<? extends UIComponent> getComponentClass() {
return UISelector.class;
}
@@ -74,20 +74,19 @@
* @see
org.ajax4jsf.framework.ajax.AjaxChildrenEncoder#encodeAjaxChild(javax.faces.context.FacesContext,
* java.lang.String, java.util.Set, java.util.Set)
*/
- public void encodeAjaxChild(FacesContext context, String path, Set ids,
- Set renderedAreas) throws IOException {
+ public void encodeAjaxChild(FacesContext context, String path,
+ Set<String> ids, Set<String> renderedAreas) throws IOException {
if (getChildCount() != 1) {
- throw new FacesException(
- "Selector component must have one, and only one, child");
+ throw new FacesException("Selector component must have one, and only one,
child");
}
UIComponent child = (UIComponent) getChildren().get(0);
- Set ajaxKeys = getAjaxKeys();
+ Set<Object> ajaxKeys = getAjaxKeys();
if (null != ajaxKeys) {
String iterationProperty = getIterationProperty();
try {
Object savedKey = PropertyUtils.getProperty(child,
iterationProperty);
- for (Iterator iter = ajaxKeys.iterator(); iter.hasNext();) {
+ for (Iterator<Object> iter = ajaxKeys.iterator(); iter.hasNext();) {
Object key = (Object) iter.next();
PropertyUtils.setProperty(child, iterationProperty, key);
if (true) {
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxCommandRendererBase.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -22,7 +22,7 @@
package org.ajax4jsf.renderkit;
import java.io.IOException;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@@ -62,7 +62,7 @@
Set<String> toProcess = AjaxRendererUtils.asSet(ajaxComponent
.getProcess());
if (null != toProcess) {
- HashSet<String> componentIdsToProcess = new HashSet<String>();
+ Set<String> componentIdsToProcess = new LinkedHashSet<String>();
for (String componentId : toProcess) {
UIComponent component = getUtils().findComponentFor(uiComponent, componentId);
if(null != component){
@@ -80,7 +80,7 @@
public String getOnClick(FacesContext context, UIComponent component) {
StringBuffer onClick;
if (!getUtils().isBooleanAttribute(component, "disabled")) {
- onClick = AjaxRendererUtils.buildOnClick(component, context);
+ onClick = AjaxRendererUtils.buildOnClick(component, context, true);
if (!"reset".equals(component.getAttributes().get("type"))) {
onClick.append(";return false;");
}
@@ -125,7 +125,7 @@
return false;
}
String clientId = uiComponent.getClientId(facesContext);
- Map paramMap = facesContext.getExternalContext()
+ Map<String, String> paramMap = facesContext.getExternalContext()
.getRequestParameterMap();
Object value = paramMap.get(clientId);
boolean submitted = null != value;
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/AjaxFunctionRendererBase.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.context.FacesContext;
@@ -46,29 +47,33 @@
*
* @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
- protected Class getComponentClass() {
- // TODO Auto-generated method stub
+ protected Class<? extends UIComponent> getComponentClass() {
return null;
}
public String getFunction(FacesContext context, UIAjaxFunction component) {
- StringBuffer script = new StringBuffer(component.getName()).append("=");
+ String functionName = component.getName();
+ if (functionName == null) {
+ throw new FacesException("Value of 'name' attribute of a4j:jsFunction
component is null!");
+ }
+
+ StringBuffer script = new StringBuffer(functionName).append("=");
JSFunctionDefinition func = new JSFunctionDefinition();
//func.setName(component.getName());
// Create AJAX Submit function.
JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(
component, context,AjaxRendererUtils.AJAX_FUNCTION_NAME);
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
- Map parameters = (Map) options.get("parameters");
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
component, true);
+ Map<String, Object> parameters = (Map<String, Object>)
options.get("parameters");
if (null == parameters) {
- parameters = new HashMap();
+ parameters = new HashMap<String, Object>();
options.put("parameters", parameters);
}
ajaxFunction.addParameter(JSReference.NULL);
ajaxFunction.addParameter(options);
// Fill parameters.
- for (Iterator it = component.getChildren().iterator(); it.hasNext();) {
- UIComponent child = (UIComponent) it.next();
+ for (Iterator<UIComponent> it = component.getChildren().iterator();
it.hasNext();) {
+ UIComponent child = it.next();
if (child instanceof UIParameter) {
UIParameter parameter = ((UIParameter) child);
String name = parameter.getName();
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/LoadResourceRendererBase.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -49,7 +49,7 @@
/* (non-Javadoc)
* @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
*/
- protected Class getComponentClass() {
+ protected Class<? extends UIComponent> getComponentClass() {
return UIResource.class;
}
@@ -63,7 +63,7 @@
String family = resource.getFamily();
ResourceRenderer renderer = null;
InternetResource internetResource = null;
- Map<String, Object> attributes = Collections.EMPTY_MAP;
+ Map<String, Object> attributes = Collections.emptyMap();
if (SCRIPT_COMPONENT_FAMILY.equals(family)) {
renderer = InternetResourceBuilder.getInstance().getScriptRenderer();
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxFormRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -22,7 +22,6 @@
package org.ajax4jsf.renderkit.html;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -38,6 +37,7 @@
import org.ajax4jsf.component.UIAjaxForm;
import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.AjaxComponentRendererBase;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -132,7 +132,7 @@
component, context,
AJAX_FORM_FUNCTION_NAME);
ajaxFunction.addParameter(AjaxRendererUtils.buildEventOptions(
- context, component));
+ context, component, false));
ajaxFunction.appendScript(onSubmit);
writer.writeURIAttribute("action", onSubmit, "action");
} else {
@@ -238,6 +238,7 @@
Object value) throws IOException {
writer.startElement(HTML.INPUT_ELEM, null);
writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, name, null);
writer.writeAttribute(HTML.value_ATTRIBUTE, value != null?value:"", null);
writer.endElement(HTML.INPUT_ELEM);
@@ -300,7 +301,7 @@
script.append("\n}");
script.append("\n");
script.append("function
").append("clearFormHiddenParams_").append(
- getValidJavascriptName(formName));
+ ScriptUtils.getValidJavascriptName(formName));
script.append("(){").append(functionName).append("();}\n");
// MyFaces 1.1.5 clear form function name
@@ -335,59 +336,7 @@
* @return String
*/
public String getClearHiddenCommandFormParamsFunctionName(String formName) {
- return "clear_" + getValidJavascriptName(formName);
+ return "clear_" + ScriptUtils.getValidJavascriptName(formName);
}
- public String getValidJavascriptName(String s) {
-
- StringBuffer buf = null;
- for (int i = 0, len = s.length(); i < len; i++) {
- char c = s.charAt(i);
-
- if (Character.isLetterOrDigit(c)||c=='_' ) {
- // allowed char
- if (buf != null)
- buf.append(c);
- } else {
- if (buf == null) {
- buf = new StringBuffer(s.length() + 10);
- buf.append(s.substring(0, i));
- }
-
- buf.append('_');
- if (c < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
-
- if (c < 128) {
- // first 128 chars match their byte representation in UTF-8
- buf.append(Integer.toHexString(c).toUpperCase());
- } else {
- byte[] bytes;
- try {
- bytes = Character.toString(c).getBytes("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
-
- for (int j = 0; j < bytes.length; j++) {
- int intVal = bytes[j];
- if (intVal < 0) {
- // intVal will be >= 128
- intVal = 256 + intVal;
- } else if (intVal < 16) {
- // pad single hex digit values with '0' on the left
- buf.append('0');
- }
- buf.append(Integer.toHexString(intVal).toUpperCase());
- }
- }
- }
-
- }
-
- return buf == null ? s : buf.toString();
- }
-
}
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -59,7 +59,7 @@
StringBuffer script = new StringBuffer("\n");
if(poll.isEnabled()){
JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_POLL_FUNCTION);
- Map options = AjaxRendererUtils.buildEventOptions(context, component);
+ Map options = AjaxRendererUtils.buildEventOptions(context, component, true);
Integer interval = new Integer(poll.getInterval());
options.put("pollinterval", interval);
options.put("pollId", component.getClientId(context));
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/AjaxPushRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -69,7 +69,7 @@
if(push.isEnabled()){
JSFunction function = AjaxRendererUtils.buildAjaxFunction(component, context,
AJAX_PUSH_FUNCTION);
// Set dummy form id, if nessesary.
- Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
component);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context,
component, false);
options.put("dummyForm",
component.getClientId(context)+RendererUtils.DUMMY_FORM_ID);
int interval = push.getInterval();
if(interval == Integer.MIN_VALUE){
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -36,9 +36,11 @@
import javax.faces.event.ActionEvent;
import org.ajax4jsf.Messages;
+import org.ajax4jsf.javascript.AjaxScript;
import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,14 +51,20 @@
* @author shura
*
*/
-public class HtmlCommandLinkRenderer extends RendererBase {
+public class HtmlCommandLinkRenderer extends HeaderResourcesRendererBase {
private static final Log _log = LogFactory.getLog(HtmlCommandLinkRenderer.class);
private static final String[] LINK_EXCLUSIONS =
{"onclick","target","href"};
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+
+ private InternetResource[] scripts = null;
+ private static final String FORM_SCRIPT =
"/org/ajax4jsf/javascript/scripts/form.js";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
*/
protected void doDecode(FacesContext context, UIComponent component) {
UIForm form = getUtils().getNestingForm(context,component);
@@ -120,7 +128,19 @@
Object child = iter.next();
if (child instanceof UIParameter) {
UIParameter param = (UIParameter) child;
- parameters.put(param.getName(),param.getValue());
+ String name = ((UIParameter) child).getName();
+ Object value = ((UIParameter) child).getValue();
+
+ if (name == null) {
+ throw new IllegalArgumentException(Messages.getMessage(
+ Messages.UNNAMED_PARAMETER_ERROR, component.getClientId(context)));
+ }
+
+ if (value == null) {
+ value = "";
+ }
+
+ parameters.put(name,value);
}
}
@@ -216,4 +236,18 @@
writer.writeText(valueString,null);
}
}
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.renderkit.HeaderResourcesRendererBase#getScripts()
+ */
+ protected InternetResource[] getScripts() {
+ synchronized (this) {
+ if (scripts == null) {
+ scripts = new InternetResource[1];
+ scripts[0] = getResource(FORM_SCRIPT);
+ }
+ }
+
+ return scripts;
+ }
}
Copied:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java (from
rev 14238, trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java)
===================================================================
--- branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,190 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.QueueRegistry;
+import org.ajax4jsf.component.UIQueue;
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils;
+import org.ajax4jsf.renderkit.html.scripts.QueueScript;
+import org.ajax4jsf.resource.InternetResource;
+import org.richfaces.component.util.MessageUtil;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueRenderer extends HeaderResourcesRendererBase {
+
+ private static final String SIZE_EXCEEDED_BEHAVIOR = "sizeExceededBehavior";
+
+ private static final String SIZE = "size";
+
+ private static final String QUEUE_ONSUBMIT_ATTRIBUTE = "queueonsubmit";
+
+ private static final String QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE =
"queueonbeforedomupdate";
+
+ private static final String QUEUE_ONCOMPLETE_ATTRIBUTE = "queueoncomplete";
+
+ private static final String QUEUE_ONERROR_ATTRIBUTE = "queueonerror";
+
+ public static final String BEHAVIOR_DROP_NEXT = "dropNext";
+
+ public static final String BEHAVIOR_DROP_NEW = "dropNew";
+
+ public static final String BEHAVIOR_FIRE_NEXT = "fireNext";
+
+ public static final String BEHAVIOR_FIRE_NEW = "fireNew";
+
+ private static final String[] REQUEST_ATTRIBUTES = new String[] {
+ "ignoreDupResponses",
+ "requestDelay",
+ "timeout"
+ };
+
+ private InternetResource[] scripts = new InternetResource[] {
+ getResource(AjaxScript.class.getName()),
+ getResource(QueueScript.class.getName())
+ };
+
+ @Override
+ protected InternetResource[] getScripts() {
+ return scripts;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIQueue.class;
+ }
+
+ private static final RendererUtils utils = RendererUtils.getInstance();
+
+ private boolean isValidBehaviorValue(String value) {
+ return BEHAVIOR_DROP_NEW.equals(value) || BEHAVIOR_DROP_NEXT.equals(value) ||
+ BEHAVIOR_FIRE_NEW.equals(value) || BEHAVIOR_FIRE_NEXT.equals(value);
+ }
+
+ private QueueRendererData createRendererData(FacesContext context, UIQueue queue) {
+ Map<String, Object> attributes = queue.getAttributes();
+
+ QueueRendererData data = new QueueRendererData();
+
+ int size = queue.getSize();
+ if (utils.shouldRenderAttribute(size)) {
+ data.addQueueAttribute(SIZE, size);
+ }
+
+ String sizeExceededBehavior = (String) attributes.get(SIZE_EXCEEDED_BEHAVIOR);
+ if (utils.shouldRenderAttribute(sizeExceededBehavior)) {
+ if (!isValidBehaviorValue(sizeExceededBehavior)) {
+ throw new IllegalArgumentException(sizeExceededBehavior + " value of " +
+ SIZE_EXCEEDED_BEHAVIOR + " attribute is not a legal one for component: " +
+ MessageUtil.getLabel(context, queue));
+ }
+
+ data.addQueueAttribute(SIZE_EXCEEDED_BEHAVIOR, sizeExceededBehavior);
+ }
+
+ String onsizeexceeded = queue.getOnsizeexceeded();
+ if (utils.shouldRenderAttribute(onsizeexceeded)) {
+ data.addQueueAttribute("onsizeexceeded", new
JSFunctionDefinition("query", "options",
"event").addToBody(onsizeexceeded));
+ }
+
+ String onrequestqueue = queue.getOnrequestqueue();
+ if (utils.shouldRenderAttribute(onrequestqueue)) {
+ data.addQueueAttribute("onrequestqueue", new
JSFunctionDefinition("query", "options",
"event").addToBody(onrequestqueue));
+ }
+
+ String onrequestdequeue = queue.getOnrequestdequeue();
+ if (utils.shouldRenderAttribute(onrequestdequeue)) {
+ data.addQueueAttribute("onrequestdequeue", new
JSFunctionDefinition("query", "options",
"event").addToBody(onrequestdequeue));
+ }
+
+ for (String attributeName : REQUEST_ATTRIBUTES) {
+ Object value = attributes.get(attributeName);
+ if (utils.shouldRenderAttribute(value)) {
+ data.addRequestAttribute(attributeName, value);
+ }
+ }
+
+ String status = AjaxRendererUtils.getAjaxStatus(queue);
+ if (utils.shouldRenderAttribute(status)) {
+ data.addRequestAttribute(AjaxRendererUtils.STATUS_ATTR_NAME, status);
+ }
+
+ String onBeforeDomUpdate = queue.getOnbeforedomupdate();
+ if (utils.shouldRenderAttribute(onBeforeDomUpdate)) {
+ data.addRequestAttribute(QUEUE_ONBEFOREDOMUPDATE_ATTRIBUTE,
AjaxRendererUtils.buildAjaxOnBeforeDomUpdate(onBeforeDomUpdate));
+ }
+
+ String oncomplete = queue.getOncomplete();
+ if (utils.shouldRenderAttribute(oncomplete)) {
+ data.addRequestAttribute(QUEUE_ONCOMPLETE_ATTRIBUTE,
AjaxRendererUtils.buildAjaxOncomplete(oncomplete));
+ }
+
+ String onsubmit = queue.getOnsubmit();
+ if (utils.shouldRenderAttribute(onsubmit)) {
+ JSFunctionDefinition onsubmitFunction = new
JSFunctionDefinition("request");
+ onsubmitFunction.addToBody(onsubmit);
+
+ data.addRequestAttribute(QUEUE_ONSUBMIT_ATTRIBUTE, onsubmitFunction);
+ }
+
+ String onerror = queue.getOnerror();
+ if (utils.shouldRenderAttribute(onerror)) {
+ JSFunctionDefinition onerrorFunction = new JSFunctionDefinition("request",
"status", "message");
+ onerrorFunction.addToBody(onerror);
+
+ data.addRequestAttribute(QUEUE_ONERROR_ATTRIBUTE, onerrorFunction);
+ }
+
+ return data;
+ }
+
+ @Override
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeBegin(context, component);
+ }
+
+ @Override
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ super.encodeEnd(context, component);
+
+ UIQueue queue = (UIQueue) component;
+ if (!queue.isDisabled()) {
+ QueueRegistry.getInstance(context).registerQueue(context,
+ queue.getClientName(context),
+ createRendererData(context, queue));
+ }
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
(from rev 14238,
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java)
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/QueueRendererData.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,61 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.ajax4jsf.renderkit.html;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @author Denis Morozov
+ * @since 3.3.0
+ */
+public class QueueRendererData {
+
+ private Map<String, Object> queueAttributes;
+
+ private Map<String, Object> requestAttributes;
+
+ public void addQueueAttribute(String key, Object value) {
+ if (queueAttributes == null) {
+ queueAttributes = new LinkedHashMap<String, Object>();
+ }
+
+ queueAttributes.put(key, value);
+ }
+
+ public void addRequestAttribute(String key, Object value) {
+ if (requestAttributes == null) {
+ requestAttributes = new LinkedHashMap<String, Object>();
+ }
+
+ requestAttributes.put(key, value);
+ }
+
+ public Map<String, Object> getQueueAttributes() {
+ return queueAttributes;
+ }
+
+ public Map<String, Object> getRequestAttributes() {
+ return requestAttributes;
+ }
+}
Copied: branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts (from
rev 14238, trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts)
Deleted:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java 2009-05-18
14:55:17 UTC (rev 14238)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,52 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html.scripts;
-
-import org.ajax4jsf.resource.InternetResourceBase;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.ResourceRenderer;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueScript extends InternetResourceBase {
-
- private static final ResourceRenderer renderer = new QueueScriptResourceRenderer();
-
- private String key = getClass().getName();
-
- @Override
- public String getKey() {
- return key;
- }
-
- @Override
- public ResourceRenderer getRenderer(ResourceContext resourceContext) {
- return renderer;
- }
-
- @Override
- public boolean isCacheable(ResourceContext resourceContext) {
- return false;
- }
-}
Copied:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
(from rev 14238,
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java)
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScript.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,52 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html.scripts;
+
+import org.ajax4jsf.resource.InternetResourceBase;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.resource.ResourceRenderer;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueScript extends InternetResourceBase {
+
+ private static final ResourceRenderer renderer = new QueueScriptResourceRenderer();
+
+ private String key = getClass().getName();
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public ResourceRenderer getRenderer(ResourceContext resourceContext) {
+ return renderer;
+ }
+
+ @Override
+ public boolean isCacheable(ResourceContext resourceContext) {
+ return false;
+ }
+}
Deleted:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
===================================================================
---
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2009-05-18
14:55:17 UTC (rev 14238)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,165 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-package org.ajax4jsf.renderkit.html.scripts;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.ajax4jsf.component.QueueRegistry;
-import org.ajax4jsf.component.UIQueue;
-import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.javascript.JSObject;
-import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.renderkit.RendererUtils.HTML;
-import org.ajax4jsf.renderkit.html.QueueRendererData;
-import org.ajax4jsf.resource.BaseResourceRenderer;
-import org.ajax4jsf.resource.InternetResource;
-
-/**
- * @author Nick Belaevski
- * @since 3.3.0
- */
-public class QueueScriptResourceRenderer extends BaseResourceRenderer {
-
- public static final String QUEUE_SCRIPT_ID = "org.ajax4jsf.queue_script";
-
- private void encodeQueue(ResponseWriter writer, String queueName, QueueRendererData
queueData)
- throws IOException {
-
- Map<String, Object> queueAttributes = null;
- Map<String, Object> requestAttributes = null;
-
- if (queueData != null) {
- queueAttributes = queueData.getQueueAttributes();
- requestAttributes = queueData.getRequestAttributes();
- }
-
- writer.writeText("if (!EventQueue.getQueue(" +
ScriptUtils.toScript(queueName) + ")) { EventQueue.addQueue(", null);
- writer.writeText(
- new JSObject("EventQueue",
- queueName,
- queueAttributes,
- requestAttributes
- ).toScript(), null);
- writer.writeText(") };", null);
- }
-
- @Override
- protected void customEncode(InternetResource resource,
- FacesContext context, Object data) throws IOException {
- super.customEncode(resource, context, data);
-
- Map<String, Object> queues = (Map<String, Object>) data;
- ResponseWriter writer = context.getResponseWriter();
-
- writer.writeText("if (typeof A4J != 'undefined') { if (A4J.AJAX) { with
(A4J.AJAX) {", null);
- for (Entry<String, Object> entry : queues.entrySet()) {
- encodeQueue(writer, entry.getKey(), (QueueRendererData) entry.getValue());
- }
- writer.writeText("}}};", null);
- }
-
- protected void doEncode(InternetResource resource, FacesContext context,
- Object data, Map<String, Object> attributes) throws IOException {
-
- ExternalContext externalContext = context.getExternalContext();
- Map<String, Object> requestMap = externalContext.getRequestMap();
-
- String resourceKey = resource.getKey();
- if (requestMap.get(resourceKey) == null) {
- requestMap.put(resourceKey, Boolean.TRUE);
-
- QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
- if (queueRegistry.isShouldCreateDefaultGlobalQueue()) {
- String encodedGlobalQueueName = context.getExternalContext().encodeNamespace(
- UIQueue.GLOBAL_QUEUE_NAME);
-
- if (!queueRegistry.containsQueue(encodedGlobalQueueName)) {
- queueRegistry.registerQueue(context, encodedGlobalQueueName, null);
- }
- }
-
- if (queueRegistry.hasQueuesToEncode()) {
- super.encode(resource, context, queueRegistry.getRegisteredQueues(context),
attributes);
- }
- }
- }
-
- private String encodeQueueScriptId(FacesContext context) {
- String encodedId = QUEUE_SCRIPT_ID;
-
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (!ajaxContext.isAjaxRequest()) {
- encodedId = context.getExternalContext().encodeNamespace(encodedId);
- }
-
- return encodedId;
- }
-
- @Override
- public void encode(InternetResource resource, FacesContext context,
- Object data, Map<String, Object> attributes) throws IOException {
-
- Map<String,Object> newAttributes = new LinkedHashMap<String,
Object>(attributes);
- newAttributes.put(HTML.id_ATTRIBUTE, encodeQueueScriptId(context));
-
- doEncode(resource, context, data, newAttributes);
- }
-
- @Override
- public void encode(InternetResource resource, FacesContext context,
- Object data) throws IOException {
-
- doEncode(resource, context, data,
- Collections.singletonMap(HTML.id_ATTRIBUTE, (Object) encodeQueueScriptId(context)));
- }
-
- @Override
- protected String[][] getCommonAttrs() {
- return new String[][] {
- {HTML.TYPE_ATTR, getContentType()},
- };
- }
-
- @Override
- protected String getHrefAttr() {
- return null;
- }
-
- @Override
- protected String getTag() {
- return HTML.SCRIPT_ELEM;
- }
-
- public String getContentType() {
- return "text/javascript";
- }
-
-}
Copied:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
(from rev 14238,
trunk/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java)
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/renderkit/html/scripts/QueueScriptResourceRenderer.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,165 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.ajax4jsf.renderkit.html.scripts;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.component.QueueRegistry;
+import org.ajax4jsf.component.UIQueue;
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSObject;
+import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.html.QueueRendererData;
+import org.ajax4jsf.resource.BaseResourceRenderer;
+import org.ajax4jsf.resource.InternetResource;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class QueueScriptResourceRenderer extends BaseResourceRenderer {
+
+ public static final String QUEUE_SCRIPT_ID = "org.ajax4jsf.queue_script";
+
+ private void encodeQueue(ResponseWriter writer, String queueName, QueueRendererData
queueData)
+ throws IOException {
+
+ Map<String, Object> queueAttributes = null;
+ Map<String, Object> requestAttributes = null;
+
+ if (queueData != null) {
+ queueAttributes = queueData.getQueueAttributes();
+ requestAttributes = queueData.getRequestAttributes();
+ }
+
+ writer.writeText("if (!EventQueue.getQueue(" +
ScriptUtils.toScript(queueName) + ")) { EventQueue.addQueue(", null);
+ writer.writeText(
+ new JSObject("EventQueue",
+ queueName,
+ queueAttributes,
+ requestAttributes
+ ).toScript(), null);
+ writer.writeText(") };", null);
+ }
+
+ @Override
+ protected void customEncode(InternetResource resource,
+ FacesContext context, Object data) throws IOException {
+ super.customEncode(resource, context, data);
+
+ Map<String, Object> queues = (Map<String, Object>) data;
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.writeText("if (typeof A4J != 'undefined') { if (A4J.AJAX) { with
(A4J.AJAX) {", null);
+ for (Entry<String, Object> entry : queues.entrySet()) {
+ encodeQueue(writer, entry.getKey(), (QueueRendererData) entry.getValue());
+ }
+ writer.writeText("}}};", null);
+ }
+
+ protected void doEncode(InternetResource resource, FacesContext context,
+ Object data, Map<String, Object> attributes) throws IOException {
+
+ ExternalContext externalContext = context.getExternalContext();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
+
+ String resourceKey = resource.getKey();
+ if (requestMap.get(resourceKey) == null) {
+ requestMap.put(resourceKey, Boolean.TRUE);
+
+ QueueRegistry queueRegistry = QueueRegistry.getInstance(context);
+ if (queueRegistry.isShouldCreateDefaultGlobalQueue()) {
+ String encodedGlobalQueueName = context.getExternalContext().encodeNamespace(
+ UIQueue.GLOBAL_QUEUE_NAME);
+
+ if (!queueRegistry.containsQueue(encodedGlobalQueueName)) {
+ queueRegistry.registerQueue(context, encodedGlobalQueueName, null);
+ }
+ }
+
+ if (queueRegistry.hasQueuesToEncode()) {
+ super.encode(resource, context, queueRegistry.getRegisteredQueues(context),
attributes);
+ }
+ }
+ }
+
+ private String encodeQueueScriptId(FacesContext context) {
+ String encodedId = QUEUE_SCRIPT_ID;
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (!ajaxContext.isAjaxRequest()) {
+ encodedId = context.getExternalContext().encodeNamespace(encodedId);
+ }
+
+ return encodedId;
+ }
+
+ @Override
+ public void encode(InternetResource resource, FacesContext context,
+ Object data, Map<String, Object> attributes) throws IOException {
+
+ Map<String,Object> newAttributes = new LinkedHashMap<String,
Object>(attributes);
+ newAttributes.put(HTML.id_ATTRIBUTE, encodeQueueScriptId(context));
+
+ doEncode(resource, context, data, newAttributes);
+ }
+
+ @Override
+ public void encode(InternetResource resource, FacesContext context,
+ Object data) throws IOException {
+
+ doEncode(resource, context, data,
+ Collections.singletonMap(HTML.id_ATTRIBUTE, (Object) encodeQueueScriptId(context)));
+ }
+
+ @Override
+ protected String[][] getCommonAttrs() {
+ return new String[][] {
+ {HTML.TYPE_ATTR, getContentType()},
+ };
+ }
+
+ @Override
+ protected String getHrefAttr() {
+ return null;
+ }
+
+ @Override
+ protected String getTag() {
+ return HTML.SCRIPT_ELEM;
+ }
+
+ public String getContentType() {
+ return "text/javascript";
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/ActionParamHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -27,20 +27,19 @@
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.event.ActionEvent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
import org.ajax4jsf.Messages;
import org.ajax4jsf.component.UIActionParameter;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:23 $
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxListenerHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -27,21 +27,19 @@
import javax.el.ValueExpression;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.Messages;
import org.ajax4jsf.event.AjaxListener;
import org.ajax4jsf.event.AjaxListenerHelper;
import org.ajax4jsf.event.AjaxSource;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.el.LegacyValueBinding;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagException;
-import com.sun.facelets.tag.TagHandler;
-
/**
* Register an ActionListener instance on the UIComponent associated with the
* closest parent UIComponent custom action. <p/> See <a
target="_new"
@@ -101,7 +99,7 @@
ve = this.binding.getValueExpression(ctx,
AjaxListener.class);
// TODO - handle both JSF 1.2/1.1 cases.
- listener = new AjaxListenerHelper(new LegacyValueBinding(ve));
+ listener = new AjaxListenerHelper(ve);
}
if (listener == null) {
try {
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxPushHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxPushHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxPushHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -23,17 +23,17 @@
import java.util.EventListener;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
import org.ajax4jsf.component.UIPush;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
/**
* @author shura (latest modification by $Author$)
* @version $Revision$ $Date$
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/AjaxSupportHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -27,16 +27,15 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.taglib.html.jsp.AjaxSupportTag;
import org.ajax4jsf.webapp.taglib.AjaxComponentHandler;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-
/**
* "proxy" class for creating UIAjaxSupport component as facet for it's
parent.
* @author shura (latest modification by $Author: alexsmirnov $)
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/FacetHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -27,16 +27,15 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagException;
+import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.Messages;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagException;
-import com.sun.facelets.tag.TagHandler;
-
/**
* Register a named facet on the UIComponent associated with the closest parent
* UIComponent custom action. <p/> See <a target="_new"
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeFaceletContext.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -35,11 +35,9 @@
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.TemplateClient;
-
/**
* @author shura
*
@@ -58,13 +56,14 @@
this.ids = new HashMap();
}
- /**
- * @param client
- * @see com.sun.facelets.FaceletContext#extendClient(com.sun.facelets.TemplateClient)
- */
- public void extendClient(TemplateClient client) {
- this.defaultContext.extendClient(client);
- }
+ //TODO JSF 2.0 analog?
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#extendClient(com.sun.facelets.TemplateClient)
+// */
+// public void extendClient(TemplateClient client) {
+// this.defaultContext.extendClient(client);
+// }
/**
* @param base
@@ -157,19 +156,20 @@
return this.defaultContext.hashCode();
}
- /**
- * @param parent
- * @param name
- * @return
- * @throws IOException
- * @throws FaceletException
- * @throws FacesException
- * @throws ELException
- * @see
com.sun.facelets.FaceletContext#includeDefinition(javax.faces.component.UIComponent,
java.lang.String)
- */
- public boolean includeDefinition(UIComponent parent, String name) throws IOException,
FaceletException, FacesException, ELException {
- return this.defaultContext.includeDefinition(parent, name);
- }
+ //TODO JSF 2.0 analog?
+// /**
+// * @param parent
+// * @param name
+// * @return
+// * @throws IOException
+// * @throws FaceletException
+// * @throws FacesException
+// * @throws ELException
+// * @see
com.sun.facelets.FaceletContext#includeDefinition(javax.faces.component.UIComponent,
java.lang.String)
+// */
+// public boolean includeDefinition(UIComponent parent, String name) throws IOException,
FaceletException, FacesException, ELException {
+// return this.defaultContext.includeDefinition(parent, name);
+// }
/**
* @param parent
@@ -205,23 +205,24 @@
return this.defaultContext.isPropertyResolved();
}
- /**
- * @param client
- * @see com.sun.facelets.FaceletContext#popClient(com.sun.facelets.TemplateClient)
- */
- public void popClient(TemplateClient client) {
- this.defaultContext.popClient(client);
- }
+ //TODO JSF 2.0 analog?
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#popClient(com.sun.facelets.TemplateClient)
+// */
+// public void popClient(TemplateClient client) {
+// this.defaultContext.popClient(client);
+// }
+//
+// /**
+// * @param client
+// * @see com.sun.facelets.FaceletContext#pushClient(com.sun.facelets.TemplateClient)
+// */
+// public void pushClient(TemplateClient client) {
+// this.defaultContext.pushClient(client);
+// }
/**
- * @param client
- * @see com.sun.facelets.FaceletContext#pushClient(com.sun.facelets.TemplateClient)
- */
- public void pushClient(TemplateClient client) {
- this.defaultContext.pushClient(client);
- }
-
- /**
* @param key
* @param contextObject
* @see javax.el.ELContext#putContext(java.lang.Class, java.lang.Object)
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/IncludeHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -27,15 +27,13 @@
import javax.el.VariableMapper;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagAttribute;
import org.ajax4jsf.component.UIInclude;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.el.VariableMapperWrapper;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
/**
* @author shura
*
@@ -56,13 +54,13 @@
* javax.faces.component.UIComponent,
* javax.faces.component.UIComponent)
*/
- protected void onComponentCreated(FaceletContext ctx, UIComponent c,
+ public void onComponentCreated(FaceletContext ctx, UIComponent c,
UIComponent parent) {
// TODO Auto-generated method stub
super.onComponentCreated(ctx, c, parent);
}
- protected void applyNextHandler(FaceletContext ctx, UIComponent component)
+ public void applyNextHandler(FaceletContext ctx, UIComponent component)
throws IOException, FacesException, ELException {
String path;
if (component instanceof UIInclude) {
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/KeepAliveHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -28,17 +28,16 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.el.ValueBinding;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.FaceletException;
+import javax.faces.view.facelets.TagAttribute;
+import javax.faces.view.facelets.TagAttributeException;
+import javax.faces.view.facelets.TagConfig;
+import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.Messages;
import org.ajax4jsf.event.AjaxPhaseListener;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.FaceletException;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.TagAttributeException;
-import com.sun.facelets.tag.TagConfig;
-import com.sun.facelets.tag.TagHandler;
-
/**
* @author shura
*
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/MediaOutputHandler.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -23,17 +23,17 @@
import java.io.OutputStream;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
import org.ajax4jsf.component.UIMediaOutput;
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.MetaRuleset;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/RowKeyConverterRule.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,85 +1,31 @@
/**
- *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.ajax4jsf.taglib.html.facelets;
-import javax.faces.convert.Converter;
-import org.ajax4jsf.component.UIDataAdaptor;
-
-import com.sun.facelets.FaceletContext;
-import com.sun.facelets.tag.MetaRule;
-import com.sun.facelets.tag.Metadata;
-import com.sun.facelets.tag.MetadataTarget;
-import com.sun.facelets.tag.TagAttribute;
-
/**
* Apply rowKeyConverter to component
* @author Maksim Kaszynski
- *
*/
-public class RowKeyConverterRule extends MetaRule {
+@Deprecated
+public class RowKeyConverterRule extends org.ajax4jsf.webapp.taglib.RowKeyConverterRule
{
- static final class DynamicConverterMetaData extends Metadata {
-
- private final TagAttribute attribute;
-
- public DynamicConverterMetaData(TagAttribute attribute) {
- super();
- this.attribute = attribute;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UIDataAdaptor) instance).setValueExpression("rowKeyConverter",
- attribute.getValueExpression(ctx, Converter.class));
-
- }
- }
-
- static final class StaticConverterMetadata extends Metadata {
-
- private final String converterId;
-
- public StaticConverterMetadata(String converterId) {
- super();
- this.converterId = converterId;
- }
-
- @Override
- public void applyMetadata(FaceletContext ctx, Object instance) {
- Converter converter = ctx.getFacesContext().getApplication()
- .createConverter(converterId);
- ((UIDataAdaptor) instance).setRowKeyConverter(converter);
-
- }
- }
-
- public static final RowKeyConverterRule INSTANCE = new RowKeyConverterRule();
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String,
- * com.sun.facelets.tag.TagAttribute,
- * com.sun.facelets.tag.MetadataTarget)
- */
- @Override
- public Metadata applyRule(String name, TagAttribute attribute,
- MetadataTarget meta) {
-
- if (meta.isTargetInstanceOf(UIDataAdaptor.class)) {
- if ("rowKeyConverter".equals(name)) {
- if (attribute.isLiteral()) {
- return new StaticConverterMetadata(attribute.getValue());
- } else {
- return new DynamicConverterMetaData(attribute);
- }
- }
- }
-
- return null;
- }
-
}
Added:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/facelets/VariableMapperWrapper.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,65 @@
+/**
+ * Licensed under the Common Development and Distribution License,
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *
http://www.sun.com/cddl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.ajax4jsf.taglib.html.facelets;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.el.VariableMapper;
+
+class VariableMapperWrapper extends VariableMapper {
+
+ private VariableMapper mapper;
+
+ private Map<String, ValueExpression> vars = null;
+
+ public VariableMapperWrapper(VariableMapper mapper) {
+ this.mapper = mapper;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#resolveVariable(java.lang.String)
+ */
+ @Override
+ public ValueExpression resolveVariable(String variable) {
+ ValueExpression ve = null;
+ try {
+ if (this.vars != null) {
+ ve = (ValueExpression) this.vars.get(variable);
+ }
+ if (ve == null) {
+ return this.mapper.resolveVariable(variable);
+ }
+ return ve;
+ } catch (StackOverflowError e) {
+ throw new ELException("Could not Resolve Variable [Overflow]: " + variable,
e);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.el.VariableMapper#setVariable(java.lang.String, javax.el.ValueExpression)
+ */
+ @Override
+ public ValueExpression setVariable(String variable,
+ ValueExpression expression) {
+
+ if (this.vars == null) {
+ this.vars = new HashMap<String, ValueExpression>();
+ }
+ return (ValueExpression) this.vars.put(variable, expression);
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/AjaxListenerTag.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -33,7 +33,6 @@
import org.ajax4jsf.event.AjaxListener;
import org.ajax4jsf.event.AjaxListenerHelper;
import org.ajax4jsf.event.AjaxSource;
-import org.richfaces.webapp.taglib.ValueBindingValueExpressionAdaptor;
/**
@@ -91,7 +90,7 @@
if (component instanceof AjaxSource) {
AjaxListener listener;
if(null != binding){
- listener = new AjaxListenerHelper(new
ValueBindingValueExpressionAdaptor(binding));
+ listener = new AjaxListenerHelper(binding);
} else {
try {
String className = (String)
type.getValue(FacesContext.getCurrentInstance().getELContext());
Modified:
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java
===================================================================
---
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/java/org/ajax4jsf/taglib/html/jsp/ServletResponseWrapperInclude.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,24 +1,3 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
Modified:
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended.xcss
===================================================================
---
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended.xcss 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended.xcss 2009-07-10
11:13:58 UTC (rev 14876)
@@ -113,11 +113,11 @@
</u:style>
</u:selector>
- <u:selector name="*|textarea[disabled]">
+ <u:selector name="*|textarea[disabled], *|select[disabled]">
<u:style name="color" skin="panelBorderColor" />
</u:selector>
- <u:selector name="textarea[type="textarea"][disabled],
input[type="text"][disabled],
input[type="password"][disabled]">
+ <u:selector name="textarea[type="textarea"][disabled],
input[type="text"][disabled],
input[type="password"][disabled], select[disabled]">
<u:style name="color" skin="panelBorderColor" />
</u:selector>
Modified:
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended_classes.xcss
===================================================================
---
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended_classes.xcss 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/resources/org/richfaces/renderkit/html/css/extended_classes.xcss 2009-07-10
11:13:58 UTC (rev 14876)
@@ -57,7 +57,7 @@
.rich-container button[type="submit"], .rich-button-submit,
.rich-container input[type="reset"], .rich-input-reset,
.rich-container input[type="submit"], .rich-input-submit,
- .rich-container input[type="button"], .rich-input-button,
+ .rich-container input[type="button"], .rich-input-button
">
<u:style name="border-color" skin="panelBorderColor" />
<u:style name="font-size" skin="generalSizeFont" />
@@ -146,13 +146,14 @@
</u:style>
</u:selector>
- <u:selector name=".rich-container *|textarea[disabled]">
+ <u:selector name=".rich-container *|textarea[disabled], .rich-container
*|select[disabled]">
<u:style name="color" skin="panelBorderColor" />
</u:selector>
-
- <u:selector name=".rich-textarea-disabled, .rich-container
textarea[type="textarea"][disabled], .rich-textarea-textarea-disabled,
+
+ <u:selector name=".rich-textarea-disabled, .rich-container
textarea[type="textarea"][disabled], .rich-textarea-textarea-disabled,
.rich-container input[type="text"][disabled],
.rich-input-text-disabled,
- .rich-container input[type="password"][disabled],
.rich-input-password-disabled">
+ .rich-container input[type="password"][disabled],
.rich-input-password-disabled,
+ .rich-container select[disabled], .rich-select-disabled">
<u:style name="color" skin="panelBorderColor" />
</u:selector>
</f:template>
\ No newline at end of file
Modified:
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/button.jspx
===================================================================
---
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/button.jspx 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/button.jspx 2009-07-10
11:13:58 UTC (rev 14876)
@@ -47,4 +47,4 @@
<jsp:scriptlet>encodeTypeAndImage(context,component);</jsp:scriptlet>
</input>
-</f:root>
\ No newline at end of file
+</f:root>
Modified:
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/function.jspx
===================================================================
---
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/function.jspx 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/function.jspx 2009-07-10
11:13:58 UTC (rev 14876)
@@ -21,4 +21,4 @@
#{this:getFunction(context,component)};
//]]>
</script>
-</f:root>
\ No newline at end of file
+</f:root>
Modified:
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/link.jspx
===================================================================
---
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/link.jspx 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/link.jspx 2009-07-10
11:13:58 UTC (rev 14876)
@@ -18,7 +18,7 @@
type="#{component.attributes['type']}"
x:passThruWithExclusions="value,name,onclick,type,href,id"
onclick="#{this:getOnClick(context,component)}"
- href="#"
+ href="#"
class="#{component.attributes['styleClass']}"
#{this:getValue(component)}
@@ -27,4 +27,4 @@
</vcp:body>
</a>
-</f:root>
\ No newline at end of file
+</f:root>
Modified: branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx
===================================================================
---
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/main/templates/org/ajax4jsf/renderkit/html/log.jspx 2009-07-10
11:13:58 UTC (rev 14876)
@@ -24,10 +24,10 @@
x:style='width:#{component.width};height:#{component.height};overflow:auto;#{component.attributes["style"]}'
x:passThruWithExclusions="value,name,id,style"
- <button
onclick="LOG.clear()">Clear</button><br />
- <script type="text/javascript">
- LOG.LEVEL = LOG.#{component.level};
+ <button onclick="LOG.clear()">Clear</button><br />
+ <script type="text/javascript">
+ LOG.LEVEL = LOG.#{component.level};
</script>
</div>
<jsp:scriptlet> } </jsp:scriptlet>
-</f:root>
\ No newline at end of file
+</f:root>
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java
(from rev 14238,
trunk/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java)
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AbstractQueueComponentTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,595 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.ajax4jsf.component;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlOutputText;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.UserResourceRenderer2;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.mozilla.javascript.FunctionObject;
+import org.mozilla.javascript.NativeArray;
+import org.mozilla.javascript.NativeObject;
+import org.mozilla.javascript.ScriptableObject;
+import org.mozilla.javascript.Undefined;
+
+import com.gargoylesoftware.htmlunit.AlertHandler;
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.ScriptPreProcessor;
+import com.gargoylesoftware.htmlunit.ScriptResult;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine;
+import com.sun.facelets.Facelet;
+import com.sun.facelets.FaceletFactory;
+import com.sun.facelets.compiler.Compiler;
+import com.sun.facelets.compiler.SAXCompiler;
+import com.sun.facelets.impl.DefaultFaceletFactory;
+import com.sun.facelets.impl.ResourceResolver;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public abstract class AbstractQueueComponentTest extends AbstractAjax4JsfTestCase {
+
+ private static final String COMPONENT_TYPE =
AjaxSubmitFunctionComponent.class.getName();
+
+ private static final String AJAX_SUBMIT = "ajaxSubmit";
+
+ public static final int DEFAULT_REQUEST_TIME = 1000;
+
+ protected HtmlPage page;
+
+ public final static class AjaxSubmitFunctionComponent extends UIComponentBase {
+
+ @Override
+ public String getRendererType() {
+ return COMPONENT_TYPE;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_TYPE;
+ }
+
+ }
+
+ private final static class AjaxSubmitFunctionResourceRenderer extends
+ Renderer implements UserResourceRenderer2 {
+
+ public void encodeToHead(FacesContext facesContext, UIComponent component)
+ throws IOException {
+ JSFunction ajaxFunction = AjaxRendererUtils.buildAjaxFunction(component,
facesContext);
+ Map<String, Object> options = AjaxRendererUtils.buildEventOptions(facesContext,
component, true);
+ options.put("requestDelay", new
JSReference("options.requestDelay"));
+ options.put("similarityGroupingId", new
JSReference("options.similarityGroupingId || '" +
+ component.getClientId(facesContext) + "'"));
+ options.put("data", new JSReference("data"));
+ options.put("requestTime", new
JSReference("options.requestTime"));
+ options.put("timeout", new JSReference("options.timeout"));
+ options.put("eventsQueue", new
JSReference("options.eventsQueue"));
+ options.put("implicitEventsQueue", new
JSReference("options.implicitEventsQueue"));
+ options.put("ignoreDupResponses", new
JSReference("options.ignoreDupResponses"));
+
+ ajaxFunction.addParameter(options);
+
+ ResponseWriter responseWriter = facesContext.getResponseWriter();
+ responseWriter.startElement(HTML.SCRIPT_ELEM, component);
+ responseWriter.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ responseWriter.writeText("var " + AJAX_SUBMIT + " = function(data,
options) {" + ajaxFunction.toScript() + "};", null);
+ responseWriter.endElement(HTML.SCRIPT_ELEM);
+ }
+
+ }
+
+ public AbstractQueueComponentTest(String name) {
+ super(name);
+ }
+
+ private static final String SIMULATION_SCRIPT_NAME =
"org/ajax4jsf/component/simulation.js";
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+ try {
+ resourceBuilder.getResource(SIMULATION_SCRIPT_NAME);
+ } catch (ResourceNotFoundException e) {
+ resourceBuilder.createResource(null, SIMULATION_SCRIPT_NAME);
+ }
+
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ UIResource resource;
+
+ UIComponent form = application.createComponent(UIForm.COMPONENT_TYPE);
+ viewRoot.getChildren().add(form);
+ final UIComponent commandButton =
application.createComponent(UIAjaxCommandButton.COMPONENT_TYPE);
+ form.getChildren().add(commandButton);
+
+ facesContext.getRenderKit().addRenderer(COMPONENT_TYPE, COMPONENT_TYPE, new
AjaxSubmitFunctionResourceRenderer());
+ form.getChildren().add(new AjaxSubmitFunctionComponent());
+
+ resource = (UIResource)
application.createComponent("org.ajax4jsf.LoadScript");
+ resource.setSrc("resource:///" + SIMULATION_SCRIPT_NAME);
+ viewRoot.getChildren().add(resource);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ this.page = null;
+ super.tearDown();
+ }
+
+ protected static final class ParametersBuilder {
+ private Map<String, Object> parameters;
+
+ private ParametersBuilder() {
+ this.parameters = new HashMap<String, Object>();
+ }
+
+ private ParametersBuilder(Map<String, Object> parameters) {
+ this.parameters = new HashMap<String, Object>(parameters);
+ }
+
+ private ParametersBuilder put(String key, Object value) {
+ this.parameters.put(key, value);
+ return this;
+ }
+
+ protected Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ /**
+ * Sets value of requestDelay parameter
+ * @param value
+ * @return
+ */
+ public ParametersBuilder requestDelay(double value) {
+ return new ParametersBuilder(this.parameters).put("requestDelay", value);
+ }
+
+ /**
+ * Sets value of similarityGroupingId parameter
+ * @param id
+ * @return
+ */
+ public ParametersBuilder similarityGroupingId(Object id) {
+ return new ParametersBuilder(this.parameters).put("similarityGroupingId",
id);
+ }
+
+ /**
+ * Defines how long this request will be executed on server
+ * @param value
+ * @return
+ */
+ public ParametersBuilder requestTime(double value) {
+ return new ParametersBuilder(this.parameters).put("requestTime", value);
+ }
+
+ /**
+ * Sets value of timeout parameter
+ * @param value
+ * @return
+ */
+ public ParametersBuilder timeout(double value) {
+ return new ParametersBuilder(this.parameters).put("timeout", value);
+ }
+
+ /**
+ * Sets value of eventsQueue parameter
+ * @param name
+ * @return
+ */
+ public ParametersBuilder eventsQueue(String name) {
+ return new ParametersBuilder(this.parameters).put("eventsQueue", name);
+ }
+
+ /**
+ * Sets value of implicitEventsQueue parameter
+ * @param name
+ * @return
+ */
+ public ParametersBuilder implicitEventsQueue(String name) {
+ return new ParametersBuilder(this.parameters).put("implicitEventsQueue",
name);
+ }
+
+ /**
+ * Sets value of ignoreDupResponses parameter
+ * @param value
+ * @return
+ */
+ public ParametersBuilder ignoreDupResponses(boolean value) {
+ return new ParametersBuilder(this.parameters).put("ignoreDupResponses",
value);
+ }
+ }
+
+ protected ParametersBuilder createAjaxParameters() {
+ return new ParametersBuilder();
+ }
+
+ protected static final class TestsResult {
+ private List<RequestData> dataList = new ArrayList<RequestData>();
+
+ private double currentTime;
+
+ public void addData(RequestData data) {
+ this.dataList.add(data);
+ }
+
+ public List<RequestData> getDataList() {
+ return dataList;
+ }
+
+ public void setCurrentTime(double number) {
+ this.currentTime = number;
+ }
+
+ public double getCurrentTime() {
+ return currentTime;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("[\n");
+ for (RequestData data : dataList) {
+ builder.append(" ");
+ builder.append(data);
+ builder.append("\n");
+ }
+ builder.append("]\n");
+ builder.append("Current time: " + this.currentTime);
+
+ return builder.toString();
+ }
+ }
+
+ protected static final class RequestData {
+ private boolean aborted;
+
+ private double startTime;
+
+ private double endTime;
+
+ private String data;
+
+ public RequestData(String data, double startTime, double endTime,
+ boolean aborted) {
+ super();
+ this.data = data;
+ this.startTime = startTime;
+ this.endTime = endTime;
+ this.aborted = aborted;
+ }
+
+ public boolean isAborted() {
+ return aborted;
+ }
+
+ public double getStartTime() {
+ return startTime;
+ }
+
+ public double getEndTime() {
+ return endTime;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+
+ builder.append("data: ");
+ builder.append(data);
+ builder.append(", ");
+
+ builder.append("startTime: ");
+ builder.append(startTime);
+ builder.append(", ");
+
+ builder.append("endTime: ");
+ builder.append(endTime);
+
+ if (isAborted()) {
+ builder.append(", aborted: ");
+ builder.append(true);
+ }
+
+ return builder.toString();
+ }
+ };
+
+ protected void checkRequestData(RequestData requestData, String data,
+ double startTime, double endTime, boolean aborted) {
+
+ assertEquals("Data check failed for " + requestData, data,
requestData.getData());
+ assertEquals("Start time check failed for " + requestData, startTime,
requestData.getStartTime());
+ assertEquals("End time check failed for " + requestData, endTime,
requestData.getEndTime());
+ assertEquals("Aborted check failed for " + requestData, aborted,
requestData.isAborted());
+
+ }
+
+ /**
+ * Execute simulated ajax request starting on given time and having data and paramaters
passed as arguments.
+ * For simulated requests defaut value of data is id of the element firing request and
default request time
+ * is 1000
+ *
+ * @param time
+ * @param data
+ * @param builder
+ */
+ protected void ajax(int time, String data, ParametersBuilder builder) {
+ JSFunction function = new JSFunction("simulationContext.ajax", time, data,
builder.getParameters());
+ page.executeJavaScript(function.toScript());
+ }
+
+ protected void executeOnTime(int time, String expression) {
+ JSFunction function = new JSFunction("simulationContext.executeOnTime",
+ time, new JSFunctionDefinition().addToBody(expression));
+
+ page.executeJavaScript(function.toScript());
+ }
+
+ private String buildClickExpression(String id) {
+ return "document.getElementById('" + id + "').click()";
+ }
+
+ protected void clickOnTime(int time, String id) {
+ JSFunction function = new JSFunction("simulationContext.executeOnTime",
+ time, new JSFunctionDefinition().addToBody(buildClickExpression(id)));
+
+ page.executeJavaScript(function.toScript());
+ }
+
+ protected String getRootContextPath() {
+ return this.getClass().getPackage().getName().replace('.', '/');
+ }
+
+ protected ResourceResolver createResourceResolver() {
+ return new ResourceResolver() {
+
+ public URL resolveUrl(String path) {
+ return
Thread.currentThread().getContextClassLoader().getResource(getRootContextPath() + path);
+ }
+
+ };
+ }
+
+ private static final Compiler compiler = new SAXCompiler();
+
+ protected void buildView(String viewId) throws IOException {
+ FaceletFactory factory = new DefaultFaceletFactory(compiler,
createResourceResolver());
+ FaceletFactory.setInstance(factory);
+
+ FaceletFactory f = FaceletFactory.getInstance();
+ Facelet at = f.getFacelet(viewId);
+
+ UIViewRoot root = facesContext.getViewRoot();
+ root.setViewId(viewId);
+ at.apply(facesContext, root);
+ }
+
+ protected void preRenderView() throws Exception {
+ StringBuilder builder = new StringBuilder("<script
type='text/javascript'>");
+ builder.append("DEFAULT_REQUEST_TIME = " + DEFAULT_REQUEST_TIME +
";");
+ builder.append("window.simulationContext = new SimulationContext(");
+ builder.append(AJAX_SUBMIT);
+ builder.append(");</script>");
+
+ HtmlOutputText text = new HtmlOutputText();
+ text.setEscape(false);
+ text.setValue(builder.toString());
+
+ List<UIComponent> childList = facesContext.getViewRoot().getChildren();
+ childList.add(childList.size(), text);
+ }
+
+ protected void postRenderView() throws Exception {
+ ScriptableObject scriptableObject = (ScriptableObject)
this.page.executeJavaScript("window.LOG").getJavaScriptResult();
+ scriptableObject.defineProperty("out", systemOut,
ScriptableObject.READONLY);
+ }
+
+ private static final ScriptableObject systemOut = new ScriptableObject() {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -8574162538513136625L;
+
+ @Override
+ public String getClassName() {
+ return "systemOut";
+ }
+
+ @SuppressWarnings("unused")
+ public void println(String s) {
+ System.out.println(s);
+ }
+ };
+
+ static {
+ try {
+ systemOut.defineProperty("println",
+ new FunctionObject(null, systemOut.getClass().getMethod("println",
String.class), systemOut),
+ ScriptableObject.READONLY);
+ } catch (SecurityException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ } catch (NoSuchMethodException e) {
+ throw new IllegalStateException(e.getMessage(), e);
+ }
+ }
+
+ protected HtmlPage renderView(String viewId) throws Exception {
+ buildView(viewId);
+ preRenderView();
+ this.page = super.renderView();
+ postRenderView();
+
+ return this.page;
+ }
+
+ @Override
+ protected HtmlPage renderView() throws Exception {
+ preRenderView();
+ this.page = super.renderView();
+ postRenderView();
+
+ return this.page;
+ }
+
+ protected void click(String id) {
+ executeJavaScript(buildClickExpression(id));
+ }
+
+ protected Object executeJavaScript(String expression) {
+ return page.executeJavaScript(expression).getJavaScriptResult();
+ }
+
+ protected void executeTimer() {
+ page.executeJavaScript("Timer.execute();");
+ }
+
+ protected TestsResult getTestsResult() {
+ TestsResult result = new TestsResult();
+
+ executeTimer();
+ ScriptResult scriptResult =
page.executeJavaScript("window.simulationContext.results");
+ NativeArray array = (NativeArray) scriptResult.getJavaScriptResult();
+
+ for (int i = 0; i < array.getLength(); i++) {
+ NativeObject object = (NativeObject) array.get(i, array);
+
+ String data = null;
+
+ Object dataObject = object.get("data", object);
+ if (!(dataObject instanceof Undefined)) {
+ data = (String) dataObject;
+ }
+
+ Double startTime = (Double) object.get("startTime", object);
+ Double endTime = (Double) object.get("endTime", object);
+
+ Object aborted = object.get("aborted", object);
+ boolean abortedBoolean = aborted instanceof Boolean && (Boolean) aborted;
+
+ result.addData(new RequestData(data, startTime, endTime, abortedBoolean));
+ }
+
+ scriptResult = page.executeJavaScript("Timer.currentTime");
+ result.setCurrentTime((Double) scriptResult.getJavaScriptResult());
+
+ return result;
+ }
+
+ @Override
+ protected void setupWebClient() {
+ super.setupWebClient();
+ webClient.setJavaScriptEngine(new JavaScriptEngine(webClient));
+ webClient.setScriptPreProcessor(new UnescapingScriptPreprocessor());
+ webClient.setThrowExceptionOnScriptError(true);
+ webClient.setAlertHandler(new AlertHandler() {
+
+ public void handleAlert(Page page, String message) {
+ fail(message);
+ }
+ });
+ }
+}
+
+class UnescapingScriptPreprocessor implements ScriptPreProcessor {
+
+ private static final Map<String, String> ENTITIES_MAP = new HashMap<String,
String>();
+
+ static {
+ ENTITIES_MAP.put("'", "\"");
+ ENTITIES_MAP.put(""", "'");
+ ENTITIES_MAP.put("&", "&");
+ ENTITIES_MAP.put("<", "<");
+ ENTITIES_MAP.put(">", ">");
+ }
+
+ private static final Pattern ENTITIES_PATTERN;
+
+ static {
+ StringBuilder sb = new StringBuilder();
+
+ for (String entity : ENTITIES_MAP.keySet()) {
+ if (sb.length() != 0) {
+ sb.append('|');
+ }
+
+ sb.append(Pattern.quote(entity));
+ }
+
+ ENTITIES_PATTERN = Pattern.compile("(" + sb.toString() + ")");
+ }
+
+ public String preProcess(HtmlPage htmlPage, String sourceCode,
+ String sourceName, HtmlElement htmlElement) {
+
+ if (sourceName != null && !sourceName.startsWith("http:/")) {
+ Matcher m = ENTITIES_PATTERN.matcher(sourceCode);
+ StringBuffer sb = new StringBuffer();
+ while (m.find()) {
+ String entity = m.group(1);
+ m.appendReplacement(sb, ENTITIES_MAP.get(entity));
+ }
+
+ m.appendTail(sb);
+
+ return sb.toString();
+ } else {
+ return sourceCode;
+ }
+
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AjaxFormQueuesTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/AjaxFormQueuesTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AjaxFormQueuesTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/AjaxFormQueuesTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.ajax4jsf.component;
+
+
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ *
+ */
+public class AjaxFormQueuesTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public AjaxFormQueuesTest(String name) {
+ super(name);
+ }
+
+ protected void checkForm(String formName) throws Exception {
+ renderView("/queue-ajax-form.xhtml");
+ click(formName + ":link");
+ executeTimer();
+
+ Object resultObject = executeJavaScript("window.testResults." + formName);
+
+ assertTrue(formName, resultObject instanceof Boolean && (Boolean)
resultObject);
+ }
+
+ public void testViewDefault() throws Exception {
+ checkForm("viewDefault");
+ }
+
+ public void testViewNamed() throws Exception {
+ checkForm("viewNamed");
+ }
+
+ public void testFormDefault() throws Exception {
+ checkForm("formDefault");
+ }
+
+ public void testFormNamed() throws Exception {
+ checkForm("formNamed");
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/ImplicitQueuesTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/ImplicitQueuesTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/ImplicitQueuesTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/ImplicitQueuesTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,115 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+import java.util.List;
+
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ *
+ */
+public class ImplicitQueuesTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public ImplicitQueuesTest(String name) {
+ super(name);
+ }
+
+ public void testImplicitGlobalQueueEnabled() throws Exception {
+ servletContext.addInitParameter("org.richfaces.queue.global.enabled",
"true");
+
+ renderView();
+
+ ajax(0, "a", createAjaxParameters().requestTime(1000));
+ ajax(0, "b", createAjaxParameters().requestTime(1000));
+
+ TestsResult result = getTestsResult();
+ assertEquals(2000d, result.getCurrentTime());
+ }
+
+ public void testImplicitGlobalQueueDefault() throws Exception {
+ renderView();
+
+ ajax(0, "a", createAjaxParameters().requestTime(1000));
+ ajax(0, "b", createAjaxParameters().requestTime(1000));
+
+ TestsResult result = getTestsResult();
+ assertEquals(1000d, result.getCurrentTime());
+ }
+
+ public void testLegacyQueuesRequestDelay() throws Exception {
+ renderView("/queue-legacy.xhtml");
+
+ clickOnTime(0, "form:buttonDelayed");
+ clickOnTime(500, "form:buttonDelayed");
+ clickOnTime(750, "form:buttonDelayed");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(1, dataList.size());
+
+ //request time set to 5000 in .xhtml file
+ RequestData data = dataList.get(0);
+ checkRequestData(data, "form:buttonDelayed", 1750, 6750, false);
+
+ assertEquals(6750d, result.getCurrentTime());
+ }
+
+ public void testLegacyQueuesIgnoreDupResponces() throws Exception {
+ renderView("/queue-legacy.xhtml");
+
+ clickOnTime(0, "form:buttonIgnoreDupResponces");
+ clickOnTime(500, "form:buttonIgnoreDupResponces");
+
+ executeTimer();
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ //RF-5788
+ //assertEquals(3, dataList.size());
+ assertEquals(2, dataList.size());
+
+ //request time set to 5000 in .xhtml file
+ checkRequestData(dataList.get(0), "form:buttonIgnoreDupResponces", 0, 5000,
false);
+ checkRequestData(dataList.get(1), "form:buttonIgnoreDupResponces", 5000,
10000, false);
+
+ //RF-5788
+ //checkRequestData(dataList.get(2), "form:buttonIgnoreDupResponces", 750,
5750, false);
+
+ //RF-5788
+ //assertEquals(5750d, result.getCurrentTime());
+ assertEquals(10000d, result.getCurrentTime());
+
+ Double requestsCompletedCounter = (Double) executeJavaScript("counter");
+ assertEquals(1d, requestsCompletedCounter);
+
+ Double requestsCompletionTime = (Double) executeJavaScript("time");
+
+ //RF-5788
+ //assertEquals(5750d, requestsCompletionTime);
+ assertEquals(10000d, requestsCompletionTime);
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/IncludeComponentTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/IncludeComponentTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/IncludeComponentTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,86 +1,86 @@
-/**
- * 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.component;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-
-public class IncludeComponentTest extends org.ajax4jsf.tests.AbstractAjax4JsfTestCase {
- private UIInclude include = null;
- private UIForm form = null;
-
- public IncludeComponentTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- include = (UIInclude) application.createComponent(UIInclude.COMPONENT_TYPE);
- include.setId("include");
- include.setLayout(UIInclude.LAYOUT_NONE);
-
- form.getChildren().add(include);
-
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- form = null;
- include = null;
- }
-
- public void testState() throws Exception {
-
- }
-
- public void testViewId() throws Exception {
- include.setViewId(null);
- assertNull(include.getViewId());
-
- String viewId = "viewId";
- include.setViewId(viewId);
- String newViewId = include.getViewId();
- assertNotNull(newViewId);
- assertEquals(viewId, newViewId);
- }
-
- public void testLayout() throws Exception {
- include.setLayout(null);
- assertNull(include.getLayout());
-
- include.setLayout(UIInclude.LAYOUT_BLOCK);
- String newLayout = include.getLayout();
- assertNotNull(newLayout);
- assertEquals(UIInclude.LAYOUT_BLOCK, newLayout);
- }
-
- public void testAjaxRendered() throws Exception {
- assertFalse(include.isAjaxRendered());
- }
-
-}
+/**
+ * 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.component;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+public class IncludeComponentTest extends org.ajax4jsf.tests.AbstractAjax4JsfTestCase {
+ private UIInclude include = null;
+ private UIForm form = null;
+
+ public IncludeComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ include = (UIInclude) application.createComponent(UIInclude.COMPONENT_TYPE);
+ include.setId("include");
+ include.setLayout(UIInclude.LAYOUT_NONE);
+
+ form.getChildren().add(include);
+
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ form = null;
+ include = null;
+ }
+
+ public void testState() throws Exception {
+
+ }
+
+ public void testViewId() throws Exception {
+ include.setViewId(null);
+ assertNull(include.getViewId());
+
+ String viewId = "viewId";
+ include.setViewId(viewId);
+ String newViewId = include.getViewId();
+ assertNotNull(newViewId);
+ assertEquals(viewId, newViewId);
+ }
+
+ public void testLayout() throws Exception {
+ include.setLayout(null);
+ assertNull(include.getLayout());
+
+ include.setLayout(UIInclude.LAYOUT_BLOCK);
+ String newLayout = include.getLayout();
+ assertNotNull(newLayout);
+ assertEquals(UIInclude.LAYOUT_BLOCK, newLayout);
+ }
+
+ public void testAjaxRendered() throws Exception {
+ assertFalse(include.isAjaxRendered());
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadBundleComponentTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,144 +1,144 @@
-/**
- * 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.component;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class LoadBundleComponentTest extends org.ajax4jsf.tests.AbstractAjax4JsfTestCase
{
- private UIForm form;
- private UILoadBundle bundle = null;
- private static final String BUNDLE_NAME = "testBundle";
-
- public LoadBundleComponentTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- bundle = (UILoadBundle) application.createComponent(UILoadBundle.COMPONENT_TYPE);
- if (null != bundle) {
- bundle.setId("loadBundle");
- bundle.setVar(BUNDLE_NAME);
- bundle.setBasename("org.ajax4jsf.component.test_skin");
- form.getChildren().add(bundle);
- }
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- form = null;
- bundle = null;
- }
-
- public void testLoadBundle() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
- assertNotNull(loadedMap);
-
- assertEquals("non-existent key", loadedMap.get("non-existent
key"));
-
- assertEquals("#000000",
loadedMap.get("shadowBackgroundColor"));
- }
-
- public void testSize() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
- assertNotNull(loadedMap);
-
- assertEquals(0, loadedMap.size());
- }
-
- public void testContainsKey() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
- assertNotNull(loadedMap);
-
- assertTrue(loadedMap.containsKey("shadowBackgroundColor"));
-
- assertFalse(loadedMap.containsKey("non-existent key"));
- }
-
- public void testFakeFunctions() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
- assertNotNull(loadedMap);
-
- assertFalse(loadedMap.isEmpty());
-
- assertFalse(loadedMap.containsValue(null));
- assertFalse(loadedMap.containsValue("any-string"));
-
- try {
- loadedMap.put("key1", "value1");
- assertFalse("UnsupportedOperationException was not thrown", true);
- } catch (UnsupportedOperationException e) {
-
- }
-
- try {
- loadedMap.putAll(new HashMap());
- assertFalse("UnsupportedOperationException was not thrown", true);
- } catch (UnsupportedOperationException e) {
-
- }
-
- try {
- loadedMap.remove("key1");
- assertFalse("UnsupportedOperationException was not thrown", true);
- } catch (UnsupportedOperationException e) {
-
- }
-
- try {
- loadedMap.clear();
- assertFalse("UnsupportedOperationException was not thrown", true);
- } catch (UnsupportedOperationException e) {
-
- }
-
- assertNull(loadedMap.keySet());
-
- assertNull(loadedMap.values());
-
- assertNull(loadedMap.entrySet());
- }
-}
+/**
+ * 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.component;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class LoadBundleComponentTest extends org.ajax4jsf.tests.AbstractAjax4JsfTestCase
{
+ private UIForm form;
+ private UILoadBundle bundle = null;
+ private static final String BUNDLE_NAME = "testBundle";
+
+ public LoadBundleComponentTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ bundle = (UILoadBundle) application.createComponent(UILoadBundle.COMPONENT_TYPE);
+ if (null != bundle) {
+ bundle.setId("loadBundle");
+ bundle.setVar(BUNDLE_NAME);
+ bundle.setBasename("org.ajax4jsf.component.test_skin");
+ form.getChildren().add(bundle);
+ }
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ form = null;
+ bundle = null;
+ }
+
+ public void testLoadBundle() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertEquals("non-existent key", loadedMap.get("non-existent
key"));
+
+ assertEquals("#000000",
loadedMap.get("shadowBackgroundColor"));
+ }
+
+ public void testSize() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertEquals(0, loadedMap.size());
+ }
+
+ public void testContainsKey() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertTrue(loadedMap.containsKey("shadowBackgroundColor"));
+
+ assertFalse(loadedMap.containsKey("non-existent key"));
+ }
+
+ public void testFakeFunctions() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ Map loadedMap =
(Map)facesContext.getExternalContext().getRequestMap().get(BUNDLE_NAME);
+ assertNotNull(loadedMap);
+
+ assertFalse(loadedMap.isEmpty());
+
+ assertFalse(loadedMap.containsValue(null));
+ assertFalse(loadedMap.containsValue("any-string"));
+
+ try {
+ loadedMap.put("key1", "value1");
+ assertFalse("UnsupportedOperationException was not thrown", true);
+ } catch (UnsupportedOperationException e) {
+
+ }
+
+ try {
+ loadedMap.putAll(new HashMap());
+ assertFalse("UnsupportedOperationException was not thrown", true);
+ } catch (UnsupportedOperationException e) {
+
+ }
+
+ try {
+ loadedMap.remove("key1");
+ assertFalse("UnsupportedOperationException was not thrown", true);
+ } catch (UnsupportedOperationException e) {
+
+ }
+
+ try {
+ loadedMap.clear();
+ assertFalse("UnsupportedOperationException was not thrown", true);
+ } catch (UnsupportedOperationException e) {
+
+ }
+
+ assertNull(loadedMap.keySet());
+
+ assertNull(loadedMap.values());
+
+ assertNull(loadedMap.entrySet());
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadResourceComponentTest.java
(from rev 14238,
trunk/ui/core/src/test/java/org/ajax4jsf/component/LoadResourceComponentTest.java)
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadResourceComponentTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/LoadResourceComponentTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,364 @@
+/**
+ * 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.component;
+
+import static org.ajax4jsf.resource.InternetResource.RESOURCE_URI_PREFIX;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.javascript.AjaxScript;
+import org.ajax4jsf.renderkit.HeaderResourceProducer2;
+import org.ajax4jsf.renderkit.ProducerContext;
+import org.ajax4jsf.renderkit.RendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.resource.InternetResource;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.ResourceNotFoundException;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlLink;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class LoadResourceComponentTest extends AbstractAjax4JsfTestCase {
+
+ private String componentJs;
+ private String userJs;
+
+ private String componentXcss;
+ private String userXcss;
+
+ /**
+ * @param name
+ */
+ public LoadResourceComponentTest(String name) {
+ super(name);
+ }
+
+ private void registerResource(String path) {
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+
+ try {
+ resourceBuilder.getResource(path);
+ } catch (ResourceNotFoundException e) {
+ resourceBuilder.createResource(null, path);
+ }
+ }
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ renderKit.addRenderer(ResourceDependentComponent.COMPONENT_FAMILY,
+ ResourceDependentComponent.COMPONENT_TYPE, new
ResourceDependentComponentRenderer());
+
+ String resourcePackage = getClass().getPackage().getName().replace('.',
'/') + "/";
+ componentJs = resourcePackage + "component.js";
+ componentXcss = resourcePackage + "component.xcss";
+
+ userJs = resourcePackage + "user.js";
+ userXcss = resourcePackage + "user.xcss";
+
+ registerResource(componentJs);
+ registerResource(userJs);
+ registerResource(componentXcss);
+ registerResource(userXcss);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ componentJs = null;
+ userJs = null;
+
+ componentXcss = null;
+ userXcss = null;
+ }
+
+ private UIResource createLoadScriptComponent() {
+ return (UIResource) application.createComponent("org.ajax4jsf.LoadScript");
+ }
+
+ private UIResource createLoadStyleComponent() {
+ return (UIResource) application.createComponent("org.ajax4jsf.LoadStyle");
+ }
+
+ private List<HtmlScript> selectScriptsBySrc(HtmlPage page, String src) throws
Exception {
+ return Collections.checkedList(page.getByXPath("//script[@src[contains(string(.),
'" + src + "')]]"),
+ HtmlScript.class);
+ }
+
+ private List<HtmlLink> selectStylesByHhref(HtmlPage page, String src) throws
Exception {
+ return Collections.checkedList(page.getByXPath("//link[@type =
'text/css'][@rel = 'stylesheet'][@href[contains(string(.), '" +
src + "')]]"),
+ HtmlLink.class);
+ }
+
+ protected UIResource createAndAddScriptResource(Object src) {
+ UIResource scriptComponent = createLoadScriptComponent();
+ scriptComponent.setSrc(src);
+ facesContext.getViewRoot().getChildren().add(scriptComponent);
+
+ return scriptComponent;
+ }
+
+ protected UIResource createAndAddStyleResource(Object src) {
+ UIResource styleComponent = createLoadStyleComponent();
+ styleComponent.setSrc(src);
+ facesContext.getViewRoot().getChildren().add(styleComponent);
+
+ return styleComponent;
+ }
+
+ public void testRenderScript() throws Exception {
+ createAndAddScriptResource(RESOURCE_URI_PREFIX + userJs);
+ createAndAddScriptResource(RESOURCE_URI_PREFIX + componentJs).setRendered(false);
+
+ HtmlPage page = renderView();
+ List<HtmlScript> scripts;
+
+ scripts = selectScriptsBySrc(page, userJs);
+ assertEquals(1, scripts.size());
+
+ scripts = selectScriptsBySrc(page, componentJs);
+ assertEquals(0, scripts.size());
+ }
+
+ public void testRenderScriptResource() throws Exception {
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+ createAndAddScriptResource(resourceBuilder.getResourceForKey(userJs));
+ createAndAddScriptResource(resourceBuilder.getResourceForKey(componentJs)).setRendered(false);
+
+ HtmlPage page = renderView();
+ List<HtmlScript> scripts;
+
+ scripts = selectScriptsBySrc(page, userJs);
+ assertEquals(1, scripts.size());
+
+ scripts = selectScriptsBySrc(page, componentJs);
+ assertEquals(1, scripts.size());
+ }
+
+ public void testRenderStyle() throws Exception {
+ createAndAddStyleResource(RESOURCE_URI_PREFIX + userXcss);
+ createAndAddStyleResource(RESOURCE_URI_PREFIX + componentXcss).setRendered(false);
+
+ HtmlPage page = renderView();
+ List<HtmlLink> styles;
+ HtmlLink userLink;
+
+ styles = selectStylesByHhref(page, userXcss);
+ assertEquals(1, styles.size());
+ userLink = styles.get(0);
+ assertEquals("user", userLink.getClassAttribute());
+ assertEquals("", userLink.getMediaAttribute());
+
+ styles = selectStylesByHhref(page, componentXcss);
+ assertEquals(0, styles.size());
+ }
+
+ public void testRenderStyleResource() throws Exception {
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+ createAndAddStyleResource(resourceBuilder.getResourceForKey(userXcss));
+ createAndAddStyleResource(resourceBuilder.getResourceForKey(componentXcss)).setRendered(false);
+
+ UIResource styleComponent = createLoadStyleComponent();
+ styleComponent.setSrc(InternetResourceBuilder.getInstance().getResourceForKey(userXcss));
+ facesContext.getViewRoot().getChildren().add(styleComponent);
+
+ HtmlPage page = renderView();
+ List<HtmlLink> styles;
+ HtmlLink userLink;
+
+ styles = selectStylesByHhref(page, userXcss);
+ assertEquals(1, styles.size());
+ userLink = styles.get(0);
+ assertEquals("user", userLink.getClassAttribute());
+ assertEquals("", userLink.getMediaAttribute());
+
+ styles = selectStylesByHhref(page, componentXcss);
+ assertEquals(1, styles.size());
+ userLink = styles.get(0);
+ assertEquals("user", userLink.getClassAttribute());
+ assertEquals("", userLink.getMediaAttribute());
+ }
+
+ public void testRenderMedia() throws Exception {
+ createAndAddStyleResource(RESOURCE_URI_PREFIX + userXcss).
+ getAttributes().put(HTML.media_ATTRIBUTE, "screen print");
+
+ HtmlPage page = renderView();
+ List<HtmlLink> styles = selectStylesByHhref(page, userXcss);
+ assertEquals(1, styles.size());
+ HtmlLink userLink = styles.get(0);
+ assertEquals("user", userLink.getClassAttribute());
+ assertEquals("screen print", userLink.getMediaAttribute());
+ }
+
+ public void testRenderOverridenScript() throws Exception {
+ List<UIComponent> childrenList = facesContext.getViewRoot().getChildren();
+
+ UIResource userJsComponent = createLoadScriptComponent();
+ userJsComponent.setSrc(RESOURCE_URI_PREFIX + userJs);
+ childrenList.add(userJsComponent);
+
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+
+ childrenList.add(new ResourceDependentComponent(true,
+ resourceBuilder.getResourceForKey(componentJs),
+ resourceBuilder.getResourceForKey(userJs)));
+
+ UIResource componentJsComponent = createLoadScriptComponent();
+ componentJsComponent.setSrc(RESOURCE_URI_PREFIX + componentJs);
+ childrenList.add(componentJsComponent);
+
+ HtmlPage page = renderView();
+ List<HtmlScript> userScripts = selectScriptsBySrc(page, userJs);
+ assertEquals(1, userScripts.size());
+ List<HtmlScript> componentScripts = selectScriptsBySrc(page, componentJs);
+ assertEquals(1, componentScripts.size());
+ }
+
+ public void testRenderOverridenStyle() throws Exception {
+ List<UIComponent> childrenList = facesContext.getViewRoot().getChildren();
+
+ UIResource userXcssComponent = createLoadStyleComponent();
+ userXcssComponent.setSrc(RESOURCE_URI_PREFIX + userXcss);
+ childrenList.add(userXcssComponent);
+
+ InternetResourceBuilder resourceBuilder = InternetResourceBuilder.getInstance();
+
+ childrenList.add(new ResourceDependentComponent(false,
+ resourceBuilder.getResourceForKey(componentXcss),
+ resourceBuilder.getResourceForKey(userXcss)));
+
+ UIResource componentXcssComponent = createLoadStyleComponent();
+ componentXcssComponent.setSrc(RESOURCE_URI_PREFIX + componentXcss);
+ childrenList.add(componentXcssComponent);
+
+ HtmlPage page = renderView();
+ List<HtmlLink> styles = selectStylesByHhref(page, userXcss);
+ assertEquals(2, styles.size());
+ assertEquals("component", styles.get(0).getClassAttribute());
+ assertEquals("user", styles.get(1).getClassAttribute());
+
+ styles = selectStylesByHhref(page, componentXcss);
+ assertEquals(2, styles.size());
+ assertEquals("component", styles.get(0).getClassAttribute());
+ assertEquals("user", styles.get(1).getClassAttribute());
+ }
+
+ public void testRenderOverridenAjaxScript() throws Exception {
+ UIResource userComponent = createLoadScriptComponent();
+ userComponent.setSrc(RESOURCE_URI_PREFIX +
"/org/ajax4jsf/javascript/scripts/AJAX.js");
+
+ List<UIComponent> childrenList = facesContext.getViewRoot().getChildren();
+ childrenList.add(userComponent);
+
+ childrenList.add(new ResourceDependentComponent(true, new AjaxScript()));
+
+ HtmlPage page = renderView();
+ List<HtmlScript> scripts = selectScriptsBySrc(page, "AjaxScript");
+ assertEquals(1, scripts.size());
+
+ scripts = selectScriptsBySrc(page, "AJAX.js");
+ //TODO change to 0 after related issue resolution
+ assertEquals(1, scripts.size());
+ }
+}
+
+class ResourceDependentComponent extends UIComponentBase {
+
+ static String COMPONENT_TYPE =
"org.ajax4jsf.component.Test$ResourceDependentComponent";
+
+ static String COMPONENT_FAMILY = COMPONENT_TYPE;
+
+ private InternetResource[] resources;
+
+ private boolean useScripts;
+
+ public ResourceDependentComponent(boolean useScripts, InternetResource... resources) {
+ this.useScripts = useScripts;
+ this.resources = resources;
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public String getRendererType() {
+ return COMPONENT_TYPE;
+ }
+
+ public InternetResource[] getScripts() {
+ return useScripts ? resources : null;
+ }
+
+ public InternetResource[] getStyles() {
+ return useScripts ? null : resources;
+ }
+}
+
+class ResourceDependentComponentRenderer extends RendererBase implements
HeaderResourceProducer2 {
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return ResourceDependentComponent.class;
+ }
+
+ public void encodeToHead(FacesContext context, UIComponent component,
+ ProducerContext pc) throws IOException {
+
+ ResourceDependentComponent resourceDependentComponent = (ResourceDependentComponent)
component;
+
+ if (pc.isProcessScripts()) {
+ InternetResource[] scripts = resourceDependentComponent.getScripts();
+ if (scripts != null) {
+ for (InternetResource script : scripts) {
+ script.encode(context, null);
+ }
+ }
+ }
+
+ if (pc.isProcessStyles()) {
+ InternetResource[] styles = resourceDependentComponent.getStyles();
+ if (styles != null) {
+ for (InternetResource script : styles) {
+ script.encode(context, null);
+ }
+ }
+ }
+ }
+
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueDiscoveryTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueDiscoveryTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueDiscoveryTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueDiscoveryTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,210 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.mozilla.javascript.NativeArray;
+
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ *
+ */
+public class QueueDiscoveryTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public QueueDiscoveryTest(String name) {
+ super(name);
+ }
+
+ protected void assertListsEqual(List<String> list1, List<String> list2)
+ throws Exception {
+
+ assertEquals(list1 + ":" + list2, list1, list2);
+ }
+
+ protected List<String> getResults(HtmlPage page) {
+ List<String> result = new ArrayList<String>();
+
+ executeJavaScript("Timer.execute()");
+ NativeArray array = (NativeArray) executeJavaScript("window.testResult");
+ for (int i = 0; i < array.getLength(); i++) {
+ result.add((String) array.get(i, array));
+ }
+
+ return result;
+ }
+
+ public void testGlobalViewQueue() throws Exception {
+ renderView("/queue-global-view.xhtml");
+
+ List<String> list = new ArrayList<String>();
+ assertListsEqual(list, getResults(page));
+
+ list.add("button");
+ click("form:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitQueue");
+ click("form:implicitQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("alternativeQueueButton");
+ list.add("alt:alternativeQueueButton");
+ click("form:alternativeQueueButton");
+ assertListsEqual(list, getResults(page));
+
+ list.add("function");
+ executeJavaScript("ajaxFunction()");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitDelayedQueue");
+ click("form2:implicitDelayedQueue");
+ assertListsEqual(list, getResults(page));
+ }
+
+ public void testGlobalFormQueue() throws Exception {
+ renderView("/queue-global-form.xhtml");
+
+ List<String> list = new ArrayList<String>();
+ assertListsEqual(list, getResults(page));
+
+ list.add("alternativeQueueButton");
+ list.add("alt:alternativeQueueButton");
+ click("form2:alternativeQueueButton");
+ assertListsEqual(list, getResults(page));
+
+ list.add("alternativeQueueButton");
+ click("form:alternativeQueueButton");
+ assertListsEqual(list, getResults(page));
+
+ list.add("buttonFormQueue");
+ click("form:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitQueue");
+ click("form:implicitQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("alternativeQueue1Button");
+ list.add("alt1:alternativeQueue1Button");
+ click("form:alternativeQueue1Button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("buttonForm2Queue");
+ click("form2:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitDelayedQueue");
+ click("form2:implicitDelayedQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("ajaxFunction");
+ executeJavaScript("ajaxFunction()");
+ assertListsEqual(list, getResults(page));
+ }
+
+ public void testGlobalFormBoth() throws Exception {
+ renderView("/queue-global-both.xhtml");
+
+ List<String> list = new ArrayList<String>();
+ assertListsEqual(list, getResults(page));
+
+ list.add("buttonFormQueue");
+ click("form:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitDelayedQueue");
+ click("form:implicitDelayedQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("implicitQueue");
+ click("form2:implicitQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("viewQueue:viewQueueButton");
+ click("form:viewQueueButton");
+ assertListsEqual(list, getResults(page));
+
+ list.add("form2Button");
+ click("form2:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("anotherImplicitQueue");
+ click("form3:anotherImplicitQueue");
+ assertListsEqual(list, getResults(page));
+
+ list.add("form3Button");
+ click("form3:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("functionFormQueue");
+ executeJavaScript("ajaxFunction()");
+ assertListsEqual(list, getResults(page));
+ }
+
+ public void testDisabled() throws Exception {
+ renderView("/queue-disabled.xhtml");
+
+ List<String> list = new ArrayList<String>();
+ assertListsEqual(list, getResults(page));
+
+ list.add("button");
+ click("form:button");
+ assertListsEqual(list, getResults(page));
+
+ list.add("formQueueButton");
+ click("form:formQueueButton");
+ assertListsEqual(list, getResults(page));
+
+ list.add("button2");
+ list.add("form2-global:button2");
+ click("form2:button2");
+ assertListsEqual(list, getResults(page));
+
+ list.add("formQueueButton2");
+ list.add("form2-queue:formQueueButton2");
+ click("form2:formQueueButton2");
+ assertListsEqual(list, getResults(page));
+
+ list.add("global");
+ click("form3:global");
+ assertListsEqual(list, getResults(page));
+
+ list.add("globalNamed");
+ click("form3:globalNamed");
+ assertListsEqual(list, getResults(page));
+
+ list.add("globalNamedX");
+ list.add("viewNamedX:globalNamedX");
+ click("form3:globalNamedX");
+ assertListsEqual(list, getResults(page));
+ }
+
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueParallelTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueParallelTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueParallelTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueParallelTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,47 @@
+/**
+ * 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.component;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueueParallelTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public QueueParallelTest(String name) {
+ super(name);
+ }
+
+ public void testParallel() throws Exception {
+ renderView("/queue-parallel.xhtml");
+
+ clickOnTime(0, "form:asyncButton");
+ clickOnTime(0, "form:asyncButton1");
+ clickOnTime(0, "form:asyncButton2");
+
+
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,252 @@
+/**
+ * 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.component;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIViewRoot;
+
+import org.ajax4jsf.renderkit.html.scripts.QueueScriptResourceRenderer;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.jaxen.JaxenException;
+
+import com.gargoylesoftware.htmlunit.html.DomText;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueueRendererTest extends AbstractAjax4JsfTestCase {
+
+ private UIForm form;
+
+ private static final String dry(String s) {
+ return s.replace(" ", "");
+ }
+
+ /**
+ * @param name
+ */
+ public QueueRendererTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+
+ UIViewRoot root = facesContext.getViewRoot();
+ List<UIComponent> children = root.getChildren();
+
+ form = (UIForm) application.createComponent(UIForm.COMPONENT_TYPE);
+ form.setId("theform");
+ form.getChildren().add(application.createComponent(UIInput.COMPONENT_TYPE));
+ children.add(form);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ form = null;
+ }
+
+ private String getQueueScript(HtmlPage page) throws JaxenException {
+ List<?> list = page.getByXPath("//head/script[@id='" +
QueueScriptResourceRenderer.QUEUE_SCRIPT_ID + "']/text()");
+ DomText text = (DomText) list.get(0);
+ String scriptData = text.getData();
+
+ return scriptData.replaceAll("^\\Qif (typeof A4J != 'undefined') { if
(A4J.AJAX) { with (A4J.AJAX) {\\E|\\Q}}};\\E$", "");
+ }
+
+ private String[] splitScript(String s) {
+ String[] split = s.split(";");
+ for (int i = 0; i < split.length; i++) {
+ split[i] = split[i] + ";";
+ }
+
+ return split;
+ }
+
+ private String createQueueInitString(String queueName, String queueParams, String
requestParams) {
+ StringBuilder builder = new StringBuilder("if
(!EventQueue.getQueue('").append(queueName).append("')) {
EventQueue.addQueue(new EventQueue('").
+ append(queueName).append("'");
+
+ builder.append(",");
+ builder.append(String.valueOf(queueParams));
+
+ builder.append(",");
+ builder.append(String.valueOf(requestParams));
+
+ builder.append(")) };");
+
+ return builder.toString();
+ }
+
+ public void testViewQueueName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setName("test_view_queue");
+ facesContext.getViewRoot().getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+
+ assertEquals(createQueueInitString("test_view_queue", null, null),
queueScript);
+ }
+
+ public void testViewQueueDefaultName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ facesContext.getViewRoot().getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertEquals(createQueueInitString(UIQueue.GLOBAL_QUEUE_NAME, null, null),
queueScript);
+ }
+
+ public void testFormQueueName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setName("test_view_queue");
+ form.getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertEquals(createQueueInitString("theform:test_view_queue", null, null),
queueScript);
+ }
+
+ public void testFormQueueDefaultName() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ form.getChildren().add(queue);
+
+ HtmlPage page = renderView();
+ String queueScript = getQueueScript(page);
+ assertEquals(createQueueInitString("theform", null, null), queueScript);
+ }
+
+ public void testRenderQueueAttributes() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue1.setSize(10);
+ queue1.setOnsizeexceeded("sizeexceeded_handler()");
+ queue1.setSizeExceededBehavior("dropNext");
+ queue1.setOnrequestqueue("request_queue_handler()");
+ queue1.setOnrequestdequeue("request_de_queue_handler()");
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue2.setSize(-1);
+ queue2.setName("unsizedQueue");
+ form.getChildren().add(queue2);
+
+ UIQueue queue3 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue3.setName("defaultSizeQueue");
+ form.getChildren().add(queue3);
+
+ HtmlPage page = renderView();
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = splitScript(queueScript);
+ assertEquals(3, scripts.length);
+
+ assertEquals(dry(createQueueInitString("theform",
+ "{'size':10,'sizeExceededBehavior':'dropNext','onsizeexceeded':function(query,options,event){sizeexceeded_handler()},'onrequestqueue':function(query,options,event){request_queue_handler()},'onrequestdequeue':function(query,options,event){request_de_queue_handler()}}",
+ null)),
+ scripts[0]);
+
+ assertEquals(dry(createQueueInitString("theform:unsizedQueue",
"{'size':-1}", null)), scripts[1]);
+
+ assertEquals(dry(createQueueInitString("theform:defaultSizeQueue", null,
null)), scripts[2]);
+ }
+
+ public void testRenderRequestAttributes() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue1.setName("queue1");
+ queue1.setTimeout(50021);
+ queue1.setOnerror("error_queue_handler()");
+ queue1.setOnsubmit("submit_queue_handler()");
+ queue1.setIgnoreDupResponses(false);
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+
+ queue2.setName("queue2");
+ queue2.setRequestDelay(600);
+ queue2.setIgnoreDupResponses(true);
+ queue2.setOnbeforedomupdate("beforedomupdate_handler()");
+ queue2.setOncomplete("complete_handler()");
+ queue2.setStatus("mystatus");
+ form.getChildren().add(queue2);
+
+ HtmlPage page = renderView();
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = splitScript(queueScript);
+ assertEquals(2, scripts.length);
+
+ assertEquals(dry(createQueueInitString("theform:queue1", null,
+ "{'timeout':50021,'queueonsubmit':function(request){submit_queue_handler()},'queueonerror':function(request,status,message){error_queue_handler()}}")),
scripts[0]);
+ assertEquals(dry(createQueueInitString("theform:queue2", null,
+ "{'ignoreDupResponses':true,'requestDelay':600,'status':'mystatus','queueonbeforedomupdate':function(request,event,data){beforedomupdate_handler()},'queueoncomplete':function(request,event,data){complete_handler()}}")),
+ scripts[1]);
+ }
+
+ public void testInvalidSizeExceededBehavior() throws Exception {
+ UIQueue queue = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue.setSizeExceededBehavior("unknownBehavior");
+ form.getChildren().add(queue);
+
+ try {
+ renderView();
+ fail();
+ } catch (IllegalArgumentException e) {
+ //ok
+ }
+ }
+
+ public void testDuplicateQueues() throws Exception {
+ UIQueue queue1 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue1.setName("testQueue");
+ queue1.setSize(2);
+ form.getChildren().add(queue1);
+
+ UIQueue queue2 = (UIQueue) application.createComponent(UIQueue.COMPONENT_TYPE);
+ queue2.setName("testQueue");
+ queue2.setSize(5);
+ form.getChildren().add(queue2);
+
+ HtmlPage page = renderView();
+
+ String queueScript = dry(getQueueScript(page));
+ String[] scripts = splitScript(queueScript);
+ assertEquals(1, scripts.length);
+
+ assertEquals(dry(createQueueInitString("theform:testQueue",
"{'size':2}",null)), scripts[0]);
+ }
+
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java (from
rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueScriptedTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,257 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+package org.ajax4jsf.component;
+
+import java.util.List;
+
+import org.mozilla.javascript.NativeArray;
+
+/**
+ * @author Denis Morozov
+ * @author Nick Belaevski
+ */
+public class QueueScriptedTest extends AbstractQueueComponentTest {
+
+ private static final String QUEUE_NAME = "testQueue";
+
+ private static final String VIEW_NAME = "/queue-scripted.xhtml";
+
+ public QueueScriptedTest(String name) {
+ super(name);
+ }
+
+ public void testRequestDelayDefined() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().
+ eventsQueue("queueRequestDelay").requestTime(5);
+
+ ajax(0, "a", parametersBuilder);
+ ajax(25, "b", parametersBuilder);
+ ajax(50, "c", parametersBuilder.requestDelay(30));
+ ajax(90, "d", parametersBuilder.requestDelay(10));
+ ajax(95, "d", parametersBuilder.requestDelay(50));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 15, 20, false);
+ checkRequestData(dataList.get(1), "b", 40, 45, false);
+ checkRequestData(dataList.get(2), "c", 80, 85, false);
+ checkRequestData(dataList.get(3), "d", 145, 150, false);
+ }
+
+ public void testRequestDelayDefault() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder =
createAjaxParameters().eventsQueue("queueDefaults").
+ requestTime(100);
+
+ ajax(0, "a", parametersBuilder.requestDelay(100));
+ ajax(300, "b", parametersBuilder);
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(2, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 200, false);
+ checkRequestData(dataList.get(1), "b", 300, 400, false);
+ }
+
+ public void testTimeout() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().
+ eventsQueue("queueTimeout").requestDelay(0);
+
+ ajax(0, "a", parametersBuilder.requestTime(4999));
+ ajax(10000, "b",
parametersBuilder.requestTime(5001).similarityGroupingId("b"));
+ ajax(10000, "c",
parametersBuilder.requestTime(100).similarityGroupingId("c"));
+ ajax(20000, "d", parametersBuilder.requestTime(10000).timeout(10000));
+ ajax(40000, "e", parametersBuilder.requestTime(10001).timeout(10000));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(5, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 4999, false);
+ checkRequestData(dataList.get(1), "b", 10000, 15000, true);
+ checkRequestData(dataList.get(2), "c", 15000, 15100, false);
+ checkRequestData(dataList.get(3), "d", 20000, 30000, false);
+ checkRequestData(dataList.get(4), "e", 40000, 50000, true);
+
+ }
+
+ public void testIgnoreDupResponses() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().
+ eventsQueue("queueIgnoreDupResponses").requestDelay(0).requestTime(1000);
+
+ ajax(0, "a", parametersBuilder.similarityGroupingId("a"));
+ ajax(500, "b", parametersBuilder.similarityGroupingId("a"));
+ ajax(2500, "c", parametersBuilder.similarityGroupingId("a"));
+ ajax(3000, "d",
parametersBuilder.similarityGroupingId("a").ignoreDupResponses(false));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 1000, false);
+ checkRequestData(dataList.get(1), "b", 1000, 2000, false);
+
+ checkRequestData(dataList.get(2), "c", 2500, 3500, false);
+ checkRequestData(dataList.get(3), "d", 3500, 4500, false);
+
+ NativeArray array = (NativeArray)
executeJavaScript("queueIgnoreDupResponsesTest");
+ long length = array.getLength();
+ assertEquals(3, length);
+
+ assertEquals("b:2000", (String) array.get(0, array));
+ assertEquals("c:3500", (String) array.get(1, array));
+ assertEquals("d:4500", (String) array.get(2, array));
+ }
+
+ public void testIgnoreDupResponsesDefault() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().
+ eventsQueue("queueDefaults").requestTime(500);
+
+ ajax(0, "a", parametersBuilder);
+ ajax(250, "b", parametersBuilder);
+ ajax(750, "c", parametersBuilder.ignoreDupResponses(true));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(3, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 500, false);
+ checkRequestData(dataList.get(1), "b", 500, 1000, false);
+ checkRequestData(dataList.get(2), "c", 1000, 1500, false);
+ }
+
+ public void testIgnoreDupResponsesTimeout() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().
+ eventsQueue("queueTimeout").ignoreDupResponses(true).requestDelay(0).requestTime(1000);
+
+ ajax(0, "a", parametersBuilder.timeout(500));
+ ajax(100, "b", parametersBuilder);
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(2, dataList.size());
+ checkRequestData(dataList.get(0), "a", 0, 500, true);
+ checkRequestData(dataList.get(1), "b", 500, 1500, false);
+ }
+
+ public void testSimpleAjax() throws Exception {
+ renderView(VIEW_NAME);
+
+ ajax(50, "a", createAjaxParameters().requestTime(100));
+ ajax(50, "b", createAjaxParameters().requestTime(150));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(2, dataList.size());
+ checkRequestData(dataList.get(0), "a", 50, 150, false);
+ checkRequestData(dataList.get(1), "b", 50, 200, false);
+
+ assertEquals(200d, result.getCurrentTime());
+ }
+
+ public void testSimpleQueuedAjax() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder queueParameters =
createAjaxParameters().requestTime(500).eventsQueue(QUEUE_NAME);
+ ajax(50, "a", queueParameters.similarityGroupingId(0));
+ ajax(250, "b", queueParameters.similarityGroupingId(1));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(2, dataList.size());
+ checkRequestData(dataList.get(0), "a", 50, 550, false);
+ checkRequestData(dataList.get(1), "b", 550, 1050, false);
+
+ assertEquals(1050d, result.getCurrentTime());
+ }
+
+ public void testImplicitQueue() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parameters = createAjaxParameters().
+ requestDelay(100).
+ implicitEventsQueue("myqueue").
+ requestTime(10);
+
+ ajax(0, "a", parameters);
+ ajax(10, "b", parameters);
+ ajax(20, "c", parameters.requestDelay(50));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(1, dataList.size());
+
+ RequestData requestData = dataList.get(0);
+ checkRequestData(requestData, "c", 70, 80, false);
+
+ assertEquals(80d, result.getCurrentTime());
+
+ }
+
+ public void testStatusIgnoreDupResponses() throws Exception {
+ renderView(VIEW_NAME);
+
+ ParametersBuilder parameters =
createAjaxParameters().requestDelay(0).eventsQueue("queueIgnoreDupResponses");
+
+ ajax(0, "a", parameters);
+ ajax(100, "b", parameters);
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(2, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, DEFAULT_REQUEST_TIME, false);
+ checkRequestData(dataList.get(1), "b", DEFAULT_REQUEST_TIME, 2 *
DEFAULT_REQUEST_TIME, false);
+
+ NativeArray array = (NativeArray) executeJavaScript("window.statusData");
+ assertEquals(2, array.getLength());
+
+ NativeArray nestedArray = (NativeArray) array.get(0, array);
+ assertEquals(Double.valueOf(0), nestedArray.get(0, nestedArray));
+ assertEquals(Double.valueOf(DEFAULT_REQUEST_TIME), nestedArray.get(1, nestedArray));
+
+ nestedArray = (NativeArray) array.get(1, array);
+ assertEquals(Double.valueOf(DEFAULT_REQUEST_TIME), nestedArray.get(0, nestedArray));
+ assertEquals(Double.valueOf(2 * DEFAULT_REQUEST_TIME), nestedArray.get(1,
nestedArray));
+ }
+}
Copied:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSimilarityTest.java
(from rev 14238,
trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueSimilarityTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSimilarityTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSimilarityTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,161 @@
+/**
+ * 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.component;
+
+import java.util.List;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueueSimilarityTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public QueueSimilarityTest(String name) {
+ super(name);
+ }
+
+ private static final String VIEW_NAME = "/queue-similarity.xhtml";
+
+ public void testDefaultBehavior() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "form:button3");
+ clickOnTime(100, "form:button3");
+ clickOnTime(200, "form:button4");
+ clickOnTime(400, "form:button3");
+
+ clickOnTime(4000, "form:button3");
+ clickOnTime(4300, "form:button3");
+ clickOnTime(4500, "form:button3");
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "form:button3", 200, 1200, false);
+ checkRequestData(dataList.get(1), "form:button4", 1200, 2200, false);
+ checkRequestData(dataList.get(2), "form:button3", 2200, 3200, false);
+ checkRequestData(dataList.get(3), "form:button3", 5000, 6000, false);
+ }
+
+ public void testGrouping() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "form:button1");
+ clickOnTime(100, "form:button1");
+ clickOnTime(200, "form:button2");
+ clickOnTime(300, "form:button1");
+
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(1, dataList.size());
+
+ checkRequestData(dataList.get(0), "form:button1", 700, 1700, false);
+ }
+
+ public void testSizeExceededGroupingDropNext() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "dropNext:button1");
+ clickOnTime(100, "dropNext:button2");
+ clickOnTime(200, "dropNext:button1");
+ clickOnTime(300, "dropNext:button2");
+ clickOnTime(2000, "dropNext:button1");
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "dropNext:button1", 100, 1100, false);
+ checkRequestData(dataList.get(1), "dropNext:button1", 1100, 2100, false);
+ checkRequestData(dataList.get(2), "dropNext:button2", 2100, 3100, false);
+ checkRequestData(dataList.get(3), "dropNext:button1", 3100, 4100, false);
+ }
+
+ public void testSizeExceededGroupingDropNew() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "dropNew:button1");
+ clickOnTime(100, "dropNew:button2");
+ clickOnTime(200, "dropNew:button1");
+ clickOnTime(300, "dropNew:button2");
+ clickOnTime(2000, "dropNew:button1");
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(4, dataList.size());
+ checkRequestData(dataList.get(0), "dropNew:button1", 100, 1100, false);
+ checkRequestData(dataList.get(1), "dropNew:button2", 1100, 2100, false);
+ checkRequestData(dataList.get(2), "dropNew:button1", 2100, 3100, false);
+ checkRequestData(dataList.get(3), "dropNew:button1", 3100, 4100, false);
+ }
+
+ public void testSizeExceededGroupingFireNext() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "fireNext:button1");
+ clickOnTime(100, "fireNext:button2");
+ clickOnTime(200, "fireNext:button1");
+ clickOnTime(300, "fireNext:button2");
+ clickOnTime(2000, "fireNext:button1");
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(5, dataList.size());
+ checkRequestData(dataList.get(0), "fireNext:button1", 100, 1100, false);
+ checkRequestData(dataList.get(1), "fireNext:button2", 300, 1300, false);
+ checkRequestData(dataList.get(2), "fireNext:button1", 1100, 2100, false);
+ checkRequestData(dataList.get(3), "fireNext:button2", 2100, 3100, false);
+ checkRequestData(dataList.get(4), "fireNext:button1", 3100, 4100, false);
+ }
+
+ public void testSizeExceededGroupingFireNew() throws Exception {
+ renderView(VIEW_NAME);
+
+ clickOnTime(0, "fireNew:button1");
+ clickOnTime(100, "fireNew:button2");
+ clickOnTime(200, "fireNew:button1");
+ clickOnTime(300, "fireNew:button2");
+ clickOnTime(2000, "fireNew:button1");
+
+ TestsResult testsResult = getTestsResult();
+ List<RequestData> dataList = testsResult.getDataList();
+
+ assertEquals(5, dataList.size());
+ checkRequestData(dataList.get(0), "fireNew:button1", 100, 1100, false);
+ checkRequestData(dataList.get(1), "fireNew:button2", 300, 1300, false);
+
+ checkRequestData(dataList.get(2), "fireNew:button2", 1100, 2100, false);
+ checkRequestData(dataList.get(3), "fireNew:button1", 2100, 3100, false);
+ checkRequestData(dataList.get(4), "fireNew:button1", 3100, 4100, false);
+ }
+}
Copied: branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSizeTest.java
(from rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueueSizeTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSizeTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueueSizeTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,422 @@
+/**
+ * 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.component;
+
+import java.text.NumberFormat;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.UUID;
+
+import org.mozilla.javascript.NativeArray;
+import org.mozilla.javascript.ScriptableObject;
+
+
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueueSizeTest extends AbstractQueueComponentTest {
+
+ public QueueSizeTest(String name) {
+ super(name);
+ }
+
+ private static final int numberOfEvents = 250;
+
+ private static abstract interface SequenceGenerator<T> {
+ public abstract T next();
+ }
+
+ protected TestsResult simulate(int numberOfEvents,
+ SequenceGenerator<Integer> userDelayGenerator,
+ SequenceGenerator<Integer> processTimeGenerator,
+ SequenceGenerator<String> requestIdGenerator) throws Exception {
+
+ NumberFormat numberFormat = NumberFormat.getInstance();
+ numberFormat.setGroupingUsed(false);
+ numberFormat.setMinimumIntegerDigits(String.valueOf(numberOfEvents).length());
+
+ renderView("/queue-size.xhtml");
+
+ ParametersBuilder parametersBuilder =
createAjaxParameters().eventsQueue("defaultSizeQueue");
+
+ int time = 0;
+
+ for (int i = 0; i < numberOfEvents; i++) {
+ int userDelay = userDelayGenerator.next();
+ int requestTime = processTimeGenerator.next();
+
+ time += userDelay;
+ ajax(time, numberFormat.format(i),
parametersBuilder.similarityGroupingId(requestIdGenerator.next()).
+ requestTime(requestTime));
+
+ }
+
+ TestsResult result = getTestsResult();
+ return result;
+ }
+
+ protected void checkQueueOrdering(TestsResult result) throws Exception {
+ double time = 0;
+ String lastRequestId = "";
+
+ List<RequestData> dataList = result.getDataList();
+ Iterator<RequestData> itr = dataList.iterator();
+ while (itr.hasNext()) {
+ RequestData data = itr.next();
+
+ assertTrue(data.getStartTime() >= time);
+ assertTrue(data.getEndTime() >= data.getStartTime());
+ assertTrue(data.getData().compareTo(lastRequestId) > 0);
+
+ lastRequestId = data.getData();
+ time = data.getEndTime();
+ }
+ }
+
+ private static final class UUIDGenerator implements SequenceGenerator<String> {
+
+ public String next() {
+ return UUID.randomUUID().toString();
+ }
+
+ }
+
+ private static final class RandomSequenceGenerator implements
SequenceGenerator<Integer> {
+
+ private int offset;
+
+ private int limit;
+
+ public RandomSequenceGenerator(int minimum, int maximum) {
+ super();
+
+ this.limit = maximum - minimum;
+ this.offset = minimum;
+ }
+
+ private Random random = new Random();
+
+ public Integer next() {
+ return random.nextInt(this.limit) + this.offset;
+ }
+
+ }
+
+ public void testUnlimitedOverload() throws Exception {
+ TestsResult result = simulate(numberOfEvents,
+ new RandomSequenceGenerator(5, 100),
+ new RandomSequenceGenerator(50, 300),
+ new UUIDGenerator()
+ );
+
+ checkQueueOrdering(result);
+ assertEquals(numberOfEvents, result.getDataList().size());
+ }
+
+ public void testUnlimitedUnderload() throws Exception {
+ TestsResult result = simulate(numberOfEvents,
+ new RandomSequenceGenerator(50, 300),
+ new RandomSequenceGenerator(5, 100),
+ new UUIDGenerator()
+ );
+
+ checkQueueOrdering(result);
+ assertEquals(numberOfEvents, result.getDataList().size());
+ }
+
+ private static final class TableRequestIdGenerator implements
SequenceGenerator<String> {
+ private static final String[] requestIds = new String[] {
+ "aaa", "bbb", "ccc", "ddd", "eee",
"fff"
+ };
+
+ private Random random = new Random();
+
+ private String lastValue;
+
+ private int uniqueIdsCounter = 0;
+
+ public String next() {
+ String newValue = requestIds[random.nextInt(requestIds.length)];
+
+ if (!newValue.equals(lastValue)) {
+ lastValue = newValue;
+ uniqueIdsCounter++;
+ }
+
+ return newValue;
+ }
+
+ public int getUniqueIdsCounter() {
+ return uniqueIdsCounter;
+ }
+ };
+
+
+ public void testUnlimitedEmulateUser() throws Exception {
+ TableRequestIdGenerator requestIdGenerator = new TableRequestIdGenerator();
+
+ TestsResult result = simulate(numberOfEvents,
+ new RandomSequenceGenerator(5, 100),
+ new RandomSequenceGenerator(5, 100),
+ requestIdGenerator
+ );
+
+ checkQueueOrdering(result);
+ assertTrue(requestIdGenerator.getUniqueIdsCounter() <=
result.getDataList().size());
+ assertTrue(result.getDataList().size() <= numberOfEvents);
+ }
+
+ protected TestsResult checkQueue(String queueName) throws Exception {
+ renderView("/queue-size.xhtml");
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().eventsQueue(queueName).
+ requestDelay(300).requestTime(300);
+
+ ajax(0, "a", parametersBuilder.similarityGroupingId("a"));
+ ajax(100, "b", parametersBuilder.similarityGroupingId("b"));
+ ajax(200, "c", parametersBuilder.similarityGroupingId("c"));
+ ajax(300, "d", parametersBuilder.similarityGroupingId("d"));
+ ajax(500, "e", parametersBuilder.similarityGroupingId("e"));
+ ajax(600, "f", parametersBuilder.similarityGroupingId("f"));
+
+ TestsResult result = getTestsResult();
+ return result;
+ }
+
+ protected TestsResult checkSingleQueue(String queueName) throws Exception {
+ renderView("/queue-size.xhtml");
+
+ ParametersBuilder parametersBuilder = createAjaxParameters().eventsQueue(queueName).
+ requestTime(300).requestDelay(200);
+
+ ajax(0, "a", parametersBuilder.similarityGroupingId("a"));
+ ajax(100, "b", parametersBuilder.similarityGroupingId("b"));
+ ajax(400, "c", parametersBuilder.similarityGroupingId("c"));
+ ajax(500, "d", parametersBuilder.similarityGroupingId("d"));
+ ajax(700, "e", parametersBuilder.similarityGroupingId("e"));
+
+ ajax(9800, "f",
parametersBuilder.similarityGroupingId("f").requestTime(1000));
+ ajax(10100, "g",
parametersBuilder.similarityGroupingId("f").requestTime(1500));
+
+ TestsResult result = getTestsResult();
+ return result;
+ }
+
+ public void testDropNext() throws Exception {
+ TestsResult result = checkQueue("dropNextQueue");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "c", 400, 700, false);
+ checkRequestData(dataList.get(2), "e", 700, 1000, false);
+ checkRequestData(dataList.get(3), "f", 1000, 1300, false);
+ }
+
+ public void testDropNew() throws Exception {
+ TestsResult result = checkQueue("dropNewQueue");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(4, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "b", 400, 700, false);
+ checkRequestData(dataList.get(2), "c", 700, 1000, false);
+ checkRequestData(dataList.get(3), "e", 1000, 1300, false);
+ }
+
+ public void testFireNext() throws Exception {
+ TestsResult result = checkQueue("fireNextQueue");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(6, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "b", 300, 600, false);
+ checkRequestData(dataList.get(2), "c", 400, 700, false);
+ checkRequestData(dataList.get(3), "d", 600, 900, false);
+ checkRequestData(dataList.get(4), "e", 700, 1000, false);
+ checkRequestData(dataList.get(5), "f", 1000, 1300, false);
+ }
+
+ public void testFireNew() throws Exception {
+ TestsResult result = checkQueue("fireNewQueue");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(6, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "d", 300, 600, false);
+ checkRequestData(dataList.get(2), "b", 400, 700, false);
+ checkRequestData(dataList.get(3), "f", 600, 900, false);
+ checkRequestData(dataList.get(4), "c", 700, 1000, false);
+ checkRequestData(dataList.get(5), "e", 1000, 1300, false);
+ }
+
+ public void testDropNextSingle() throws Exception {
+ TestsResult result = checkSingleQueue("dropNextQueueSingle");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(3, dataList.size());
+
+ checkRequestData(dataList.get(0), "b", 300, 600, false);
+ checkRequestData(dataList.get(1), "e", 900, 1200, false);
+ checkRequestData(dataList.get(2), "f", 10000, 11000, false);
+ }
+
+ public void testDropNewSingle() throws Exception {
+ TestsResult result = checkSingleQueue("dropNewQueueSingle");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(3, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "d", 700, 1000, false);
+ checkRequestData(dataList.get(2), "f", 10000, 11000, false);
+ }
+
+ public void testFireNextSingle() throws Exception {
+ TestsResult result = checkSingleQueue("fireNextQueueSingle");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(7, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 100, 400, false);
+ checkRequestData(dataList.get(1), "b", 300, 600, false);
+ checkRequestData(dataList.get(2), "c", 400, 700, false);
+ checkRequestData(dataList.get(3), "d", 500, 800, false);
+ checkRequestData(dataList.get(4), "e", 900, 1200, false);
+
+ checkRequestData(dataList.get(5), "f", 10000, 11000, false);
+ checkRequestData(dataList.get(6), "g", 10100, 11600, false);
+ }
+
+ public void testFireNewSingle() throws Exception {
+ TestsResult result = checkSingleQueue("fireNewQueueSingle");
+ List<RequestData> dataList = result.getDataList();
+
+ for (RequestData requestData : dataList) {
+ System.out.println(" " + requestData);
+ }
+ System.out.println();
+
+ assertEquals(7, dataList.size());
+
+ checkRequestData(dataList.get(0), "b", 100, 400, false);
+ checkRequestData(dataList.get(1), "a", 100, 400, false);
+ checkRequestData(dataList.get(2), "c", 400, 700, false);
+ checkRequestData(dataList.get(3), "e", 700, 1000, false);
+ checkRequestData(dataList.get(4), "d", 700, 1000, false);
+
+ checkRequestData(dataList.get(5), "f", 10000, 11000, false);
+ checkRequestData(dataList.get(6), "g", 10100, 11600, false);
+ }
+
+ public void testOnSizeExceeded() throws Exception {
+ renderView("/queue-size.xhtml");
+
+ for (int i = 0; i <= 3; i++) {
+ clickOnTime(i, "form:button" + i);
+ }
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(2, dataList.size());
+
+ //dropNext is default
+ checkRequestData(dataList.get(0), "form:button0", 0, DEFAULT_REQUEST_TIME,
false);
+ checkRequestData(dataList.get(1), "form:button3", DEFAULT_REQUEST_TIME,
DEFAULT_REQUEST_TIME * 2, false);
+
+ NativeArray handlersData = (NativeArray)
executeJavaScript("defaultExceededQueueResults");
+ assertEquals(2, handlersData.getLength());
+
+ ScriptableObject firstHandlerData = (ScriptableObject) handlersData.get(0,
handlersData);
+ Double firstEventTime = (Double) firstHandlerData.get("_time",
firstHandlerData);
+ assertEquals(2d, firstEventTime);
+
+ ScriptableObject secondHandlerData = (ScriptableObject) handlersData.get(1,
handlersData);
+ Double secondEventTime = (Double) secondHandlerData.get("_time",
secondHandlerData);
+ assertEquals(3d, secondEventTime);
+ }
+
+ public void testSingleSizedQueueIgnoreDupResponses() throws Exception {
+ renderView("/queue-size.xhtml");
+
+ ParametersBuilder parametersBuilder =
createAjaxParameters().eventsQueue("singleSizedDefaultQueue").
+ requestDelay(0);
+
+ ajax(0, "a", parametersBuilder);
+ ajax(500, "b", parametersBuilder);
+
+ TestsResult result = getTestsResult();
+ List<RequestData> list = result.getDataList();
+ assertEquals(1, list.size());
+
+ checkRequestData(list.get(0), "a", 0, DEFAULT_REQUEST_TIME, false);
+
+ NativeArray handlersData = (NativeArray)
executeJavaScript("defaultSingleSizedQueueResults");
+ assertEquals(1, handlersData.getLength());
+
+ assertEquals("a", handlersData.get(0, handlersData));
+ }
+}
Copied: branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueuedPollTest.java
(from rev 14238, trunk/ui/core/src/test/java/org/ajax4jsf/component/QueuedPollTest.java)
===================================================================
--- branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueuedPollTest.java
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/QueuedPollTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,171 @@
+/**
+ * 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.component;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class QueuedPollTest extends AbstractQueueComponentTest {
+
+ /**
+ * @param name
+ */
+ public QueuedPollTest(String name) {
+ super(name);
+ }
+
+ private void setFlag(String name) {
+ Map<String, Object> requestMap =
facesContext.getExternalContext().getRequestMap();
+ requestMap.put(name, Boolean.TRUE);
+ }
+
+ public void testQueuedDefaultPollRequestDelay() throws Exception {
+ setFlag("queuedDefaultPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "firstForm:queuedDefaultPoll", 600, 1600,
false);
+ }
+
+ public void testQueuedPollRequestDelay() throws Exception {
+ setFlag("queuedDelayedPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "firstForm:queuedDelayedPoll", 300, 1300,
false);
+ }
+
+ public void testDelayedQueueDefaultPollRequestDelay() throws Exception {
+ setFlag("delayedQueueDefaultPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "secondForm:delayedQueueDefaultPoll", 1500,
2500, false);
+ }
+
+ public void testDelayedQueuePollRequestDelay() throws Exception {
+ setFlag("delayedQueueDelayedPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "secondForm:delayedQueueDelayedPoll", 2400,
3400, false);
+ }
+
+ public void testUnqueuedDefaultPollRequestDelay() throws Exception {
+ setFlag("unqueuedDefaultPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "thirdForm:unqueuedDefaultPoll", 700, 1700,
false);
+ }
+
+ public void testunQueuedPollRequestDelay() throws Exception {
+ setFlag("unqueuedDelayedPollEnabled");
+ renderView("/queue-poll.xhtml");
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+
+ assertEquals(1, dataList.size());
+ checkRequestData(dataList.get(0), "thirdForm:unqueuedDelayedPoll", 950, 1950,
false);
+ }
+
+ public void testDropNextDroppedPoll() throws Exception {
+ setFlag("renderDropNext");
+ renderView("/queue-poll-drop.xhtml");
+
+ ParametersBuilder parametersBuilder =
createAjaxParameters().eventsQueue("dropNextQueue").
+ requestDelay(0);
+
+ ajax(0, "a", parametersBuilder.similarityGroupingId(1).requestTime(3000));
+
+ //poll has 2000 interval, so ajax request at 2100 will make queue drop it from list
+ ajax(2500, "b", parametersBuilder.similarityGroupingId(2).requestTime(500));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(3, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 3000, false);
+ checkRequestData(dataList.get(1), "b", 3000, 3500, false);
+
+ //poll has been kicked from queue at 2500, requeued in 2000
+ checkRequestData(dataList.get(2), "firstForm:poll", 2500 + 2000, 2500 + 2000
+ 1000 /* default request time */,
+ false);
+ }
+
+ public void testDropNextDroppedPollSingle() throws Exception {
+ setFlag("renderDropNextSingle");
+ renderView("/queue-poll-drop.xhtml");
+
+ ajax(0, "a",
createAjaxParameters().requestTime(3000).requestDelay(0).eventsQueue("dropNextQueueSingle"));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(2, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 3000, false);
+ checkRequestData(dataList.get(1), "thirdForm:poll", 4000, 5000, false);
+ }
+
+ public void testDropNewDroppedPoll() throws Exception {
+ setFlag("renderDropNew");
+ renderView("/queue-poll-drop.xhtml");
+
+ ParametersBuilder parametersBuilder =
createAjaxParameters().eventsQueue("dropNewQueue").
+ requestDelay(0);
+
+ ajax(0, "a", parametersBuilder.similarityGroupingId(1).requestTime(3000));
+
+ //poll has 2500 interval, so ajax request at 2000 will make queue drop it from the
list
+ ajax(2000, "b", parametersBuilder.similarityGroupingId(2).requestTime(500));
+
+ TestsResult result = getTestsResult();
+ List<RequestData> dataList = result.getDataList();
+ assertEquals(3, dataList.size());
+
+ checkRequestData(dataList.get(0), "a", 0, 3000, false);
+ checkRequestData(dataList.get(1), "b", 3000, 3500, false);
+ checkRequestData(dataList.get(2), "secondForm:poll", 5000, 6000, false);
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/UIAjaxFormTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/UIAjaxFormTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/component/UIAjaxFormTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,3 +1,23 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
package org.ajax4jsf.component;
import java.io.Serializable;
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxFormRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxFormRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxFormRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,144 +1,144 @@
-/**
- * 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.renderkit.html;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.ajax4jsf.component.UIAjaxForm;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.commons.lang.StringUtils;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
-
-public class AjaxFormRendererTest extends AbstractAjax4JsfTestCase {
- private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
- private static Set javaScripts = new HashSet();
-
- static {
- javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
- javaScripts.add("org/ajax4jsf/javascript/scripts/form.js");
- }
-
- private UIAjaxForm form1;
- private UIAjaxForm form2;
-
- public AjaxFormRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form1 = (UIAjaxForm) application.createComponent(UIAjaxForm.COMPONENT_TYPE);
- form1.setId("form1");
- form1.setAjaxSubmit(true);
-
- form2 = (UIAjaxForm) application.createComponent(UIAjaxForm.COMPONENT_TYPE);
- form2.setId("form2");
- form2.setAjaxSubmit(false);
-
- facesContext.getViewRoot().getChildren().add(form1);
- facesContext.getViewRoot().getChildren().add(form2);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test script rendering
- *
- * @throws Exception
- */
- public void testRenderScript() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
- }
-
- /**
- * Test rendering
- *
- * @throws Exception
- */
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- HtmlElement htmlForm1 =
page.getHtmlElementById(form1.getClientId(facesContext));
- assertNotNull(htmlForm1);
- assertEquals("form", htmlForm1.getTagName());
-
- String action = htmlForm1.getAttributeValue("action");
- assertNotNull(action);
- assertTrue(action.startsWith("javascript:A4J.AJAX.SubmitForm"));
-
- HtmlElement htmlForm2 =
page.getHtmlElementById(form2.getClientId(facesContext));
- assertNotNull(htmlForm2);
- assertEquals("form", htmlForm2.getTagName());
-
- action = htmlForm2.getAttributeValue("action");
- assertNotNull(action);
- assertTrue(action.startsWith("/"));
- }
-
- /**
- * Test rendering hidden inputs
- *
- * @throws Exception
- */
- public void testRenderHiddenInputs() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- HtmlElement htmlForm1 =
page.getHtmlElementById(form1.getClientId(facesContext));
- List inputs = htmlForm1.getHtmlElementsByTagName("input");
- assertNotNull(inputs);
- boolean foundId = false;
- boolean foundAutoscroll = false;
- for (Iterator it = inputs.iterator(); it.hasNext();) {
- HtmlElement input = (HtmlElement) it.next();
- String name = input.getAttributeValue("name");
- assertNotNull(name);
- if (!foundId && name.equals(form1.getClientId(facesContext))) {
- foundId = true;
- }
- if (!foundAutoscroll && name.equals("autoScroll")) {
- foundAutoscroll = true;
- }
- }
- assertTrue(foundId);
- assertTrue(foundAutoscroll);
-
- HtmlElement htmlForm2 =
page.getHtmlElementById(form2.getClientId(facesContext));
- assertNotNull(htmlForm2);
- assertEquals("form", htmlForm2.getTagName());
-
- }
-}
+/**
+ * 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.renderkit.html;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.ajax4jsf.component.UIAjaxForm;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+public class AjaxFormRendererTest extends AbstractAjax4JsfTestCase {
+ private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
+ private static Set javaScripts = new HashSet();
+
+ static {
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ javaScripts.add("org/ajax4jsf/javascript/scripts/form.js");
+ }
+
+ private UIAjaxForm form1;
+ private UIAjaxForm form2;
+
+ public AjaxFormRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form1 = (UIAjaxForm) application.createComponent(UIAjaxForm.COMPONENT_TYPE);
+ form1.setId("form1");
+ form1.setAjaxSubmit(true);
+
+ form2 = (UIAjaxForm) application.createComponent(UIAjaxForm.COMPONENT_TYPE);
+ form2.setId("form2");
+ form2.setAjaxSubmit(false);
+
+ facesContext.getViewRoot().getChildren().add(form1);
+ facesContext.getViewRoot().getChildren().add(form2);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test script rendering
+ *
+ * @throws Exception
+ */
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
+ }
+
+ /**
+ * Test rendering
+ *
+ * @throws Exception
+ */
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlElement htmlForm1 =
page.getHtmlElementById(form1.getClientId(facesContext));
+ assertNotNull(htmlForm1);
+ assertEquals("form", htmlForm1.getTagName());
+
+ String action = htmlForm1.getAttributeValue("action");
+ assertNotNull(action);
+ assertTrue(action.startsWith("javascript:A4J.AJAX.SubmitForm"));
+
+ HtmlElement htmlForm2 =
page.getHtmlElementById(form2.getClientId(facesContext));
+ assertNotNull(htmlForm2);
+ assertEquals("form", htmlForm2.getTagName());
+
+ action = htmlForm2.getAttributeValue("action");
+ assertNotNull(action);
+ assertTrue(action.startsWith("/"));
+ }
+
+ /**
+ * Test rendering hidden inputs
+ *
+ * @throws Exception
+ */
+ public void testRenderHiddenInputs() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlElement htmlForm1 =
page.getHtmlElementById(form1.getClientId(facesContext));
+ List inputs = htmlForm1.getHtmlElementsByTagName("input");
+ assertNotNull(inputs);
+ boolean foundId = false;
+ boolean foundAutoscroll = false;
+ for (Iterator it = inputs.iterator(); it.hasNext();) {
+ HtmlElement input = (HtmlElement) it.next();
+ String name = input.getAttributeValue("name");
+ assertNotNull(name);
+ if (!foundId && name.equals(form1.getClientId(facesContext))) {
+ foundId = true;
+ }
+ if (!foundAutoscroll && name.equals("autoScroll")) {
+ foundAutoscroll = true;
+ }
+ }
+ assertTrue(foundId);
+ assertTrue(foundAutoscroll);
+
+ HtmlElement htmlForm2 =
page.getHtmlElementById(form2.getClientId(facesContext));
+ assertNotNull(htmlForm2);
+ assertEquals("form", htmlForm2.getTagName());
+
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxIncludeRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxIncludeRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxIncludeRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,103 +1,103 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.UIOutput;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.component.UIInclude;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import com.gargoylesoftware.htmlunit.ElementNotFoundException;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class AjaxIncludeRendererTest extends AbstractAjax4JsfTestCase {
- private UIInclude include1 = null;
- private UIInclude include2 = null;
- private UIInclude include3 = null;
- private UIForm form;
-
- public AjaxIncludeRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- include1 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
- include1.setId("include1");
- include1.setLayout(UIInclude.LAYOUT_NONE);
-
- UIOutput output = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
- output.setRendered(true);
- output.setId("output");
- output.setValue("output");
- include1.getChildren().add(output);
-
- include2 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
- include2.setId("include2");
- include2.setLayout(UIInclude.LAYOUT_BLOCK);
-
- include3 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
- include3.setId("include3");
- include3.setLayout(UIInclude.LAYOUT_INLINE);
-
- form.getChildren().add(include1);
- form.getChildren().add(include2);
- form.getChildren().add(include3);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- include1 = null;
- include2 = null;
- include3 = null;
- }
-
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- try {
- HtmlElement empty =
page.getHtmlElementById(include1.getClientId(facesContext));
- assertFalse("ElementNotFoundException was not thrown", true);
- } catch (ElementNotFoundException e) {
-
- }
-
- HtmlElement div = page.getHtmlElementById(include2.getClientId(facesContext));
- assertNotNull(div);
- assertEquals("div", div.getNodeName());
-
- HtmlElement span = page.getHtmlElementById(include3.getClientId(facesContext));
- assertNotNull(span);
- assertEquals("span", span.getNodeName());
- }
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.component.UIInclude;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class AjaxIncludeRendererTest extends AbstractAjax4JsfTestCase {
+ private UIInclude include1 = null;
+ private UIInclude include2 = null;
+ private UIInclude include3 = null;
+ private UIForm form;
+
+ public AjaxIncludeRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ include1 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
+ include1.setId("include1");
+ include1.setLayout(UIInclude.LAYOUT_NONE);
+
+ UIOutput output = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ output.setRendered(true);
+ output.setId("output");
+ output.setValue("output");
+ include1.getChildren().add(output);
+
+ include2 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
+ include2.setId("include2");
+ include2.setLayout(UIInclude.LAYOUT_BLOCK);
+
+ include3 = (UIInclude)application.createComponent(UIInclude.COMPONENT_TYPE);
+ include3.setId("include3");
+ include3.setLayout(UIInclude.LAYOUT_INLINE);
+
+ form.getChildren().add(include1);
+ form.getChildren().add(include2);
+ form.getChildren().add(include3);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ include1 = null;
+ include2 = null;
+ include3 = null;
+ }
+
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ try {
+ HtmlElement empty =
page.getHtmlElementById(include1.getClientId(facesContext));
+ assertFalse("ElementNotFoundException was not thrown", true);
+ } catch (ElementNotFoundException e) {
+
+ }
+
+ HtmlElement div = page.getHtmlElementById(include2.getClientId(facesContext));
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
+
+ HtmlElement span = page.getHtmlElementById(include3.getClientId(facesContext));
+ assertNotNull(span);
+ assertEquals("span", span.getNodeName());
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxOutputPanelRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,119 +1,119 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.UIOutput;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.component.UIAjaxOutputPanel;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import com.gargoylesoftware.htmlunit.ElementNotFoundException;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class AjaxOutputPanelRendererTest extends AbstractAjax4JsfTestCase {
- private UIForm form = null;
- private UIAjaxOutputPanel panel1 = null;
- private UIAjaxOutputPanel panel2 = null;
- private UIAjaxOutputPanel panel3 = null;
- private UIAjaxOutputPanel panel4 = null;
- private UIOutput output = null;
-
- public AjaxOutputPanelRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- panel1 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
- panel1.setId("panel1");
- panel1.setLayout("none");
- form.getChildren().add(panel1);
-
- panel2 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
- panel2.setId("panel2");
- panel2.setLayout("block");
- form.getChildren().add(panel2);
-
- panel3 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
- panel3.setId("panel3");
- panel3.setLayout("inline");
- form.getChildren().add(panel3);
-
- panel4 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
- panel4.setId("panel4");
- panel4.setLayout("none");
-
- output = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
- output.setId("output");
- output.setValue("output");
- output.setTransient(true);
- panel4.getChildren().add(output);
-
- form.getChildren().add(panel4);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- output = null;
- panel1 = null;
- panel2 = null;
- panel3 = null;
- form = null;
- }
-
- public void testRender() throws Exception{
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- try {
- HtmlElement empty = page.getHtmlElementById(panel1.getClientId(facesContext));
- assertFalse("ElementNotFoundException was not thrown", true);
- } catch (ElementNotFoundException e) {
-
- }
-
- HtmlElement div = page.getHtmlElementById(panel2.getClientId(facesContext));
- assertNotNull(div);
- assertEquals("div", div.getNodeName());
-
- HtmlElement span = page.getHtmlElementById(panel3.getClientId(facesContext));
- assertNotNull(span);
- assertEquals("span", span.getNodeName());
-
- span = page.getHtmlElementById(output.getClientId(facesContext));
- assertNotNull(span);
- assertEquals("span", span.getNodeName());
-
- assertFalse(output.isTransient());
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.component.UIAjaxOutputPanel;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.ElementNotFoundException;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class AjaxOutputPanelRendererTest extends AbstractAjax4JsfTestCase {
+ private UIForm form = null;
+ private UIAjaxOutputPanel panel1 = null;
+ private UIAjaxOutputPanel panel2 = null;
+ private UIAjaxOutputPanel panel3 = null;
+ private UIAjaxOutputPanel panel4 = null;
+ private UIOutput output = null;
+
+ public AjaxOutputPanelRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ panel1 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
+ panel1.setId("panel1");
+ panel1.setLayout("none");
+ form.getChildren().add(panel1);
+
+ panel2 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
+ panel2.setId("panel2");
+ panel2.setLayout("block");
+ form.getChildren().add(panel2);
+
+ panel3 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
+ panel3.setId("panel3");
+ panel3.setLayout("inline");
+ form.getChildren().add(panel3);
+
+ panel4 =
(UIAjaxOutputPanel)application.createComponent(UIAjaxOutputPanel.COMPONENT_TYPE);
+ panel4.setId("panel4");
+ panel4.setLayout("none");
+
+ output = (UIOutput) application.createComponent(UIOutput.COMPONENT_TYPE);
+ output.setId("output");
+ output.setValue("output");
+ output.setTransient(true);
+ panel4.getChildren().add(output);
+
+ form.getChildren().add(panel4);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ output = null;
+ panel1 = null;
+ panel2 = null;
+ panel3 = null;
+ form = null;
+ }
+
+ public void testRender() throws Exception{
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ try {
+ HtmlElement empty = page.getHtmlElementById(panel1.getClientId(facesContext));
+ assertFalse("ElementNotFoundException was not thrown", true);
+ } catch (ElementNotFoundException e) {
+
+ }
+
+ HtmlElement div = page.getHtmlElementById(panel2.getClientId(facesContext));
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
+
+ HtmlElement span = page.getHtmlElementById(panel3.getClientId(facesContext));
+ assertNotNull(span);
+ assertEquals("span", span.getNodeName());
+
+ span = page.getHtmlElementById(output.getClientId(facesContext));
+ assertNotNull(span);
+ assertEquals("span", span.getNodeName());
+
+ assertFalse(output.isTransient());
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPageRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPageRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPageRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,114 +1,127 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-
-import javax.faces.component.UIOutput;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.commons.lang.StringUtils;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
-
-public class AjaxPageRendererTest extends AbstractAjax4JsfTestCase{
-
- private org.ajax4jsf.component.html.HtmlPage ajaxPage = null;
- private static Set<String> javaScripts = new HashSet<String>();
-
- static {
- javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
- }
-
- private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
-
- public AjaxPageRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- ajaxPage = (org.ajax4jsf.component.html.HtmlPage)
application.createComponent(org.ajax4jsf.component.html.HtmlPage.COMPONENT_TYPE);
- ajaxPage.setId("page");
-
- UIOutput head = new UIOutput();
- head.setValue("HEAD");
- ajaxPage.getFacets().put("head", head);
-
- UIOutput content = new UIOutput();
- content.setValue("content");
- ajaxPage.getChildren().add(content);
-
- ajaxPage.setFormat("xhtml");
- ajaxPage.setPageTitle("title");
-
- facesContext.getViewRoot().setLocale(new Locale("be", "BY"));
-
- facesContext.getViewRoot().getChildren().add(ajaxPage);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement html = (HtmlElement)page.getFirstChild();
- assertNotNull(html);
- assertEquals("html", html.getTagName());
-
- String lang = html.getAttributeValue("lang");
- assertNotNull(lang);
- assertEquals(lang, "be_BY");
-
- HtmlElement title = (HtmlElement)
html.getHtmlElementsByTagName("title").get(0);
- assertNotNull(title);
-
- assertEquals("title", title.getFirstChild().asText());
-
- HtmlElement meta = (HtmlElement)
html.getHtmlElementsByTagName("meta").get(0);
-
- assertNotNull(meta);
- String httpEquiv = meta.getAttributeValue("http-equiv");
- assertEquals(httpEquiv, "Content-Type");
-
- String content = meta.getAttributeValue("content");
- assertEquals(content, "application/xhtml+xml");
- }
-
- public void testRenderScript() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+import javax.faces.component.UIOutput;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class AjaxPageRendererTest extends AbstractAjax4JsfTestCase{
+
+ private org.ajax4jsf.component.html.HtmlPage ajaxPage = null;
+ private static Set<String> javaScripts = new HashSet<String>();
+
+ static {
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ }
+
+ private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
+
+ public AjaxPageRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ ajaxPage = (org.ajax4jsf.component.html.HtmlPage)
application.createComponent(org.ajax4jsf.component.html.HtmlPage.COMPONENT_TYPE);
+ ajaxPage.setId("page");
+
+ UIOutput head = new UIOutput();
+ head.setValue("HEAD");
+ ajaxPage.getFacets().put("head", head);
+
+ UIOutput content = new UIOutput();
+ content.setValue("content");
+ ajaxPage.getChildren().add(content);
+
+ ajaxPage.setFormat("xhtml");
+ ajaxPage.setPageTitle("title");
+
+ facesContext.getViewRoot().setLocale(new Locale("be", "BY"));
+
+ facesContext.getViewRoot().getChildren().add(ajaxPage);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ HtmlElement html = (HtmlElement)page.getFirstChild();
+ assertNotNull(html);
+ assertEquals("html", html.getTagName());
+
+ String lang = html.getAttributeValue("lang");
+ assertNotNull(lang);
+ assertEquals(lang, "be_BY");
+
+ HtmlElement title = (HtmlElement)
html.getHtmlElementsByTagName("title").get(0);
+ assertNotNull(title);
+
+ assertEquals("title", title.getFirstChild().asText());
+
+ HtmlElement meta = (HtmlElement)
html.getHtmlElementsByTagName("meta").get(0);
+
+ assertNotNull(meta);
+ String httpEquiv = meta.getAttributeValue("http-equiv");
+ assertEquals(httpEquiv, "Content-Type");
+
+ String content = meta.getAttributeValue("content");
+ assertEquals(content, "application/xhtml+xml");
+ }
+
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
+ }
+
+ @Override
+ protected void encodeDocumentProlog(FacesContext context,
+ UIViewRoot viewRoot, ResponseWriter writer) throws IOException {
+
+ //do nothing as a4j:page encodes full page structure
+ }
+
+ @Override
+ protected void encodeDocumentEpilog(FacesContext context,
+ UIViewRoot viewRoot, ResponseWriter writer) throws IOException {
+
+ //do nothing as a4j:page encodes full page structure
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPushRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPushRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxPushRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,140 +1,140 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.component.UIPush;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-import org.apache.commons.lang.StringUtils;
-
-import com.gargoylesoftware.htmlunit.html.DomText;
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-import com.gargoylesoftware.htmlunit.html.HtmlScript;
-
-public class AjaxPushRendererTest extends AbstractAjax4JsfTestCase {
-
- private static Set<String> javaScripts = new HashSet<String>();
- private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
-
- static {
- javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
- }
- private UIForm form = null;
- private UIPush push1 = null;
- private UIPush push2 = null;
-
- public AjaxPushRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- push1 = (UIPush) application.createComponent(UIPush.COMPONENT_TYPE);
- push1.setId("push1");
- push1.setEnabled(true);
- form.getChildren().add(push1);
-
- push2 = (UIPush) application.createComponent(UIPush.COMPONENT_TYPE);
- push2.setId("push2");
- push2.setEnabled(false);
- form.getChildren().add(push2);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- push1 = null;
- push2 = null;
- form = null;
- }
-
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement span1 = page.getHtmlElementById(push1.getClientId(facesContext));
- assertNotNull(span1);
- assertEquals("span", span1.getTagName());
- String style = span1.getAttributeValue("style");
- assertNotNull(style);
- assertTrue(style.matches("display\\s*\\:\\s*none\\s*\\;\\s*"));
-
- HtmlElement span2 = page.getHtmlElementById(push2.getClientId(facesContext));
- assertNotNull(span2);
- assertEquals("span", span2.getTagName());
- style = span2.getAttributeValue("style");
- assertNotNull(style);
- assertTrue(style.matches("display\\s*\\:\\s*none\\s*\\;\\s*"));
- }
-
- public void testRenderScript() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- List scripts =
page.getDocumentElement().getHtmlElementsByTagName("script");
- assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
-
- HtmlElement span1 = page.getHtmlElementById(push1.getClientId(facesContext));
- assertNotNull(span1);
- scripts = span1.getHtmlElementsByTagName("script");
- int i = 0;
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
- DomText text = (DomText) item.getFirstChild();
-
- assertNotNull(text);
- assertTrue(text.asText().contains("A4J.AJAX.Push"));
-
- i++;
- }
- assertEquals(1, i);
-
- HtmlElement span2 = page.getHtmlElementById(push2.getClientId(facesContext));
- assertNotNull(span2);
- scripts = span2.getHtmlElementsByTagName("script");
- i = 0;
- for (Iterator it = scripts.iterator(); it.hasNext();) {
- HtmlScript item = (HtmlScript) it.next();
- DomText text = (DomText) item.getFirstChild();
-
- assertNotNull(text);
- assertTrue(text.asText().contains("A4J.AJAX.StopPush"));
-
- i++;
- }
- assertEquals(1, i);
- }
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.component.UIPush;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.html.DomText;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+public class AjaxPushRendererTest extends AbstractAjax4JsfTestCase {
+
+ private static Set<String> javaScripts = new HashSet<String>();
+ private static final boolean IS_PAGE_AVAILABILITY_CHECK = true;
+
+ static {
+ javaScripts.add("org.ajax4jsf.javascript.AjaxScript");
+ }
+ private UIForm form = null;
+ private UIPush push1 = null;
+ private UIPush push2 = null;
+
+ public AjaxPushRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ push1 = (UIPush) application.createComponent(UIPush.COMPONENT_TYPE);
+ push1.setId("push1");
+ push1.setEnabled(true);
+ form.getChildren().add(push1);
+
+ push2 = (UIPush) application.createComponent(UIPush.COMPONENT_TYPE);
+ push2.setId("push2");
+ push2.setEnabled(false);
+ form.getChildren().add(push2);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ push1 = null;
+ push2 = null;
+ form = null;
+ }
+
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ HtmlElement span1 = page.getHtmlElementById(push1.getClientId(facesContext));
+ assertNotNull(span1);
+ assertEquals("span", span1.getTagName());
+ String style = span1.getAttributeValue("style");
+ assertNotNull(style);
+ assertTrue(style.matches("display\\s*\\:\\s*none\\s*\\;\\s*"));
+
+ HtmlElement span2 = page.getHtmlElementById(push2.getClientId(facesContext));
+ assertNotNull(span2);
+ assertEquals("span", span2.getTagName());
+ style = span2.getAttributeValue("style");
+ assertNotNull(style);
+ assertTrue(style.matches("display\\s*\\:\\s*none\\s*\\;\\s*"));
+ }
+
+ public void testRenderScript() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts =
page.getDocumentElement().getHtmlElementsByTagName("script");
+ assertEquals(getCountValidScripts(page, javaScripts,
IS_PAGE_AVAILABILITY_CHECK).intValue(), javaScripts.size());
+
+ HtmlElement span1 = page.getHtmlElementById(push1.getClientId(facesContext));
+ assertNotNull(span1);
+ scripts = span1.getHtmlElementsByTagName("script");
+ int i = 0;
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ DomText text = (DomText) item.getFirstChild();
+
+ assertNotNull(text);
+ assertTrue(text.asText().contains("A4J.AJAX.Push"));
+
+ i++;
+ }
+ assertEquals(1, i);
+
+ HtmlElement span2 = page.getHtmlElementById(push2.getClientId(facesContext));
+ assertNotNull(span2);
+ scripts = span2.getHtmlElementsByTagName("script");
+ i = 0;
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ DomText text = (DomText) item.getFirstChild();
+
+ assertNotNull(text);
+ assertTrue(text.asText().contains("A4J.AJAX.StopPush"));
+
+ i++;
+ }
+ assertEquals(1, i);
+ }
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxStatusRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxStatusRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/AjaxStatusRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,151 +1,153 @@
-/**
- * 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.renderkit.html;
-
-import java.util.Iterator;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.UIGraphic;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.component.UIAjaxStatus;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class AjaxStatusRendererTest extends AbstractAjax4JsfTestCase {
- private UIForm form = null;
- private UIAjaxStatus status1 = null;
- private UIAjaxStatus status2 = null;
-
- public AjaxStatusRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- application.addComponent("org.ajax4jsf.AjaxStatus",
"org.ajax4jsf.component.html.HtmlAjaxStatus");
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- status1 = (UIAjaxStatus)application.createComponent(UIAjaxStatus.COMPONENT_TYPE);
- status1.setId("status1");
- status1.setStartStyle("color: red;");
- status1.setStartStyleClass("A B C D");
- status1.setStopStyle("color: green;");
- status1.setStopStyleClass("X Y Z");
- status1.setStartText("startText");
- status1.setStopText("stopText");
- status1.getAttributes().put("layout", "block");
-
- status2 = (UIAjaxStatus)application.createComponent(UIAjaxStatus.COMPONENT_TYPE);
- status2.setId("status2");
- status2.setStartStyle("color: red;");
- status2.setStartStyleClass("A B C D");
- status2.setStopStyle("color: green;");
- status2.setStopStyleClass("X Y Z");
- status2.getAttributes().put("layout", "inline");
-
- UIGraphic startImage = new UIGraphic();
- startImage.setValue("start.png");
- status2.getFacets().put("start", startImage);
-
- UIGraphic stopGraphic = new UIGraphic();
- stopGraphic.setValue("stop.png");
- status2.getFacets().put("stop", stopGraphic);
-
- form.getChildren().add(status1);
- form.getChildren().add(status2);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- status1 = null;
- status2 = null;
- form = null;
- }
-
- /**
- * Test rendering
- *
- * @throws Exception
- */
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
-
- HtmlElement div = page.getHtmlElementById(status1.getClientId(facesContext));
- assertNotNull(div);
- assertEquals("div", div.getNodeName());
-
- Iterator childIterator = div.getChildIterator();
- int i = 0;
- while (childIterator.hasNext()) {
- i++;
- HtmlElement element = (HtmlElement) childIterator.next();
- assertEquals("div", element.getNodeName());
- }
- assertEquals(2, i);
-
- HtmlElement div1 = page.getHtmlElementById(status1.getClientId(facesContext) +
".start");
- assertNotNull(div1);
- String style1 = div1.getAttributeValue("style");
- assertNotNull(style1);
- assertTrue(style1.contains("color: red;"));
- String class1 = div1.getAttributeValue("class");
- assertNotNull(class1);
- assertEquals(class1, "A B C D");
-
- HtmlElement div2 = page.getHtmlElementById(status1.getClientId(facesContext) +
".stop");
- assertNotNull(div2);
- String style2 = div2.getAttributeValue("style");
- assertNotNull(style2);
- assertTrue(style2.contains("color: green;"));
- String class2 = div2.getAttributeValue("class");
- assertNotNull(class2);
- assertEquals(class2, "X Y Z");
-
- form.getChildren().remove(0);
- page = renderView();
- System.out.println(page.asXml());
-
- HtmlElement span = (HtmlElement) div.getNextSibling();
- assertNotNull(span);
- assertEquals("span", span.getNodeName());
-
- childIterator = span.getChildIterator();
- i = 0;
- while (childIterator.hasNext()) {
- i++;
- HtmlElement element = (HtmlElement) childIterator.next();
- assertEquals("span", element.getNodeName());
- assertEquals("img", element.getFirstChild().getNodeName());
- }
- assertEquals(2, i);
- }
-
-}
+/**
+ * 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.renderkit.html;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.UIGraphic;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.component.UIAjaxStatus;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class AjaxStatusRendererTest extends AbstractAjax4JsfTestCase {
+ private UIForm form = null;
+ private UIAjaxStatus status1 = null;
+ private UIAjaxStatus status2 = null;
+
+ public AjaxStatusRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ application.addComponent("org.ajax4jsf.AjaxStatus",
"org.ajax4jsf.component.html.HtmlAjaxStatus");
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ status1 = (UIAjaxStatus)application.createComponent(UIAjaxStatus.COMPONENT_TYPE);
+ status1.setId("status1");
+ status1.setStartStyle("color: red;");
+ status1.setStartStyleClass("A B C D");
+ status1.setStopStyle("color: green;");
+ status1.setStopStyleClass("X Y Z");
+ status1.setStartText("startText");
+ status1.setStopText("stopText");
+ status1.getAttributes().put("layout", "block");
+
+ status2 = (UIAjaxStatus)application.createComponent(UIAjaxStatus.COMPONENT_TYPE);
+ status2.setId("status2");
+ status2.setStartStyle("color: red;");
+ status2.setStartStyleClass("A B C D");
+ status2.setStopStyle("color: green;");
+ status2.setStopStyleClass("X Y Z");
+ status2.getAttributes().put("layout", "inline");
+
+ UIGraphic startImage = new UIGraphic();
+ startImage.setValue("start.png");
+ startImage.getAttributes().put("alt", "alt");
+ status2.getFacets().put("start", startImage);
+
+ UIGraphic stopGraphic = new UIGraphic();
+ stopGraphic.setValue("stop.png");
+ stopGraphic.getAttributes().put("alt", "alt");
+ status2.getFacets().put("stop", stopGraphic);
+
+ form.getChildren().add(status1);
+ form.getChildren().add(status2);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ status1 = null;
+ status2 = null;
+ form = null;
+ }
+
+ /**
+ * Test rendering
+ *
+ * @throws Exception
+ */
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlElement div = page.getHtmlElementById(status1.getClientId(facesContext));
+ assertNotNull(div);
+ assertEquals("div", div.getNodeName());
+
+ Iterator childIterator = div.getChildIterator();
+ int i = 0;
+ while (childIterator.hasNext()) {
+ i++;
+ HtmlElement element = (HtmlElement) childIterator.next();
+ assertEquals("div", element.getNodeName());
+ }
+ assertEquals(2, i);
+
+ HtmlElement div1 = page.getHtmlElementById(status1.getClientId(facesContext) +
".start");
+ assertNotNull(div1);
+ String style1 = div1.getAttributeValue("style");
+ assertNotNull(style1);
+ assertTrue(style1.contains("color: red;"));
+ String class1 = div1.getAttributeValue("class");
+ assertNotNull(class1);
+ assertEquals(class1, "A B C D");
+
+ HtmlElement div2 = page.getHtmlElementById(status1.getClientId(facesContext) +
".stop");
+ assertNotNull(div2);
+ String style2 = div2.getAttributeValue("style");
+ assertNotNull(style2);
+ assertTrue(style2.contains("color: green;"));
+ String class2 = div2.getAttributeValue("class");
+ assertNotNull(class2);
+ assertEquals(class2, "X Y Z");
+
+ form.getChildren().remove(0);
+ page = renderView();
+ System.out.println(page.asXml());
+
+ HtmlElement span = (HtmlElement) div.getNextSibling();
+ assertNotNull(span);
+ assertEquals("span", span.getNodeName());
+
+ childIterator = span.getChildIterator();
+ i = 0;
+ while (childIterator.hasNext()) {
+ i++;
+ HtmlElement element = (HtmlElement) childIterator.next();
+ assertEquals("span", element.getNodeName());
+ assertEquals("img", element.getFirstChild().getNodeName());
+ }
+ assertEquals(2, i);
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/HtmlCommandLinkRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,96 +1,139 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import javax.faces.component.UIForm;
-import javax.faces.component.html.HtmlCommandLink;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class HtmlCommandLinkRendererTest extends AbstractAjax4JsfTestCase {
- private UIForm form = null;
- private HtmlCommandLink link1 = null;
- private HtmlCommandLink link2 = null;
-
- public HtmlCommandLinkRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- facesContext.getRenderKit().addRenderer(HtmlCommandLink.COMPONENT_FAMILY,
"org.ajax4jsf.Link", new HtmlCommandLinkRenderer());
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- link1 = (HtmlCommandLink)
application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
- link1.setId("link1");
- link1.setValue("link1");
- link1.getAttributes().put("disabled", Boolean.FALSE);
- link1.setRendererType("org.ajax4jsf.Link");
- form.getChildren().add(link1);
-
- link2 = (HtmlCommandLink)
application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
- link2.setId("link2");
- link2.setValue("link2");
- link2.getAttributes().put("disabled", Boolean.TRUE);
- link2.setRendererType("org.ajax4jsf.Link");
- form.getChildren().add(link2);
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- link1 = null;
- link2 = null;
- form = null;
- }
-
- public void testRendered() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement href = page.getHtmlElementById(link1.getClientId(facesContext));
- assertNotNull(href);
- assertEquals("a", href.getTagName());
-
- String onclick = href.getAttributeValue("onclick");
- assertNotNull(onclick);
- assertTrue(onclick.contains(AjaxFormRenderer.FORM_SUBMIT_FUNCTION_NAME));
-
- HtmlElement span = page.getHtmlElementById(link2.getClientId(facesContext));
- assertNotNull(span);
- assertEquals("span", span.getTagName());
-
- String disabled = span.getAttributeValue("disabled");
- assertNotNull(disabled);
- assertEquals("disabled", disabled);
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlCommandLink;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.apache.commons.lang.StringUtils;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
+
+public class HtmlCommandLinkRendererTest extends AbstractAjax4JsfTestCase {
+ /** Set with required javascripts for Editor */
+ private static Set<String> javaScripts = new HashSet<String>();
+
+ static {
+ javaScripts.add("org/ajax4jsf/javascript/scripts/form.js");
+ }
+
+ private UIForm form = null;
+ private HtmlCommandLink link1 = null;
+ private HtmlCommandLink link2 = null;
+
+ public HtmlCommandLinkRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ facesContext.getRenderKit().addRenderer(HtmlCommandLink.COMPONENT_FAMILY,
"org.ajax4jsf.Link", new HtmlCommandLinkRenderer());
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ link1 = (HtmlCommandLink)
application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
+ link1.setId("link1");
+ link1.setValue("link1");
+ link1.getAttributes().put("disabled", Boolean.FALSE);
+ link1.setRendererType("org.ajax4jsf.Link");
+ form.getChildren().add(link1);
+
+ link2 = (HtmlCommandLink)
application.createComponent(HtmlCommandLink.COMPONENT_TYPE);
+ link2.setId("link2");
+ link2.setValue("link2");
+ link2.getAttributes().put("disabled", Boolean.TRUE);
+ link2.setRendererType("org.ajax4jsf.Link");
+ form.getChildren().add(link2);
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ link1 = null;
+ link2 = null;
+ form = null;
+ }
+
+ public void testRendered() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ HtmlElement href = page.getHtmlElementById(link1.getClientId(facesContext));
+ assertNotNull(href);
+ assertEquals("a", href.getTagName());
+
+ String onclick = href.getAttributeValue("onclick");
+ assertNotNull(onclick);
+ assertTrue(onclick.contains(AjaxFormRenderer.FORM_SUBMIT_FUNCTION_NAME));
+
+ HtmlElement span = page.getHtmlElementById(link2.getClientId(facesContext));
+ assertNotNull(span);
+ assertEquals("span", span.getTagName());
+
+ String disabled = span.getAttributeValue("disabled");
+ assertNotNull(disabled);
+ assertEquals("disabled", disabled);
+ }
+
+ /**
+ * Method to test if required scripts is present on page
+ * @throws Exception
+ */
+ @SuppressWarnings("unchecked")
+ public void testLinkScripts() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List scripts = page.getDocumentHtmlElement().getHtmlElementsByTagName(
+ "script");
+
+ for (Iterator it = scripts.iterator(); it.hasNext();) {
+ HtmlScript item = (HtmlScript) it.next();
+ String srcAttr = item.getSrcAttribute();
+ if (StringUtils.isNotBlank(srcAttr)) {
+ boolean found = false;
+ for (Iterator srcIt = javaScripts.iterator(); srcIt.hasNext();) {
+ String src = (String) srcIt.next();
+ found = srcAttr.contains(src);
+ if (found) {
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+ }
+ }
+
+}
Modified:
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/MediaOutputRendererTest.java
===================================================================
---
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/MediaOutputRendererTest.java 2009-07-10
11:04:14 UTC (rev 14875)
+++
branches/jsf2.0/ui/core/src/test/java/org/ajax4jsf/renderkit/html/MediaOutputRendererTest.java 2009-07-10
11:13:58 UTC (rev 14876)
@@ -1,140 +1,141 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.renderkit.html;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIForm;
-import javax.faces.component.UIParameter;
-import javax.faces.component.html.HtmlForm;
-
-import org.ajax4jsf.component.UIMediaOutput;
-import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
-
-import com.gargoylesoftware.htmlunit.html.HtmlElement;
-import com.gargoylesoftware.htmlunit.html.HtmlPage;
-
-public class MediaOutputRendererTest extends AbstractAjax4JsfTestCase {
- UIForm form = null;
- UIMediaOutput media1 = null;
- UIMediaOutput media2 = null;
- UIMediaOutput media3 = null;
- UIMediaOutput media4 = null;
- UIMediaOutput media5 = null;
-
- public MediaOutputRendererTest(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- super.setUp();
-
- application.addComponent("org.ajax4jsf.MMedia",
"org.ajax4jsf.component.html.MediaOutput");
-
- form = new HtmlForm();
- form.setId("form");
- facesContext.getViewRoot().getChildren().add(form);
-
- media1 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
- media1.setId("media1");
- media1.setElement("a");
- media1.setUriAttribute("href");
- form.getChildren().add(media1);
-
- media2 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
- media2.setId("media2");
- media2.setElement("img");
- media2.setUriAttribute("src");
- form.getChildren().add(media2);
-
- media3 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
- media3.setId("media3");
- media3.setElement("object");
- media3.setUriAttribute("data");
- form.getChildren().add(media3);
-
- media4 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
- media4.setId("media4");
- media4.setElement("a");
- UIParameter param = new UIParameter();
- param.setName("name");
- param.setValue("value");
- media4.getChildren().add(param);
- form.getChildren().add(media4);
-
- media5 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
- media5.setId("media5");
- }
-
- public void tearDown() throws Exception {
- super.tearDown();
-
- media1 = null;
- media2 = null;
- media3 = null;
- media4 = null;
- media5 = null;
- form = null;
- }
-
- public void testRender() throws Exception {
- HtmlPage page = renderView();
- assertNotNull(page);
- System.out.println(page.asXml());
-
- HtmlElement a = page.getHtmlElementById(media1.getClientId(facesContext));
- assertNotNull(a);
- assertEquals("a", a.getTagName());
- String href = a.getAttributeValue("href");
- assertNotNull(href);
-
- HtmlElement img = page.getHtmlElementById(media2.getClientId(facesContext));
- assertNotNull(img);
- assertEquals("img", img.getTagName());
- String src = img.getAttributeValue("src");
- assertNotNull(src);
-
- HtmlElement object = page.getHtmlElementById(media3.getClientId(facesContext));
- assertNotNull(object);
- assertEquals("object", object.getTagName());
- String data = object.getAttributeValue("data");
- assertNotNull(data);
-
- // Rendering without uriAttribute
- HtmlElement a2 = page.getHtmlElementById(media4.getClientId(facesContext));
- assertNotNull(a2);
- assertEquals("a", a2.getTagName());
- String href2 = a2.getAttributeValue("href");
- assertNotNull(href2);
- assertTrue(href2.endsWith("name=value"));
- }
-
- public void testRenderWithoutElement() throws Exception {
- form.getChildren().add(media5);
- try {
- renderView();
- assertTrue("'element' is undefined but exception was not thrown",
false);
- } catch (FacesException e) {
-
- }
- }
-
-}
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.ajax4jsf.renderkit.html;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIForm;
+import javax.faces.component.UIParameter;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.component.UIMediaOutput;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public class MediaOutputRendererTest extends AbstractAjax4JsfTestCase {
+ UIForm form = null;
+ UIMediaOutput media1 = null;
+ UIMediaOutput media2 = null;
+ UIMediaOutput media3 = null;
+ UIMediaOutput media4 = null;
+ UIMediaOutput media5 = null;
+
+ public MediaOutputRendererTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+
+ application.addComponent("org.ajax4jsf.MMedia",
"org.ajax4jsf.component.html.MediaOutput");
+
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ media1 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
+ media1.setId("media1");
+ media1.setElement("a");
+ media1.setUriAttribute("href");
+ form.getChildren().add(media1);
+
+ media2 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
+ media2.setId("media2");
+ media2.setElement("img");
+ media2.setUriAttribute("src");
+ media2.getAttributes().put("alt", "Generated value");
+ form.getChildren().add(media2);
+
+ media3 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
+ media3.setId("media3");
+ media3.setElement("object");
+ media3.setUriAttribute("data");
+ form.getChildren().add(media3);
+
+ media4 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
+ media4.setId("media4");
+ media4.setElement("a");
+ UIParameter param = new UIParameter();
+ param.setName("name");
+ param.setValue("value");
+ media4.getChildren().add(param);
+ form.getChildren().add(media4);
+
+ media5 = (UIMediaOutput)application.createComponent(UIMediaOutput.COMPONENT_TYPE);
+ media5.setId("media5");
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+
+ media1 = null;
+ media2 = null;
+ media3 = null;
+ media4 = null;
+ media5 = null;
+ form = null;
+ }
+
+ public void testRender() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+ System.out.println(page.asXml());
+
+ HtmlElement a = page.getHtmlElementById(media1.getClientId(facesContext));
+ assertNotNull(a);
+ assertEquals("a", a.getTagName());
+ String href = a.getAttributeValue("href");
+ assertNotNull(href);
+
+ HtmlElement img = page.getHtmlElementById(media2.getClientId(facesContext));
+ assertNotNull(img);
+ assertEquals("img", img.getTagName());
+ String src = img.getAttributeValue("src");
+ assertNotNull(src);
+
+ HtmlElement object = page.getHtmlElementById(media3.getClientId(facesContext));
+ assertNotNull(object);
+ assertEquals("object", object.getTagName());
+ String data = object.getAttributeValue("data");
+ assertNotNull(data);
+
+ // Rendering without uriAttribute
+ HtmlElement a2 = page.getHtmlElementById(media4.getClientId(facesContext));
+ assertNotNull(a2);
+ assertEquals("a", a2.getTagName());
+ String href2 = a2.getAttributeValue("href");
+ assertNotNull(href2);
+ assertTrue(href2.endsWith("name=value"));
+ }
+
+ public void testRenderWithoutElement() throws Exception {
+ form.getChildren().add(media5);
+ try {
+ renderView();
+ assertTrue("'element' is undefined but exception was not thrown",
false);
+ } catch (FacesException e) {
+
+ }
+ }
+
+}
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.js
(from rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/component.js)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.js
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.js 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1 @@
+/* dependency of org.ajax4jsf.component.LoadResourceComponentTest */
\ No newline at end of file
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.xcss
(from rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/component.xcss)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.xcss
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/component.xcss 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml">
+
+ <!-- dependency of org.ajax4jsf.component.LoadResourceComponentTest -->
+
+</f:template>
\ No newline at end of file
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-ajax-form.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-ajax-form.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-ajax-form.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-ajax-form.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,42 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <head>
+ <title>a4j:form check page</title>
+ </head>
+ <body>
+ <f:view>
+ <script type="text/javascript">
+ window.testResults = {};
+ </script>
+
+ <a4j:status startText="...running..." startStyle="color: green"
/>
+
+ <a4j:queue oncomplete="window.testResults.viewDefault = true"/>
+
+ <a4j:form ajaxSubmit="true" id="viewDefault">
+ <h:commandButton value="view default queue" id="link" />
+ </a4j:form>
+
+ <a4j:queue oncomplete="window.testResults.viewNamed = true"
name="viewNamed" />
+
+ <a4j:form ajaxSubmit="true" eventsQueue="viewNamed"
id="viewNamed">
+ <h:commandButton value="view named queue" id="link" />
+ </a4j:form>
+
+ <a4j:form ajaxSubmit="true" id="formDefault">
+ <a4j:queue oncomplete="window.testResults.formDefault = true" />
+
+ <h:commandButton value="form default queue" id="link" />
+ </a4j:form>
+
+ <a4j:form ajaxSubmit="true" eventsQueue="formQueue"
id="formNamed">
+ <a4j:queue oncomplete="window.testResults.formNamed = true"
name="formQueue" />
+
+ <h:commandButton value="form named queue" id="link" />
+ </a4j:form>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-disabled.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-disabled.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-disabled.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-disabled.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,59 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <ui:include src="queue-discovery-base.xhtml" />
+
+ <h:form id="form">
+ <a4j:commandButton id="button"
oncomplete="addResult('button')">
+ <f:param name="data" value="button" />
+ </a4j:commandButton>
+ <a4j:commandButton id="formQueueButton"
oncomplete="addResult('formQueueButton')"
eventsQueue="form">
+ <f:param name="data" value="formQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:queue oncomplete="addResult('disabled')"
disabled="true" />
+ <a4j:queue oncomplete="addResult('disabledForm')"
name="form" disabled="true" />
+ </h:form>
+
+ <h:form id="form2">
+ <a4j:commandButton id="button2"
oncomplete="addResult('button2')">
+ <f:param name="data" value="button2" />
+ </a4j:commandButton>
+ <a4j:commandButton id="formQueueButton2"
oncomplete="addResult('formQueueButton2')"
eventsQueue="form2">
+ <f:param name="data" value="formQueueButton2" />
+ </a4j:commandButton>
+
+ <a4j:queue oncomplete="addResult('disabledA')"
disabled="true" />
+ <a4j:queue oncomplete="addResult('form2-global:' +
request.options.parameters.data)" />
+ <a4j:queue oncomplete="addResult('disabledB')"
disabled="true" />
+
+ <a4j:queue oncomplete="addResult('disabledA1')"
disabled="true" name="form2" />
+ <a4j:queue oncomplete="addResult('form2-queue:' +
request.options.parameters.data)" name="form2"/>
+ <a4j:queue oncomplete="addResult('disabledB1')"
disabled="true" name="form2" />
+ </h:form>
+
+ <h:form id="form3">
+ <a4j:commandButton id="global"
oncomplete="addResult('global')">
+ <f:param name="data" value="global" />
+ </a4j:commandButton>
+ <a4j:commandButton id="globalNamed"
oncomplete="addResult('globalNamed')"
eventsQueue="viewNamed">
+ <f:param name="data" value="globalNamed" />
+ </a4j:commandButton>
+ <a4j:commandButton id="globalNamedX"
oncomplete="addResult('globalNamedX')"
eventsQueue="viewNamedX">
+ <f:param name="data" value="globalNamedX" />
+ </a4j:commandButton>
+ </h:form>
+
+ <a4j:queue oncomplete="addResult('disabled:' +
request.options.parameters.data)" disabled="true" />
+ <a4j:queue oncomplete="addResult('viewNamed:' +
request.options.parameters.data)" name="viewNamed"
disabled="true" />
+
+ <a4j:queue oncomplete="addResult('viewNamedXA:' +
request.options.parameters.data)" name="viewNamedX"
disabled="true" />
+ <a4j:queue oncomplete="addResult('viewNamedX:' +
request.options.parameters.data)" name="viewNamedX" />
+ <a4j:queue oncomplete="addResult('viewNamedXB:' +
request.options.parameters.data)" name="viewNamedX"
disabled="true" />
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-discovery-base.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-discovery-base.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-discovery-base.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-discovery-base.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,18 @@
+<ui:composition
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+
+ <script type="text/javascript">
+ window.testResult = new Array();
+
+ function addResult(value) {
+ window.testResult.push(value);
+ }
+
+ function stub() {
+ }
+ </script>
+
+ <a4j:status startText="...running..." startStyle="color: green"
/>
+</ui:composition>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-both.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-both.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-both.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-both.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,65 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <ui:include src="queue-discovery-base.xhtml" />
+
+ <a4j:queue oncomplete="addResult(request.options.parameters.data)"/>
+
+ <h:form id="form">
+ <a4j:queue oncomplete="addResult('buttonFormQueue')"/>
+
+ <a4j:commandButton id="button" oncomplete="stub()">
+ <f:param name="data" value="button" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="viewQueueButton" oncomplete="stub()"
eventsQueue="viewQueue">
+ <f:param name="data" value="viewQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="implicitDelayedQueue"
requestDelay="500"
+ eventsQueue="implicitDelayedQueue"
oncomplete="addResult('implicitDelayedQueue')">
+ <f:param name="data" value="implicitDelayedQueue" />
+ </a4j:commandButton>
+ </h:form>
+
+ <h:form id="form2">
+ <a4j:commandButton id="formQueueButton"
eventsQueue="formQueue" requestDelay="1000"
oncomplete="stub()">
+ <f:param name="data" value="formQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:queue oncomplete="addResult('formQueue:' +
request.options.parameters.data)" name="formQueue"/>
+
+ <a4j:commandButton id="button" requestDelay="1000"
oncomplete="stub()">
+ <f:param name="data" value="form2Button" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="implicitQueue"
eventsQueue="implicitQueue"
oncomplete="addResult('implicitQueue')">
+ <f:param name="data" value="implicitQueue" />
+ </a4j:commandButton>
+ </h:form>
+
+ <h:form id="form3">
+
+ <a4j:commandButton id="button">
+ <f:param name="data" value="form3Button" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="anotherImplicitQueue"
ignoreDupResponses="true" eventsQueue="anotherImplicitQueue"
oncomplete="addResult('anotherImplicitQueue')">
+ <f:param name="data" value="anotherImplicitQueue" />
+ </a4j:commandButton>
+ </h:form>
+
+ <h:form>
+ <a4j:queue oncomplete="addResult('functionFormQueue')"/>
+
+ <a4j:jsFunction name="ajaxFunction" />
+ </h:form>
+
+ <a4j:queue oncomplete="addResult('viewQueue:' +
request.options.parameters.data)" name="viewQueue"/>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-form.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-form.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-form.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-form.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,53 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <ui:include src="queue-discovery-base.xhtml" />
+
+ <h:form id="form">
+ <a4j:queue oncomplete="addResult('alt1:' +
request.options.parameters.data)" name="alternativeQueue1" />
+ <a4j:queue oncomplete="addResult('buttonFormQueue')"/>
+
+ <a4j:commandButton id="button" oncomplete="stub()">
+ <f:param name="data" value="button" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="implicitQueue"
eventsQueue="implicitQueue"
oncomplete="addResult('implicitQueue')">
+ <f:param name="data" value="implicitQueue" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="alternativeQueueButton"
eventsQueue="alternativeQueue"
oncomplete="addResult('alternativeQueueButton')">
+ <f:param name="data" value="alternativeQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="alternativeQueue1Button"
eventsQueue="alternativeQueue1"
oncomplete="addResult('alternativeQueue1Button')">
+ <f:param name="data" value="alternativeQueue1Button" />
+ </a4j:commandButton>
+
+ </h:form>
+
+ <h:form>
+ <a4j:jsFunction name="ajaxFunction"
oncomplete="addResult('ajaxFunction')"/>
+ </h:form>
+
+
+ <h:form id="form2">
+ <a4j:commandButton id="button" requestDelay="1000"
oncomplete="stub()" />
+ <a4j:commandButton id="implicitDelayedQueue"
requestDelay="500"
+ eventsQueue="implicitDelayedQueue"
oncomplete="addResult('implicitDelayedQueue')">
+ <f:param name="data" value="implicitDelayedQueue" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="alternativeQueueButton"
eventsQueue="alternativeQueue"
oncomplete="addResult('alternativeQueueButton')">
+ <f:param name="data" value="alternativeQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:queue oncomplete="addResult('buttonForm2Queue')"/>
+ <a4j:queue oncomplete="addResult('alt:' +
request.options.parameters.data)" name="alternativeQueue" />
+ </h:form>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-view.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-view.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-view.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-global-view.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,40 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <ui:include src="queue-discovery-base.xhtml" />
+
+ <h:form id="form">
+ <a4j:commandButton id="button" oncomplete="stub()"
requestDelay="100">
+ <f:param name="data" value="button" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="alternativeQueueButton"
eventsQueue="alternativeQueue"
oncomplete="addResult('alternativeQueueButton')">
+ <f:param name="data" value="alternativeQueueButton" />
+ </a4j:commandButton>
+
+ <a4j:commandButton id="implicitQueue"
eventsQueue="implicitQueue"
oncomplete="addResult('implicitQueue')">
+ <f:param name="data" value="implicitQueue" />
+ </a4j:commandButton>
+ </h:form>
+
+ <h:form id="form2">
+ <a4j:jsFunction name="ajaxFunction" oncomplete="stub()">
+ <f:param name="data" value="function" />
+ </a4j:jsFunction>
+
+ <a4j:commandButton id="implicitDelayedQueue"
requestDelay="500"
+ eventsQueue="implicitDelayedQueue"
oncomplete="addResult('implicitDelayedQueue')">
+ <f:param name="data" value="implicitDelayedQueue" />
+ </a4j:commandButton>
+ </h:form>
+
+ <a4j:queue oncomplete="addResult(request.options.parameters.data)"/>
+ <a4j:queue oncomplete="addResult('alt:' +
request.options.parameters.data)" name="alternativeQueue" />
+
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-implicit-global.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-implicit-global.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-implicit-global.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-implicit-global.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,10 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-legacy.xhtml (from
rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-legacy.xhtml)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-legacy.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-legacy.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,20 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <script type="text/javascript">
+ XMLHttpRequest.defaultRequestTime = 5000;
+
+ var counter = 0;
+ var time = 0;
+ </script>
+ <h:form id="form">
+ <a4j:commandButton id="buttonDelayed" requestDelay="1000"
/>
+ <a4j:commandButton id="buttonIgnoreDupResponces"
ignoreDupResponses="true" oncomplete="counter++;time =
Timer.currentTime;"/>
+ </h:form>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-parallel.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-parallel.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-parallel.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-parallel.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,24 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jstl/core">
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <a4j:status startText="...running..." stopText="stopped"
startStyle="color: green" />
+
+ <h:form id="form">
+ <a4j:queue name="queue" />
+
+ <a4j:commandButton id="asyncButton" />
+
+ <a4j:commandButton id="syncButton1" eventsQueue="queue" />
+ <a4j:commandButton id="syncButton2" eventsQueue="queue" />
+ </h:form>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll-drop.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll-drop.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll-drop.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll-drop.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,26 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <a4j:queue size="2" name="dropNextQueue"
sizeExceededBehavior="dropNext" />
+ <a4j:queue size="2" name="dropNewQueue"
sizeExceededBehavior="dropNew" />
+ <a4j:queue size="1" name="dropNextQueueSingle"
sizeExceededBehavior="dropNext" />
+
+ <h:form id="firstForm" rendered="#{renderDropNext}">
+ <a4j:poll interval="2000" id="poll"
eventsQueue="dropNextQueue" />
+ </h:form>
+
+ <h:form id="secondForm" rendered="#{renderDropNew}">
+ <a4j:poll interval="2500" id="poll"
eventsQueue="dropNewQueue" />
+ </h:form>
+
+ <h:form id="thirdForm" rendered="#{renderDropNextSingle}">
+ <a4j:poll interval="2000" id="poll"
eventsQueue="dropNextQueueSingle" />
+ </h:form>
+
+ </f:view>
+ </body>
+</html>
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll.xhtml)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-poll.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,29 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+
+ <h:form id="firstForm">
+ <a4j:queue />
+
+ <a4j:poll id="queuedDefaultPoll"
enabled="#{queuedDefaultPollEnabled}" interval="600" />
+ <a4j:poll id="queuedDelayedPoll"
enabled="#{queuedDelayedPollEnabled}" interval="200"
requestDelay="100" />
+ </h:form>
+
+ <h:form id="secondForm">
+ <a4j:queue requestDelay="10000" />
+
+ <a4j:poll id="delayedQueueDefaultPoll"
enabled="#{delayedQueueDefaultPollEnabled}" interval="1500" />
+ <a4j:poll id="delayedQueueDelayedPoll"
enabled="#{delayedQueueDelayedPollEnabled}" interval="2000"
requestDelay="400" />
+ </h:form>
+
+ <h:form id="thirdForm">
+ <a4j:poll id="unqueuedDefaultPoll"
enabled="#{unqueuedDefaultPollEnabled}" interval="700" />
+ <a4j:poll id="unqueuedDelayedPoll"
enabled="#{unqueuedDelayedPollEnabled}" interval="900"
requestDelay="50" />
+ </h:form>
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-scripted.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-scripted.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-scripted.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-scripted.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,35 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jstl/core">
+ <head>
+ <title></title>
+ </head>
+ <body>
+ <f:view>
+ <a4j:status startText="...running..." stopText="stopped"
startStyle="color: green" />
+
+ <a4j:status id="queueStatus" forceId="true"
onstart="window.startStatusTime = Timer.currentTime;"
+ onstop="statusData.push([window.startStatusTime, Timer.currentTime]);
window.startStatusTime = undefined;" />
+
+ <a4j:queue name="queueDefaults" />
+
+ <a4j:queue name="queueRequestDelay" requestDelay="15" />
+
+ <a4j:queue name="queueTimeout" timeout="5000" />
+
+ <script type="text/javascript">
+ //LOG.LEVEL = LOG.ALL;
+ window.queueIgnoreDupResponsesTest = new Array();
+ window.statusData = new Array();
+ </script>
+
+ <a4j:queue status="queueStatus" name="queueIgnoreDupResponses"
ignoreDupResponses="true" oncomplete="queueIgnoreDupResponsesTest.push(data
+ ':' + Timer.currentTime)" />
+
+ <a4j:queue name="testQueue" />
+
+ </f:view>
+ </body>
+</html>
Copied:
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-similarity.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-similarity.xhtml)
===================================================================
---
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-similarity.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-similarity.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,50 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j"
+
xmlns:c="http://java.sun.com/jstl/core">
+ <body>
+ <f:view>
+ <h:form id="form">
+ <a4j:queue name="queue" />
+
+ <a4j:commandButton requestDelay="400" value="Button 1"
id="button1" eventsQueue="queue"
+ similarityGroupingId="buttons" />
+
+ <a4j:commandButton requestDelay="400" value="Button 2"
id="button2" eventsQueue="queue"
+ similarityGroupingId="buttons" />
+
+ <a4j:commandButton value="Button 3" requestDelay="500"
id="button3" eventsQueue="queue" />
+ <a4j:commandButton value="Button 4" requestDelay="500"
id="button4" eventsQueue="queue" />
+
+ </h:form>
+
+ <h:form id="dropNext">
+ <a4j:queue name="dropNextQueue" size="3"
sizeExceededBehavior="dropNext" />
+
+ <a4j:commandButton value="Button 1" requestDelay="500"
id="button1" eventsQueue="dropNextQueue" />
+ <a4j:commandButton value="Button 2" requestDelay="500"
id="button2" eventsQueue="dropNextQueue" />
+ </h:form>
+ <h:form id="dropNew">
+ <a4j:queue name="dropNewQueue" size="3"
sizeExceededBehavior="dropNew" />
+
+ <a4j:commandButton value="Button 1" requestDelay="500"
id="button1" eventsQueue="dropNewQueue" />
+ <a4j:commandButton value="Button 2" requestDelay="500"
id="button2" eventsQueue="dropNewQueue" />
+ </h:form>
+ <h:form id="fireNext">
+ <a4j:queue name="fireNextQueue" size="3"
sizeExceededBehavior="fireNext" />
+
+ <a4j:commandButton value="Button 1" requestDelay="500"
id="button1" eventsQueue="fireNextQueue" />
+ <a4j:commandButton value="Button 2" requestDelay="500"
id="button2" eventsQueue="fireNextQueue" />
+ </h:form>
+ <h:form id="fireNew">
+ <a4j:queue name="fireNewQueue" size="3"
sizeExceededBehavior="fireNew" />
+
+ <a4j:commandButton value="Button 1" requestDelay="500"
id="button1" eventsQueue="fireNewQueue" />
+ <a4j:commandButton value="Button 2" requestDelay="500"
id="button2" eventsQueue="fireNewQueue" />
+ </h:form>
+
+ </f:view>
+ </body>
+</html>
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-size.xhtml
(from rev 14238,
trunk/ui/core/src/test/resources/org/ajax4jsf/component/queue-size.xhtml)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-size.xhtml
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/queue-size.xhtml 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,56 @@
+<html
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:a4j="http://richfaces.org/a4j">
+ <body>
+ <f:view>
+ <a4j:queue name="defaultSizeQueue" />
+
+ <a4j:queue name="dropNextQueue" sizeExceededBehavior="dropNext"
size="3" />
+ <a4j:queue name="dropNextQueueSingle"
sizeExceededBehavior="dropNext" size="1" />
+
+ <a4j:queue name="fireNextQueue" sizeExceededBehavior="fireNext"
size="3" />
+ <a4j:queue name="fireNextQueueSingle"
sizeExceededBehavior="fireNext" size="1" />
+
+ <a4j:queue name="dropNewQueue" sizeExceededBehavior="dropNew"
size="3" />
+ <a4j:queue name="dropNewQueueSingle"
sizeExceededBehavior="dropNew" size="1" />
+
+ <a4j:queue name="fireNewQueue" sizeExceededBehavior="fireNew"
size="3" />
+ <a4j:queue name="fireNewQueueSingle"
sizeExceededBehavior="fireNew" size="1" />
+
+ <script type="text/javascript">
+ defaultExceededQueueResults = new Array();
+
+ function addEventData(queue, query, options, event) {
+ if (!queue) {
+ throw "queue not defined";
+ }
+ if (!query) {
+ throw "query not defined";
+ }
+ if (!options) {
+ throw "options not defined";
+ }
+ if (!event) {
+ throw "event not defined";
+ }
+
+ defaultExceededQueueResults.push({queue: queue, query: query, options: options,
event: event, _time: Timer.currentTime});
+ }
+
+ defaultSingleSizedQueueResults = new Array();
+ </script>
+
+ <a4j:queue onsizeexceeded="addEventData(this, query, options, event)"
size="2" name="defaultExceededQueue" />
+ <h:form id="form">
+ <a4j:commandButton id="button0"
eventsQueue="defaultExceededQueue" value="button" />
+ <a4j:commandButton id="button1"
eventsQueue="defaultExceededQueue" value="button" />
+ <a4j:commandButton id="button2"
eventsQueue="defaultExceededQueue" value="button" />
+ <a4j:commandButton id="button3"
eventsQueue="defaultExceededQueue" value="button" />
+ </h:form>
+
+ <a4j:queue name="singleSizedDefaultQueue" size="1"
ignoreDupResponses="true"
oncomplete="defaultSingleSizedQueueResults.push(data)" />
+ </f:view>
+ </body>
+</html>
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/root (from rev
14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/root)
===================================================================
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/simulation.js
(from rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/simulation.js)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/simulation.js
(rev 0)
+++
branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/simulation.js 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,217 @@
+LOG.LEVEL = LOG.INFO;
+LOG._logToConsole = function(message, level) {
+ //TODO deal with this nasty message
+ if (message != "No information in response about elements to replace") {
+ LOG.out.println(level.name + ': ' + message)
+ }
+};
+
+var Timer = {
+
+ _eventCounter: 0,
+
+ currentTime: 0,
+
+ maxTime: 10000000,
+
+ events: new Array(),
+
+ addEventToTimer: function(callback, delay) {
+ var eventTime = this.currentTime + delay;
+
+ var i = 0;
+
+ while (this.events[i] && (this.events[i].eventTime <= eventTime)) {
+ i++;
+ }
+
+ var eventId = this._eventCounter++;
+
+ this.events.splice(i, 0, {eventTime: eventTime, callback: callback, eventId:
eventId});
+
+ return eventId;
+ },
+
+ removeEventFromTimer: function(eventId) {
+ for ( var i = 0; i < this.events.length; i++) {
+ if (this.events[i].eventId == eventId) {
+ this.events.splice(i, 1);
+
+ break;
+ }
+ }
+ },
+
+ execute: function() {
+ while (this.events.length > 0) {
+
+ var eventData = this.events.shift();
+
+ this.currentTime = eventData.eventTime;
+ if (this.currentTime > this.maxTime) {
+ throw "Maximum execution time reached, aborting timer";
+ }
+
+ try {
+
+ eventData.callback();
+ } catch (e) {
+ alert(e.message);
+ }
+ }
+ },
+
+ isEmpty: function() {
+ return this.events.length == 0;
+ }
+};
+
+window.setTimeout = function(callback, delay) {
+ return Timer.addEventToTimer(callback, delay);
+}
+
+window.clearTimeout = function(timerId) {
+ Timer.removeEventFromTimer(timerId);
+}
+
+var SimulationContext = function(submitFunction) {
+ this.results = new Array();
+
+ this.submitFunction = submitFunction;
+};
+
+SimulationContext.prototype.ajax = function() {
+ var args = new Array();
+ for (var i = 1; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ }
+ var _this = this;
+
+ Timer.addEventToTimer(function() {
+ _this.submitFunction.apply(this, args);
+ }, arguments[0]);
+};
+
+SimulationContext.prototype.executeOnTime = function(time, code) {
+ Timer.addEventToTimer(function() {
+ code();
+ }, time);
+};
+
+window.simulationContext = undefined;
+
+window.XMLHttpRequest = function() {
+ this.requestTime = XMLHttpRequest.requestTime || 0;
+ this.data = XMLHttpRequest.data;
+
+ this.responseText = null;
+ this.responseXML = null;
+
+ this.readyState = 0;
+}
+
+window.XMLHttpRequest.UNSENT = 0;
+window.XMLHttpRequest.OPENED = 1;
+window.XMLHttpRequest.HEADERS_RECEIVED = 2;
+window.XMLHttpRequest.LOADING = 3;
+window.XMLHttpRequest.DONE = 4;
+
+XMLHttpRequest.prototype.abort = function() {
+ if (this.timerId) {
+ clearTimeout(this.timerId);
+ }
+
+ window.simulationContext.results[this.requestId].endTime = Timer.currentTime;
+ window.simulationContext.results[this.requestId].aborted = true;
+};
+
+XMLHttpRequest.prototype.getAllResponseHeaders = function() {
+ return "";
+};
+XMLHttpRequest.prototype.getResponseHeader = function(name) {
+ if ("Ajax-Response" == name) {
+ return "true";
+ }
+
+ return "";
+};
+XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
+ this.readyState = XMLHttpRequest.OPENED;
+};
+
+XMLHttpRequest.prototype.send = function(contentType) {
+ var length = window.simulationContext.results.push({data: this.data, startTime:
Timer.currentTime});
+ this.requestId = length - 1;
+
+ var _this = this;
+ this.timerId = setTimeout(function() {
+ _this.status = 200;
+ _this.statusText = "Success";
+ _this.readyState = window.XMLHttpRequest.DONE;
+
+ var responseTextArray = new Array();
+ responseTextArray.push("<html><head></head><body>");
+ if (_this.data) {
+
+ responseTextArray.push("<span id='_ajax:data'>");
+ if (typeof _this.data == 'string') {
+ responseTextArray.push("'");
+ responseTextArray.push(_this.data);
+ responseTextArray.push("'");
+ } else {
+ responseTextArray.push(_this.data);
+ }
+ responseTextArray.push("</span>");
+ }
+ responseTextArray.push("</body></html>");
+
+ _this.responseText = responseTextArray.join('');
+
+ var doc = new ActiveXObject("MSXML.DOMDocument");
+ doc.loadXML(_this.responseText);
+
+ //hack to make it work with current HTMLUnit
+ delete doc.getElementById;
+ doc.getElementById = function(id){
+ var nodes = this.selectNodes("//*");
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].getAttribute("id") == id) {
+ return nodes[i];
+ }
+ }
+ };
+
+ _this.responseXML = doc;
+
+ window.simulationContext.results[_this.requestId].endTime = Timer.currentTime;
+ _this.onreadystatechange();
+ }, this.requestTime);
+};
+
+XMLHttpRequest.prototype.setRequestHeader = function(name, value) {
+
+};
+
+var oldSubmitQuery = A4J.AJAX.SubmitQuery;
+
+var DEFAULT_REQUEST_TIME;
+
+A4J.AJAX.SubmitQuery = function(query, options, event) {
+ var defaultRequestTime = XMLHttpRequest.defaultRequestTime;
+ if (typeof defaultRequestTime == "function") {
+ defaultRequestTime = defaultRequestTime(query, options, event);
+ }
+
+ XMLHttpRequest.requestTime = options.requestTime || defaultRequestTime ||
DEFAULT_REQUEST_TIME;
+ XMLHttpRequest.data = options.data || (event && event.srcElement.id) ||
options.pollId;
+
+ try {
+ var req = oldSubmitQuery.apply(this, arguments);
+
+ return req;
+ } finally {
+ XMLHttpRequest.requestTime = undefined;
+ XMLHttpRequest.data = undefined;
+ }
+}
+
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.js (from
rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/user.js)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.js
(rev 0)
+++ branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.js 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1 @@
+/* dependency of org.ajax4jsf.component.LoadResourceComponentTest */
\ No newline at end of file
Copied: branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.xcss (from
rev 14238, trunk/ui/core/src/test/resources/org/ajax4jsf/component/user.xcss)
===================================================================
--- branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.xcss
(rev 0)
+++ branches/jsf2.0/ui/core/src/test/resources/org/ajax4jsf/component/user.xcss 2009-07-10
11:13:58 UTC (rev 14876)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<f:template
xmlns:f='http:/jsf.exadel.com/template'
+
xmlns:u='http:/jsf.exadel.com/template/util'
+
xmlns="http://www.w3.org/1999/xhtml">
+
+ <!-- dependency of org.ajax4jsf.component.LoadResourceComponentTest -->
+
+</f:template>
\ No newline at end of file
Modified: branches/jsf2.0/ui/pom.xml
===================================================================
--- branches/jsf2.0/ui/pom.xml 2009-07-10 11:04:14 UTC (rev 14875)
+++ branches/jsf2.0/ui/pom.xml 2009-07-10 11:13:58 UTC (rev 14876)
@@ -1,11 +1,12 @@
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
+ <!--parent>
<artifactId>root</artifactId>
<groupId>org.richfaces</groupId>
<version>4.0.0-SNAPSHOT</version>
- </parent>
+ </parent-->
<modelVersion>4.0.0</modelVersion>
<groupId>org.richfaces</groupId>
+ <version>4.0.0-SNAPSHOT</version>
<artifactId>ui</artifactId>
<packaging>pom</packaging>
<name>RichFaces Components</name>
@@ -122,16 +123,16 @@
</dependency>
<dependency>
<groupId>org.richfaces.framework</groupId>
- <artifactId>richfaces-test</artifactId>
+ <artifactId>richfaces-test-base</artifactId>
<version>4.0.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
<optional>true</optional>
- </dependency>
+ </dependency-->
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
@@ -164,7 +165,7 @@
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
- <artifactId>mojarra-jsf-api</artifactId>
+ <artifactId>jsf-api</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>