JBoss Rich Faces SVN: r20424 - in modules/docs/trunk: Component_Reference/src/main/docbook/en-US and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2010-12-06 21:12:48 -0500 (Mon, 06 Dec 2010)
New Revision: 20424
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtoolbarGroup-richtoolbarGroup.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richtoolbarGroup-richtoolbarGroup.png
Modified:
modules/docs/trunk/Component_Development_Kit_Guide/src/main/docbook/en-US/Component_Development_Kit_Guide.xml
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
Log:
Added rich:toolbarGroup
Modified: modules/docs/trunk/Component_Development_Kit_Guide/src/main/docbook/en-US/Component_Development_Kit_Guide.xml
===================================================================
--- modules/docs/trunk/Component_Development_Kit_Guide/src/main/docbook/en-US/Component_Development_Kit_Guide.xml 2010-12-06 20:34:27 UTC (rev 20423)
+++ modules/docs/trunk/Component_Development_Kit_Guide/src/main/docbook/en-US/Component_Development_Kit_Guide.xml 2010-12-07 02:12:48 UTC (rev 20424)
@@ -13,6 +13,6 @@
<xi:include href="Creating_components_in_other_environments.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
<xi:include href="Naming_conventions.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
<xi:include href="Template_tags_reference.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
- <xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>
+ <!--<xi:include href="Revision_History.xml" xmlns:xi="http://www.w3.org/2001/XInclude"></xi:include>-->
</book>
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2010-12-06 20:34:27 UTC (rev 20423)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2010-12-07 02:12:48 UTC (rev 20424)
@@ -387,6 +387,40 @@
The <sgmltag><rich:toolbarGroup></sgmltag> component is a child component of the <sgmltag><rich:toolbar></sgmltag> component. The <sgmltag><rich:toolbarGroup></sgmltag> component is used to group a number of items together on a toolbar.
</para>
+ <section id="sect-Component_Reference-richtoolbarGroup-Basic_usage">
+ <title>Basic usage</title>
+ <para>
+ Like the <sgmltag><rich:toolbar></sgmltag> parent component, the <sgmltag><rich:toolbarGroup></sgmltag> component does not require any extra attributes for basic functionality. Add child components to the <sgmltag><rich:toolbarGroup></sgmltag> component to have them appear grouped on the parent toolbar when rendered.
+ </para>
+ </section>
+
+ <section id="sect-Component_Reference-richtoolbarGroup-Appearance">
+ <title>Appearance</title>
+ <para>
+ Similar to the <sgmltag><rich:toolbar></sgmltag> component, items within a <sgmltag><rich:toolbarGroup></sgmltag> can be separated by specifying the <varname>itemSeparator</varname> attribute. Refer to <xref linkend="sect-Component_Reference-richtoolbar-Appearance" /> for details on using the <varname>itemSeparator</varname> attribute.
+ </para>
+ <para>
+ Groups of toolbar items can be located on either the left-hand side or the right-hand side of the parent toolbar. By default, they appear to the left. To locate the toolbar group to the right of the parent toolbar, set <code>location="right"</code>.
+ </para>
+ <example id="exam-Component_Reference-richtoolbarGroup-richtoolbarGroup">
+ <title><sgmltag><rich:toolbarGroup></sgmltag></title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtoolbarGroup-richtoolbarGroup.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <para>
+ The example shows how to locate a toolbar group to the right-hand side of the parent toolbar. It also demonstrates how item separators on the parent toolbar work with toolbar groups.
+ </para>
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="images/figu-Component_Reference-richtoolbarGroup-richtoolbarGroup.png" format="PNG" />
+ </imageobject>
+ <textobject>
+ <para>
+ A toolbar using icons. Two toolbar groups are located on the left-hand side of the toolbar and separated by a grid pattern. The third toolbar group is located to the right-hand side.
+ </para>
+ </textobject>
+ </mediaobject>
+ </example>
+ </section>
+
<section id="sect-Component_Reference-richtoolbarGroup-Reference_data">
<title>Reference data</title>
<itemizedlist>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtoolbarGroup-richtoolbarGroup.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtoolbarGroup-richtoolbarGroup.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtoolbarGroup-richtoolbarGroup.xml_sample 2010-12-07 02:12:48 UTC (rev 20424)
@@ -0,0 +1,16 @@
+<rich:toolBar height="26" itemSeparator="grid">
+ <rich:toolBarGroup>
+ <h:graphicImage value="/images/icons/create_doc.gif"/>
+ <h:graphicImage value="/images/icons/create_folder.gif"/>
+ <h:graphicImage value="/images/icons/copy.gif"/>
+ </rich:toolBarGroup>
+ <rich:toolBarGroup>
+ <h:graphicImage value="/images/icons/save.gif"/>
+ <h:graphicImage value="/images/icons/save_as.gif"/>
+ <h:graphicImage value="/images/icons/save_all.gif"/>
+ </rich:toolBarGroup>
+ <rich:toolBarGroup location="right">
+ <h:graphicImage value="/images/icons/find.gif"/>
+ <h:graphicImage value="/images/icons/filter.gif"/>
+ </rich:toolBarGroup>
+</rich:toolBar>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richtoolbarGroup-richtoolbarGroup.png
===================================================================
(Binary files differ)
Property changes on: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/figu-Component_Reference-richtoolbarGroup-richtoolbarGroup.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 1 month
JBoss Rich Faces SVN: r20423 - in trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk: naming and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-06 15:34:27 -0500 (Mon, 06 Dec 2010)
New Revision: 20423
Added:
trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/FileNameMapping.java
Modified:
trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java
trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
Log:
maven-resources-plugin:
- file name mappings are now applied in the same order as they are defined in pom.xml
Added: trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/FileNameMapping.java
===================================================================
--- trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/FileNameMapping.java (rev 0)
+++ trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/FileNameMapping.java 2010-12-06 20:34:27 UTC (rev 20423)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.cdk;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class FileNameMapping {
+
+ private String name;
+
+ private String value;
+
+ private Pattern namePattern = null;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public Pattern getNamePattern() {
+ if (namePattern == null) {
+ namePattern = Pattern.compile(name);
+ }
+
+ return namePattern;
+ }
+}
Modified: trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java
===================================================================
--- trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-12-06 19:22:19 UTC (rev 20422)
+++ trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/ProcessMojo.java 2010-12-06 20:34:27 UTC (rev 20423)
@@ -36,7 +36,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Locale;
-import java.util.Properties;
import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -79,7 +78,6 @@
import com.google.common.base.Predicates;
import com.google.common.collect.Constraints;
import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
* @goal process
@@ -151,7 +149,7 @@
* @parameter
*/
// TODO review usage of properties?
- private Properties fileNameMappings = new Properties();
+ private FileNameMapping[] fileNameMappings = new FileNameMapping[0];
/**
* @parameter
@@ -286,7 +284,7 @@
ResourceHandler resourceHandler = new DynamicResourceHandler(staticResourceHandler, resourceFactory);
// TODO set webroot
- faces = new FacesImpl(null, new FileNameMapperImpl(Maps.fromProperties(fileNameMappings)), resourceHandler);
+ faces = new FacesImpl(null, new FileNameMapperImpl(fileNameMappings), resourceHandler);
faces.start();
ResourceWriterImpl resourceWriter = new ResourceWriterImpl(resourceOutputDir, resourceMappingDir, resourceProcessors);
Modified: trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java
===================================================================
--- trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-12-06 19:22:19 UTC (rev 20422)
+++ trunk/cdk/maven-resources-plugin/src/main/java/org/richfaces/cdk/naming/FileNameMapperImpl.java 2010-12-06 20:34:27 UTC (rev 20423)
@@ -21,73 +21,34 @@
*/
package org.richfaces.cdk.naming;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.richfaces.cdk.FileNameMapper;
+import org.richfaces.cdk.FileNameMapping;
-import com.google.common.collect.Lists;
-
/**
* @author Nick Belaevski
*
*/
public class FileNameMapperImpl implements FileNameMapper {
- private static final class Mapping {
+ private FileNameMapping[] fileNameMappings;
- private Pattern pattern;
-
- private String replacement;
-
- public Mapping(Pattern pattern, String replacement) {
- super();
- this.pattern = pattern;
- this.replacement = replacement;
- }
-
- public Pattern getPattern() {
- return pattern;
- }
-
- public String getReplacement() {
- return replacement;
- }
- }
-
- private List<Mapping> fileNameMappings;
-
- public FileNameMapperImpl(Map<String, String> fileNameMappings) {
+ public FileNameMapperImpl(FileNameMapping[] fileNameMappings) {
super();
- this.fileNameMappings = compileMappings(fileNameMappings);
+ this.fileNameMappings = fileNameMappings;
}
- private static List<Mapping> compileMappings(Map<String, String> mappings) {
- List<Mapping> result = Lists.newArrayList();
-
- for (Entry<String, String> entry: mappings.entrySet()) {
- Pattern pattern = Pattern.compile((String) entry.getKey());
- String replacement = entry.getValue();
-
- result.add(new Mapping(pattern, replacement));
- }
-
- return result;
- }
-
@Override
public String createName(String resourcePath) {
if (resourcePath == null) {
return resourcePath;
}
- for (Mapping mapping : fileNameMappings) {
- Matcher matcher = mapping.getPattern().matcher(resourcePath);
+ for (FileNameMapping mapping : fileNameMappings) {
+ Matcher matcher = mapping.getNamePattern().matcher(resourcePath);
if (matcher.find()) {
- return matcher.replaceAll(mapping.getReplacement());
+ return matcher.replaceAll(mapping.getValue());
}
}
14 years, 1 month
JBoss Rich Faces SVN: r20422 - in trunk/ui/output/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2010-12-06 14:22:19 -0500 (Mon, 06 Dec 2010)
New Revision: 20422
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js
Log:
https://jira.jboss.org/browse/RF-9882
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-12-06 19:13:42 UTC (rev 20421)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ProgressBarBaseRenderer.java 2010-12-06 19:22:19 UTC (rev 20422)
@@ -110,9 +110,9 @@
ProgressBarState result;
- if (value.doubleValue() <= minValue.doubleValue()) {
+ if (value.doubleValue() < minValue.doubleValue()) {
result = ProgressBarState.initialState;
- } else if (value.doubleValue() > maxValue.doubleValue()) {
+ } else if (value.doubleValue() >= maxValue.doubleValue()) {
result = ProgressBarState.finishState;
} else {
result = ProgressBarState.progressState;
Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js 2010-12-06 19:13:42 UTC (rev 20421)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/progressBar.js 2010-12-06 19:22:19 UTC (rev 20422)
@@ -46,7 +46,7 @@
name: "ProgressBar",
__isInitialState: function() {
- return parseFloat(this.value) <= parseFloat(this.getMinValue());
+ return parseFloat(this.value) < parseFloat(this.getMinValue());
},
__isProgressState: function() {
@@ -54,7 +54,7 @@
},
__isFinishState: function() {
- return parseFloat(this.value) > parseFloat(this.getMaxValue());
+ return parseFloat(this.value) >= parseFloat(this.getMaxValue());
},
__beforeUpdate: function(event) {
@@ -120,7 +120,7 @@
__setValue: function(val, initialStateSetup) {
this.value = parseFloat(this.__getPropertyOrObject(val, "value"));
- if (this.__isFinishState()) {
+ if (this.__isFinishState() || this.__isInitialState()) {
this.disable();
}
},
14 years, 1 month
JBoss Rich Faces SVN: r20421 - in modules/tests/metamer/trunk/application/src/main: webapp/components/richPanelMenu and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2010-12-06 14:13:42 -0500 (Mon, 06 Dec 2010)
New Revision: 20421
Modified:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichPanelMenuBean.java
modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenu/simple.xhtml
Log:
https://jira.jboss.org/browse/RF-9468
* sample for rich:panelMenu fixed
Modified: modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichPanelMenuBean.java
===================================================================
--- modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichPanelMenuBean.java 2010-12-06 19:04:32 UTC (rev 20420)
+++ modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichPanelMenuBean.java 2010-12-06 19:13:42 UTC (rev 20421)
@@ -27,6 +27,7 @@
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.richfaces.component.UIPanelMenu;
+import org.richfaces.event.ItemChangeEvent;
import org.richfaces.tests.metamer.Attributes;
import org.slf4j.Logger;
@@ -78,4 +79,15 @@
public void setAttributes(Attributes attributes) {
this.attributes = attributes;
}
+
+ /**
+ * An item change listener that logs to the page old and new value.
+ *
+ * @param event
+ * an event representing the activation of a user interface component
+ */
+ public void itemChangeListener(ItemChangeEvent event) {
+ attributes.get("activeItem").setValue(event.getNewItem());
+ RichBean.logToPage("* item changed: " + event.getOldItem() + " -> " + event.getNewItem());
+ }
}
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenu/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenu/simple.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richPanelMenu/simple.xhtml 2010-12-06 19:13:42 UTC (rev 20421)
@@ -62,7 +62,7 @@
groupExpandIconRight="#{richPanelMenuBean.attributes['groupExpandIconRight'].value}"
groupMode="#{richPanelMenuBean.attributes['groupMode'].value}"
immediate="#{richPanelMenuBean.attributes['immediate'].value}"
- itemChangeListener="#{richBean.itemChangeListener}"
+ itemChangeListener="#{richPanelMenuBean.itemChangeListener}"
itemClass="#{richPanelMenuBean.attributes['topItemClass'].value}"
itemDisableClass="#{richPanelMenuBean.attributes['topItemDisableClass'].value}"
itemDisableIconLeft="#{richPanelMenuBean.attributes['topItemDisableIconLeft'].value}"
@@ -99,69 +99,45 @@
topItemIconRight="#{richPanelMenuBean.attributes['topItemDisableIconRight'].value}"
width="#{richPanelMenuBean.attributes['width'].value}"
>
- <rich:panelMenuGroup id="group1" label="Group 1">
- <rich:panelMenuItem id="item11" label="Item 1.1">
- <f:param name="current" value="Item 1.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item12" label="Item 1.2">
- <f:param name="current" value="Item 1.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item13" label="Item 1.3">
- <f:param name="current" value="Item 1.3" />
- </rich:panelMenuItem>
+
+ <rich:panelMenuGroup id="group1" name="group1" label="Group 1">
+ <rich:panelMenuItem id="item11" name="item11" label="Item 1.1"/>
+ <rich:panelMenuItem id="item12" name="item12" label="Item 1.2"/>
+ <rich:panelMenuItem id="item13" name="item13" label="Item 1.3"/>
</rich:panelMenuGroup>
- <rich:panelMenuGroup id="group2" label="Group 2">
- <rich:panelMenuItem id="item21" label="Item 2.1">
- <f:param name="current" value="Item 2.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item22" label="Item 2.2">
- <f:param name="current" value="Item 2.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item23" label="Item 2.3">
- <f:param name="current" value="Item 2.3" />
- </rich:panelMenuItem>
- <rich:panelMenuGroup id="group24" label="Group 2.4">
- <rich:panelMenuItem id="item241" label="Item 2.4.1">
- <f:param name="current" value="Item 2.4.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item242" label="Item 2.4.2">
- <f:param name="current" value="Item 2.4.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item243" label="Item 2.4.3">
- <f:param name="current" value="Item 2.4.3" />
- </rich:panelMenuItem>
+
+ <rich:panelMenuGroup id="group2" name="group2" label="Group 2">
+ <rich:panelMenuItem id="item21" name="item21" label="Item 2.1"/>
+ <rich:panelMenuItem id="item22" name="item22" label="Item 2.2"/>
+ <rich:panelMenuItem id="item23" name="item23" label="Item 2.3"/>
+
+ <rich:panelMenuGroup id="group24" name="group24" label="Group 2.4">
+ <rich:panelMenuItem id="item241" name="item241" label="Item 2.4.1"/>
+ <rich:panelMenuItem id="item242" name="item242" label="Item 2.4.2"/>
+ <rich:panelMenuItem id="item243" name="item243" label="Item 2.4.3"/>
</rich:panelMenuGroup>
- <rich:panelMenuItem id="item25" label="Item 2.5" disabled="true">
- <f:param name="current" value="Item 2.5" />
- </rich:panelMenuItem>
- <rich:panelMenuGroup id="group26" label="Group 2.6" disabled="true">
- <rich:panelMenuItem id="item261" label="Item 2.6.1">
- <f:param name="current" value="Item 2.6.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item262" label="Item 2.6.2">
- <f:param name="current" value="Item 2.6.2" />
- </rich:panelMenuItem>
+
+ <rich:panelMenuItem id="item25" name="item25" disabled="true" label="Item 2.5"/>
+
+ <rich:panelMenuGroup id="group26" name="group26" label="Group 2.6" disabled="true">
+ <rich:panelMenuItem id="item261" name="item261" label="Item 2.6.1"/>
+ <rich:panelMenuItem id="item262" name="item262" label="Item 2.6.2"/>
+ <rich:panelMenuItem id="item263" name="item263" label="Item 2.6.3"/>
</rich:panelMenuGroup>
</rich:panelMenuGroup>
- <rich:panelMenuGroup id="group3" label="Group 3">
- <rich:panelMenuItem id="item31" label="Item 3.1">
- <f:param name="current" value="Item 3.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item32" label="Item 3.2">
- <f:param name="current" value="Item 3.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item33" label="Item 3.3">
- <f:param name="current" value="Item 3.3" />
- </rich:panelMenuItem>
+
+ <rich:panelMenuGroup id="group3" name="group3" label="Group 3">
+ <rich:panelMenuItem id="item31" name="item31" label="Item 3.1"/>
+ <rich:panelMenuItem id="item32" name="item32" label="Item 3.2"/>
+ <rich:panelMenuItem id="item33" name="item33" label="Item 3.3"/>
</rich:panelMenuGroup>
- <rich:panelMenuGroup id="group4" label="Group 4" disabled="true">
- <rich:panelMenuItem id="item41" label="Item 4.1">
- <f:param name="current" value="Item 4.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem id="item42" label="Item 4.2">
- <f:param name="current" value="Item 4.2" />
- </rich:panelMenuItem>
+
+ <rich:panelMenuGroup id="group4" name="group4" label="Group 4" disabled="true">
+ <rich:panelMenuItem id="item41" name="item41" label="Item 4.1"/>
+ <rich:panelMenuItem id="item42" name="item42" label="Item 4.2"/>
+ <rich:panelMenuItem id="item43" name="item43" label="Item 4.3"/>
</rich:panelMenuGroup>
+
</rich:panelMenu>
<br/><br/>
14 years, 1 month
JBoss Rich Faces SVN: r20420 - in branches/RF-8742-1: examples/input-demo and 29 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-12-06 14:04:32 -0500 (Mon, 06 Dec 2010)
New Revision: 20420
Added:
branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java
branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/fileupload.xhtml
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/loading.gif
branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java
branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif
branches/RF-8742-1/ui/input/ui/src/main/templates/fileupload.template.xml
branches/RF-8742-1/ui/misc/ui/src/main/java/org/richfaces/view/
Removed:
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java
branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java
Modified:
branches/RF-8742-1/
branches/RF-8742-1/examples/input-demo/pom.xml
branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml
branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/web.xml
branches/RF-8742-1/examples/input-demo/src/main/webapp/templates/template.xhtml
branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
branches/RF-8742-1/ui/dist/richfaces-components-api/pom.xml
branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml
branches/RF-8742-1/ui/misc/pom.xml
Log:
Merged revisions 20379-20384,20386,20388-20389,20391-20394,20403-20407,20409-20410,20419 via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
.......
r20379 | konstantin.mishin | 2010-12-03 10:53:03 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20380 | konstantin.mishin | 2010-12-03 11:40:33 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20381 | konstantin.mishin | 2010-12-03 11:42:01 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20382 | konstantin.mishin | 2010-12-03 11:45:31 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20383 | konstantin.mishin | 2010-12-03 11:56:08 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20384 | konstantin.mishin | 2010-12-03 12:00:01 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20386 | konstantin.mishin | 2010-12-03 12:08:40 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20388 | nbelaevski | 2010-12-03 12:34:04 -0800 (Fri, 03 Dec 2010) | 6 lines
https://jira.jboss.org/browse/RF-9838
- IE7:
-- visual fixes
-- selection was not submitted correctly
- Improved trees & queues compatibility
- Default treeNode was not working
.......
r20389 | konstantin.mishin | 2010-12-03 12:41:52 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20391 | konstantin.mishin | 2010-12-03 12:45:51 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20392 | konstantin.mishin | 2010-12-03 12:46:13 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20393 | nbelaevski | 2010-12-03 14:04:14 -0800 (Fri, 03 Dec 2010) | 1 line
https://jira.jboss.org/browse/RF-9828
.......
r20394 | konstantin.mishin | 2010-12-03 16:50:27 -0800 (Fri, 03 Dec 2010) | 1 line
RF-9921
.......
r20403 | konstantin.mishin | 2010-12-06 05:17:22 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9921
.......
r20404 | ilya_shaikovsky | 2010-12-06 06:11:23 -0800 (Mon, 06 Dec 2010) | 1 line
style correction for tree adaptors demo.
.......
r20405 | ilya_shaikovsky | 2010-12-06 07:27:17 -0800 (Mon, 06 Dec 2010) | 1 line
panelMenu samples finished.
.......
r20406 | konstantin.mishin | 2010-12-06 07:35:45 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9927
.......
r20407 | konstantin.mishin | 2010-12-06 07:40:46 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9927
.......
r20409 | konstantin.mishin | 2010-12-06 07:49:25 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9927
.......
r20410 | konstantin.mishin | 2010-12-06 07:52:12 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9927
.......
r20419 | konstantin.mishin | 2010-12-06 10:16:22 -0800 (Mon, 06 Dec 2010) | 1 line
RF-9497
.......
Property changes on: branches/RF-8742-1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-20377
+ /trunk:1-20419
Modified: branches/RF-8742-1/examples/input-demo/pom.xml
===================================================================
--- branches/RF-8742-1/examples/input-demo/pom.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/input-demo/pom.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -108,6 +108,10 @@
<artifactId>richfaces-ui-input-ui</artifactId>
</dependency>
<dependency>
+ <groupId>org.richfaces.ui.output</groupId>
+ <artifactId>richfaces-ui-output-ui</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.richfaces.ui.core</groupId>
<artifactId>richfaces-ui-core-ui</artifactId>
</dependency>
Copied: branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java (from rev 20419, trunk/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java)
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java (rev 0)
+++ branches/RF-8742-1/examples/input-demo/src/main/java/org/richfaces/demo/FileUploadBean.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.demo;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.SessionScoped;
+import javax.faces.component.UIComponent;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.AjaxBehaviorEvent;
+
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@ManagedBean
+@SessionScoped
+public class FileUploadBean {
+
+ private String acceptedTypes;
+ private boolean enabled = true;
+ private boolean noDuplicate = false;
+ private UploadItem item;
+
+ public UploadItem getItem() {
+ return item;
+ }
+
+// public void paint(OutputStream stream, Object object) throws IOException {
+// stream.write(item.getData());
+// }
+
+ public void listener(UploadEvent event) throws Exception {
+ item = event.getUploadItem();
+ if (item != null) {
+ item.getFile().delete();
+ }
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setNoDuplicate(boolean noDuplicate) {
+ this.noDuplicate = noDuplicate;
+ }
+
+ public boolean isNoDuplicate() {
+ return noDuplicate;
+ }
+
+ public void setAcceptedTypes(String acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+
+ public String getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void updateAttribute(AjaxBehaviorEvent event) throws AbortProcessingException {
+ UIComponent component = (UIComponent) event.getSource();
+ String attributeName = (String) component.findComponent("name").getAttributes().get("value");
+ Object attributeValue = component.findComponent("value").getAttributes().get("value");
+ component.findComponent("fu").getAttributes().put(attributeName, attributeValue);
+ }
+}
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -31,6 +31,10 @@
<from-outcome>calendar</from-outcome>
<to-view-id>/examples/calendar.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>fileUpload</from-outcome>
+ <to-view-id>/examples/fileupload.xhtml</to-view-id>
+ </navigation-case>
<!-- QUnit -->
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/input-demo/src/main/webapp/WEB-INF/web.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -39,6 +39,10 @@
<display-name></display-name>
<description></description>
<context-param>
+ <param-name>org.richfaces.fileUpload.maxRequestSize</param-name>
+ <param-value>268435456</param-value>
+ </context-param>
+ <context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>#{skinBean.skin}</param-value>
</context-param>
Copied: branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/fileupload.xhtml (from rev 20419, trunk/examples/input-demo/src/main/webapp/examples/fileupload.xhtml)
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/fileupload.xhtml (rev 0)
+++ branches/RF-8742-1/examples/input-demo/src/main/webapp/examples/fileupload.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,101 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns: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:fu="http://richfaces.org/input">
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+ <h:head>
+ <title>Richfaces FileUpload Demo</title>
+ <style>
+ <!--
+ .fu .rf-fu-lst {
+ height: 500px;
+ }
+ -->
+ </style>
+ </h:head>
+ <h:body>
+ <h:form id="form">
+ <h:outputText value="Skin: "/>
+ <h:selectOneMenu value="#{skinBean.skin}" onchange="submit();">
+ <f:selectItems value="#{skinBean.skins}"/>
+ </h:selectOneMenu>
+ <br />
+ <script type="text/javascript">
+ <!--
+ var onfilesubmit = function (event) {
+ var data = event.rf.data;
+ RichFaces.log.info(jQuery("<span><b>onfilesubmit: </b>" + data.name + " " + data.state + "</span>"));
+ };
+
+ var onuploadcomplete = function (event) {
+ var data = event.rf.data;
+ var str = "";
+ RichFaces.log.info(jQuery("<b>onuploadcomplete:</b>"));
+ for (var i in data) {
+ var item = data[i];
+ RichFaces.log.info(" " + item.name + " " + item.state);
+ }
+ };
+ //-->
+ </script>
+ <fu:fileUpload id="fu" acceptedTypes="#{fileUploadBean.acceptedTypes}" enabled="#{fileUploadBean.enabled}"
+ fileUploadListener="#{fileUploadBean.listener}" noDuplicate="#{fileUploadBean.noDuplicate}"
+ onfilesubmit="onfilesubmit(event)" onuploadcomplete="onuploadcomplete(event)"/>
+ <h:outputText value="File name:" />
+ <a4j:outputPanel ajaxRendered="true">#{fileUploadBean.item.fileName}</a4j:outputPanel>
+ <br />
+ <h:outputText value="Attribute name: "/>
+ <h:inputText id="name"/>
+ <h:outputText value="Attribute value: "/>
+ <h:inputText id="value"/>
+ <h:commandButton value="Update attribute">
+ <f:ajax render="fu" execute="name value" listener="#{fileUploadBean.updateAttribute}"/>
+ </h:commandButton>
+ <br />
+ <h:outputText value="AcceptedTypes: " />
+ <h:inputText value="#{fileUploadBean.acceptedTypes}">
+ <f:ajax render="fu"/>
+ </h:inputText>
+ <br />
+ <h:outputText value="Enabled: " />
+ <h:selectBooleanCheckbox value="#{fileUploadBean.enabled}">
+ <f:ajax render="fu"/>
+ </h:selectBooleanCheckbox>
+ <br />
+ <h:outputText value="NoDuplicate: " />
+ <h:selectBooleanCheckbox value="#{fileUploadBean.noDuplicate}">
+ <f:ajax render="fu"/>
+ </h:selectBooleanCheckbox>
+ <br />
+ <input type="submit" />
+ <a4j:log />
+ </h:form>
+ </h:body>
+</html>
Modified: branches/RF-8742-1/examples/input-demo/src/main/webapp/templates/template.xhtml
===================================================================
--- branches/RF-8742-1/examples/input-demo/src/main/webapp/templates/template.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/input-demo/src/main/webapp/templates/template.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -37,6 +37,7 @@
<li><h:commandLink value="rich:inputNumberSlider" action="inputNumberSlider" /></li>
<li><h:commandLink value="rich:inputNumberSpinner" action="inputNumberSpinner" /></li>
<li><h:commandLink value="rich:autocomplete" action="autocomplete" /></li>
+ <li><h:commandLink value="rich:fileUpload" action="fileUpload" /></li>
</ul>
<h:panelGrid columns="3">
Copied: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/images/loading.gif (from rev 20419, trunk/examples/iteration-demo/src/main/webapp/images/loading.gif)
===================================================================
(Binary files differ)
Modified: branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml
===================================================================
--- branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/iteration-demo/src/main/webapp/tree.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -27,6 +27,11 @@
border: 1px solid green;
}
+ .loadingWithoutFacet .rf-trn-ldn .rf-trn-hnd {
+ cursor: default;
+ background-image: url(#{facesContext.externalContext.requestContextPath}/images/loading.gif);
+ }
+
/*]]>*/</h:outputStylesheet>
</h:head>
@@ -244,6 +249,22 @@
</h:panelGroup>
</h:panelGrid>
+ 'loading' facet:
+ <it:tree value="#{treeBean.rootNodes}" toggleType="ajax" var="node">
+ <it:treeNode>
+ <f:facet name="loading">
+ <h:graphicImage value="/images/loading.gif" />
+ </f:facet>
+
+ #{node}
+ </it:treeNode>
+ </it:tree>
+
+ 'loading' without facet:
+ <it:tree value="#{treeBean.rootNodes}" toggleType="ajax" var="node" styleClass="loadingWithoutFacet" />
+
+ <a4j:queue />
+
<a4j:log />
</h:form>
</h:body>
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/panelMenu.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -17,6 +17,10 @@
<ui:param name="openLabel" value="View Source" />
<ui:param name="hideLabel" value="Hide Source" />
</ui:include>
+ <p>That menu uses parent component <b>itemChangeListener</b> to
+ output current selection but you could use <b>action/actionListener</b>
+ pair at <b>panelMenuItem</b>'s as usually to perform navigation and
+ process ActionEvent from them</p>
<p>Switching mode could be chosen with the <b>itemMode</b>
attribute for all panelMenu items except ones where this attribute was
redefined.</p>
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/panelMenu/samples/panelMenu-sample.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -12,64 +12,38 @@
</style>
<h:form id="form">
<h:panelGrid columns="2" columnClasses="cols,cols" width="400">
- <rich:panelMenu style="width:200px" mode="ajax"
+ <rich:panelMenu style="width:200px" mode="ajax" groupMode="ajax"
iconExpandedGroup="disc" iconCollapsedGroup="disc"
- iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
+ iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown"
- activeItem="#{panelMenuBean.current}">
+ itemChangeListener="#{panelMenuBean.updateCurrent}">
<rich:panelMenuGroup label="Group 1">
- <rich:panelMenuItem label="Item 1.1">
- <f:param name="current" value="Item 1.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 1.2">
- <f:param name="current" value="Item 1.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 1.3">
- <f:param name="current" value="Item 1.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 1.1" name="Item_1_1"/>
+ <rich:panelMenuItem label="Item 1.2" name="Item_1_2"/>
+ <rich:panelMenuItem label="Item 1.3" name="Item_1_3"/>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 2">
- <rich:panelMenuItem label="Item 2.1">
- <f:param name="current" value="Item 2.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.2">
- <f:param name="current" value="Item 2.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.3">
- <f:param name="current" value="Item 2.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.1" name="Item_2_1"/>
+ <rich:panelMenuItem label="Item 2.2" name="Item_2_2"/>
+ <rich:panelMenuItem label="Item 2.3" name="Item_2_3"/>
<rich:panelMenuGroup label="Group 2.4">
- <rich:panelMenuItem label="Item 2.4.1">
- <f:param name="current" value="Item 2.4.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.4.2">
- <f:param name="current" value="Item 2.4.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 2.4.3">
- <f:param name="current" value="Item 2.4.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.4.1" name="Item_2_4_1"/>
+ <rich:panelMenuItem label="Item 2.4.2" name="Item_2_4_2"/>
+ <rich:panelMenuItem label="Item 2.4.3" name="Item_2_4_3"/>
</rich:panelMenuGroup>
- <rich:panelMenuItem label="Item 2.5">
- <f:param name="current" value="Item 2.5" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 2.5" name="Item_2_5"/>
</rich:panelMenuGroup>
<rich:panelMenuGroup label="Group 3">
- <rich:panelMenuItem label="Item 3.1">
- <f:param name="current" value="Item 3.1" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 3.2">
- <f:param name="current" value="Item 3.2" />
- </rich:panelMenuItem>
- <rich:panelMenuItem label="Item 3.3">
- <f:param name="current" value="Item 3.3" />
- </rich:panelMenuItem>
+ <rich:panelMenuItem label="Item 3.1" name="Item_3_1"/>
+ <rich:panelMenuItem label="Item 3.2" name="Item_3_2"/>
+ <rich:panelMenuItem label="Item 3.3" name="Item_3_3"/>
</rich:panelMenuGroup>
</rich:panelMenu>
- <rich:panel bodyClass="rich-laguna-panel-no-header">
<a4j:outputPanel ajaxRendered="true">
+ <rich:panel rendered="#{not empty panelMenuBean.current}">
<h:outputText value="#{panelMenuBean.current} selected" id="current" />
- </a4j:outputPanel>
</rich:panel>
+ </a4j:outputPanel>
</h:panelGrid>
</h:form>
</ui:composition>
\ No newline at end of file
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -19,7 +19,7 @@
}
</style>
<h:form>
- <rich:togglePanel id="panel1" activeItem="item1" render="tabs">
+ <rich:togglePanel id="panel1" activeItem="item1" render="tabs" itemChangeListener="#{panelMenuBean.updateCurrent}">
<rich:togglePanelItem name="item1">
<p>This toggle panel switches in Ajax mode. So only one active
item loaded to the client.</p>
Modified: branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml
===================================================================
--- branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/examples/richfaces-showcase/src/main/webapp/richfaces/treeAdaptors/samples/treeModelRecursiveAdaptor-sample.xhtml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -7,7 +7,7 @@
xmlns:rich="http://richfaces.org/rich">
<h:form>
- <rich:tree style="width:300px" toggleType="ajax" var="item">
+ <rich:tree toggleType="ajax" var="item">
<rich:treeModelRecursiveAdaptor roots="#{fileSystemBean.sourceRoots}" nodes="#{item.directories}" >
<rich:treeNode>
#{item.shortPath}
Modified: branches/RF-8742-1/ui/dist/richfaces-components-api/pom.xml
===================================================================
--- branches/RF-8742-1/ui/dist/richfaces-components-api/pom.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/dist/richfaces-components-api/pom.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -173,4 +173,4 @@
<developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/trunk/ui/dist/richfaces-com...</developerConnection>
<url>http://fisheye.jboss.org/browse/richfaces</url>
</scm>
-</project>
\ No newline at end of file
+</project>
Copied: branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java (from rev 20419, trunk/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java)
===================================================================
--- branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java (rev 0)
+++ branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/FileUploadListener.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,29 @@
+/**
+ * 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.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+public interface FileUploadListener extends FacesListener {
+
+ public void processUpload(UploadEvent event);
+}
Copied: branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java (from rev 20419, trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java)
===================================================================
--- branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java (rev 0)
+++ branches/RF-8742-1/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,55 @@
+/**
+ * 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.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.model.UploadItem;
+
+public class UploadEvent extends FacesEvent {
+
+ private static final long serialVersionUID = -7645197191376210068L;
+ private UploadItem uploadItem = null;
+
+ public UploadEvent(UIComponent component, UploadItem uploadItem) {
+ super(component);
+ this.uploadItem = uploadItem;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof FileUploadListener;
+ }
+
+ public void processListener(FacesListener listener) {
+ ((FileUploadListener) listener).processUpload(this);
+ }
+
+ /**
+ * Returns UploadItem instance. Returns first element of list of UploadItems in case of multiple upload.
+ *
+ * @return the uploadItem
+ */
+ public UploadItem getUploadItem() {
+ return uploadItem;
+ }
+}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/component/AbstractFileUpload.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import java.util.Map;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ComponentSystemEvent;
+import javax.faces.event.ListenerFor;
+import javax.faces.event.PostAddToViewEvent;
+
+import org.richfaces.cdk.annotations.Attribute;
+import org.richfaces.cdk.annotations.EventName;
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.JsfRenderer;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.context.FileUploadPartialViewContextFactory;
+import org.richfaces.event.FileUploadListener;
+import org.richfaces.request.MultipartRequest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+@JsfComponent(tag = @Tag(handler = "org.richfaces.view.facelets.FileUploadHandler"),
+ renderer = @JsfRenderer(type = "org.richfaces.FileUploadRenderer"),
+ attributes = {"events-props.xml", "core-props.xml", "i18n-props.xml"})
+@ListenerFor(systemEventClass = PostAddToViewEvent.class)
+public abstract class AbstractFileUpload extends UIComponentBase {
+
+ @Attribute
+ public abstract String getAcceptedTypes();
+
+ @Attribute(defaultValue = "true")
+ public abstract boolean isEnabled();
+
+ @Attribute(defaultValue = "false")
+ public abstract boolean isNoDuplicate();
+
+ @Attribute(events = @EventName("filesubmit"))
+ public abstract String getOnfilesubmit();
+
+ @Attribute(events = @EventName("uploadcomplete"))
+ public abstract String getOnuploadcomplete();
+
+ @Override
+ public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
+ super.processEvent(event);
+ FacesContext context = getFacesContext();
+ Map<String, UIComponent> facets = getFacets();
+ UIComponent component = facets.get("progress");
+ if (component == null) {
+ try {
+ component = context.getApplication().createComponent(context, "org.richfaces.ProgressBar",
+ "org.richfaces.ProgressBarRenderer");
+ } catch (FacesException e) {
+ // To work without ProgressBar.
+ }
+ if (component != null) {
+ component.setId(getId() + "_pb");
+ facets.put("progress", component);
+ }
+ }
+ if (component != null) {
+ component.setValueExpression("value", context.getApplication().getExpressionFactory()
+ .createValueExpression(context.getELContext(),
+ "#{" + MultipartRequest.PERCENT_BEAN_NAME + "[param['"
+ + FileUploadPartialViewContextFactory.UID_KEY + "']]}", Integer.class));
+ }
+ }
+
+ /**
+ * <p>Add a new {@link FileUploadListener} to the set of listeners
+ * interested in being notified when {@link UploadEvent}s occur.</p>
+ *
+ * @param listener The {@link FileUploadListener} to be added
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void addFileUploadListener(FileUploadListener listener) {
+ addFacesListener(listener);
+ }
+
+ /**
+ * <p>Return the set of registered {@link FileUploadListener}s for this
+ * {@link AbstractFileUpload} instance. If there are no registered listeners,
+ * a zero-length array is returned.</p>
+ */
+ public FileUploadListener[] getFileUploadListeners() {
+ return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
+ }
+
+ /**
+ * <p>Remove an existing {@link FileUploadListener} (if any) from the
+ * set of listeners interested in being notified when
+ * {@link FileUploadListener}s occur.</p>
+ *
+ * @param listener The {@link FileUploadListener} to be removed
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ public void removeFileUploadListener(FileUploadListener listener) {
+ removeFacesListener(listener);
+ }
+}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/context)
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.context;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.net.URLDecoder;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.faces.context.PartialViewContext;
-import javax.faces.context.PartialViewContextFactory;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.richfaces.exception.FileUploadException;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.request.MultipartRequest;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FileUploadPartialViewContextFactory extends PartialViewContextFactory {
-
- public static final String UID_KEY = "rf_fu_uid";
-
- private static enum ResponseState {
- sizeExceeded, stopped, serverError
- };
-
- private static final Logger LOGGER = RichfacesLogger.CONTEXT.getLogger();
-
- private static final Pattern AMPERSAND = Pattern.compile("&+");
-
- private PartialViewContextFactory parentFactory;
-
- /** Flag indicating whether a temporary file should be used to cache the uploaded file */
- private boolean createTempFiles = true;
-
- private String tempFilesDirectory;
-
- /** The maximum size of a file upload request. 0 means no limit. */
- private int maxRequestSize = 0;
-
- public FileUploadPartialViewContextFactory(PartialViewContextFactory parentFactory) {
- this.parentFactory = parentFactory;
- ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
- //TODO Use ConfigurationServiceHelper to initialize InitParameters.
- String param = context.getInitParameter("org.richfaces.fileUpload.createTempFiles");
- if (param != null) {
- this.createTempFiles = Boolean.parseBoolean(param);
- }
- this.tempFilesDirectory = context.getInitParameter("org.richfaces.fileUpload.tempFilesDirectory");
- param = context.getInitParameter("org.richfaces.fileUpload.maxRequestSize");
- if (param != null) {
- this.maxRequestSize = Integer.parseInt(param);
- }
- }
-
- @Override
- public PartialViewContext getPartialViewContext(FacesContext facesContext) {
- ExternalContext externalContext = facesContext.getExternalContext();
- HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
- Map<String, String> queryParamMap = parseQueryString(request.getQueryString());
- String uid = queryParamMap.get(UID_KEY);
- if (uid != null) {
- if (maxRequestSize != 0 && externalContext.getRequestContentLength() > maxRequestSize) {
- printResponse(facesContext, uid, ResponseState.sizeExceeded);
- } else {
- MultipartRequest multipartRequest = new MultipartRequest(request, createTempFiles,
- tempFilesDirectory, maxRequestSize, uid);
- try {
- multipartRequest.parseRequest();
- if (!multipartRequest.isDone()) {
- printResponse(facesContext, uid, ResponseState.stopped);
- } else {
- externalContext.setRequest(multipartRequest);
- }
- } catch (FileUploadException e) {
- printResponse(facesContext, uid, ResponseState.serverError);
- } finally {
- multipartRequest.clearRequestData();
- }
- }
- }
- return parentFactory.getPartialViewContext(facesContext);
- }
-
- private Map<String, String> parseQueryString(String queryString) {
- if (queryString != null) {
- Map<String, String> parameters = new HashMap<String, String>();
- String[] nvPairs = AMPERSAND.split(queryString);
- for (String nvPair : nvPairs) {
- if (nvPair.length() == 0) {
- continue;
- }
-
- int eqIdx = nvPair.indexOf('=');
- if (eqIdx >= 0) {
- try {
- String name = URLDecoder.decode(nvPair.substring(0, eqIdx), "UTF-8");
- if (!parameters.containsKey(name)) {
- String value = URLDecoder.decode(nvPair.substring(eqIdx + 1), "UTF-8");
-
- parameters.put(name, value);
- }
- } catch (UnsupportedEncodingException e) {
- // log warning and skip this parameter
- LOGGER.warn(e.getLocalizedMessage(), e);
- }
- }
- }
- return parameters;
- } else {
- return Collections.emptyMap();
- }
- }
-
- private void printResponse(FacesContext facesContext, String uid, ResponseState state) {
- facesContext.responseComplete();
- ExternalContext externalContext = facesContext.getExternalContext();
- externalContext.setResponseStatus(HttpServletResponse.SC_OK);
- externalContext.setResponseContentType(MultipartRequest.TEXT_HTML);
- try {
- Writer writer = externalContext.getResponseOutputWriter();
- writer.write("<html id=\"" + UID_KEY + uid + ":" + state + "\"/>");
- writer.close();
- } catch (IOException e) {
- LOGGER.error(e);
- }
- }
-}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/context/FileUploadPartialViewContextFactory.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.context;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.net.URLDecoder;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.PartialViewContext;
+import javax.faces.context.PartialViewContextFactory;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.richfaces.exception.FileUploadException;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.request.MultipartRequest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadPartialViewContextFactory extends PartialViewContextFactory {
+
+ public static final String UID_KEY = "rf_fu_uid";
+
+ private static enum ResponseState {
+ sizeExceeded, stopped, serverError
+ };
+
+ private static final Logger LOGGER = RichfacesLogger.CONTEXT.getLogger();
+
+ private static final Pattern AMPERSAND = Pattern.compile("&+");
+
+ private PartialViewContextFactory parentFactory;
+
+ /** Flag indicating whether a temporary file should be used to cache the uploaded file */
+ private boolean createTempFiles = true;
+
+ private String tempFilesDirectory;
+
+ /** The maximum size of a file upload request. 0 means no limit. */
+ private int maxRequestSize = 0;
+
+ public FileUploadPartialViewContextFactory(PartialViewContextFactory parentFactory) {
+ this.parentFactory = parentFactory;
+ ExternalContext context = FacesContext.getCurrentInstance().getExternalContext();
+ //TODO Use ConfigurationServiceHelper to initialize InitParameters.
+ String param = context.getInitParameter("org.richfaces.fileUpload.createTempFiles");
+ if (param != null) {
+ this.createTempFiles = Boolean.parseBoolean(param);
+ }
+ this.tempFilesDirectory = context.getInitParameter("org.richfaces.fileUpload.tempFilesDirectory");
+ param = context.getInitParameter("org.richfaces.fileUpload.maxRequestSize");
+ if (param != null) {
+ this.maxRequestSize = Integer.parseInt(param);
+ }
+ }
+
+ @Override
+ public PartialViewContext getPartialViewContext(FacesContext facesContext) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
+ Map<String, String> queryParamMap = parseQueryString(request.getQueryString());
+ String uid = queryParamMap.get(UID_KEY);
+ if (uid != null) {
+ if (maxRequestSize != 0 && externalContext.getRequestContentLength() > maxRequestSize) {
+ printResponse(facesContext, uid, ResponseState.sizeExceeded);
+ } else {
+ MultipartRequest multipartRequest = new MultipartRequest(request, createTempFiles,
+ tempFilesDirectory, maxRequestSize, uid);
+ try {
+ multipartRequest.parseRequest();
+ if (!multipartRequest.isDone()) {
+ printResponse(facesContext, uid, ResponseState.stopped);
+ } else {
+ externalContext.setRequest(multipartRequest);
+ }
+ } catch (FileUploadException e) {
+ printResponse(facesContext, uid, ResponseState.serverError);
+ } finally {
+ multipartRequest.clearRequestData();
+ }
+ }
+ }
+ return parentFactory.getPartialViewContext(facesContext);
+ }
+
+ private Map<String, String> parseQueryString(String queryString) {
+ if (queryString != null) {
+ Map<String, String> parameters = new HashMap<String, String>();
+ String[] nvPairs = AMPERSAND.split(queryString);
+ for (String nvPair : nvPairs) {
+ if (nvPair.length() == 0) {
+ continue;
+ }
+
+ int eqIdx = nvPair.indexOf('=');
+ if (eqIdx >= 0) {
+ try {
+ String name = URLDecoder.decode(nvPair.substring(0, eqIdx), "UTF-8");
+ if (!parameters.containsKey(name)) {
+ String value = URLDecoder.decode(nvPair.substring(eqIdx + 1), "UTF-8");
+
+ parameters.put(name, value);
+ }
+ } catch (UnsupportedEncodingException e) {
+ // log warning and skip this parameter
+ LOGGER.warn(e.getLocalizedMessage(), e);
+ }
+ }
+ }
+ return parameters;
+ } else {
+ return Collections.emptyMap();
+ }
+ }
+
+ private void printResponse(FacesContext facesContext, String uid, ResponseState state) {
+ facesContext.responseComplete();
+ ExternalContext externalContext = facesContext.getExternalContext();
+ externalContext.setResponseStatus(HttpServletResponse.SC_OK);
+ externalContext.setResponseContentType(MultipartRequest.TEXT_HTML);
+ try {
+ Writer writer = externalContext.getResponseOutputWriter();
+ writer.write("<html id=\"" + UID_KEY + uid + ":" + state + "\"/>");
+ writer.close();
+ } catch (IOException e) {
+ LOGGER.error(e);
+ }
+ }
+}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/exception)
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.exception;
-
-/**
- * Thrown when an exception occurs while uploading a file.
- *
- */
-public class FileUploadException extends RuntimeException {
-
- private static final long serialVersionUID = -3579917878909990838L;
-
- public FileUploadException() {
- this(null, null);
- }
-
- public FileUploadException(String message) {
- this(message, null);
- }
-
- public FileUploadException(String message, Throwable cause) {
- super(message, cause);
- }
-}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/exception/FileUploadException.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.exception;
+
+/**
+ * Thrown when an exception occurs while uploading a file.
+ *
+ */
+public class FileUploadException extends RuntimeException {
+
+ private static final long serialVersionUID = -3579917878909990838L;
+
+ public FileUploadException() {
+ this(null, null);
+ }
+
+ public FileUploadException(String message) {
+ this(message, null);
+ }
+
+ public FileUploadException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+import org.richfaces.request.MultipartRequest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadRendererBase extends RendererBase {
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ ExternalContext externalContext = context.getExternalContext();
+ Object request = externalContext.getRequest();
+ if (request instanceof MultipartRequest) {
+ UploadItem uploadItem = ((MultipartRequest) request).getUploadItem(component.getClientId(context));
+ if (uploadItem != null) {
+ component.queueEvent(new UploadEvent(component, uploadItem));
+ }
+ }
+ }
+}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request)
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,191 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.request;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ByteSequenceMatcher {
-
- public interface BytesHandler {
-
- void handle(byte[] bytes, int length) throws IOException;
-
- }
-
- private static final int ZERO_READS_NUMBER = 20;
-
- private byte[] buffer;
-
- private int readLength = 0;
-
- private int zeroReadCounter = ZERO_READS_NUMBER;
-
- private boolean bufferEOF = false;
-
- private boolean isEOF = false;
-
- private boolean isMatched = false;
-
- private InputStream inputStream;
-
- private BytesHandler bytesHandler;
-
- public ByteSequenceMatcher(InputStream inputStream, int bufferSize) {
- this.inputStream = inputStream;
- this.buffer = new byte[bufferSize];
- }
-
- public BytesHandler getBytesHandler() {
- return bytesHandler;
- }
-
- public void setBytesHandler(BytesHandler bytesHandler) {
- this.bytesHandler = bytesHandler;
- }
-
- protected void prefillBuffer(int usedLength) throws IOException {
- if (usedLength > readLength) {
- throw new IllegalArgumentException();
- }
-
- if (usedLength != readLength && usedLength != 0) {
- System.arraycopy(buffer, usedLength, buffer, 0, readLength - usedLength);
- }
-
- readLength -= usedLength;
-
-
- while (!bufferEOF) {
- int remaining = buffer.length - readLength;
- if (remaining <= 0) {
- break;
- }
- int read = inputStream.read(buffer, readLength, remaining);
-
- if (read > 0) {
- readLength += read;
- } else if (read == 0) {
- --zeroReadCounter;
-
- if (zeroReadCounter == 0) {
- throw new IllegalStateException("Maximum number of zero reads reached");
- }
- } else if (read < 0) {
- bufferEOF = true;
- }
- }
- }
-
- private boolean match(int startOffset, byte[]... sequences) {
- int index = startOffset;
-
- for (byte[] bs : sequences) {
- for (byte b : bs) {
-
- if (index >= readLength) {
- return false;
- }
-
- if (buffer[index] != b) {
- return false;
- }
-
- index++;
- }
- }
-
- return true;
- }
-
- public void findSequence(int limit, byte[]... sequences) throws IOException {
- isMatched = false;
-
- int userLimit = limit;
- if (userLimit <= 0) {
- userLimit = Integer.MAX_VALUE;
- }
-
- prefillBuffer(0);
-
- int sequencesLength = 0;
- for (byte[] bs : sequences) {
- sequencesLength += bs.length;
- }
-
- int i = 0;
-
- while (!isMatched && i <= readLength - sequencesLength) {
- if (match(i, sequences)) {
- isMatched = true;
- bytesHandler.handle(buffer, i);
- prefillBuffer(i + sequencesLength);
- } else {
- int sequenceLimit = readLength - sequencesLength + 1;
- int realLimit;
-
- if (sequenceLimit < userLimit) {
- realLimit = sequenceLimit;
- } else {
- realLimit = userLimit;
- }
-
- if (realLimit > 0 && i == realLimit - 1) {
- // report limit
- bytesHandler.handle(buffer, realLimit);
- prefillBuffer(realLimit);
-
- i = 0;
- } else {
- i++;
- }
- }
- }
-
- flushUnmatchedBytes();
-
- if (this.readLength == 0) {
- this.isEOF = true;
- }
- }
-
- private void flushUnmatchedBytes() throws IOException {
- if (!isMatched) {
- if (readLength > 0) {
- bytesHandler.handle(buffer, readLength);
- prefillBuffer(readLength);
- }
- }
- }
-
- public boolean isEOF() {
- return isEOF;
- }
-
- public boolean isMatched() {
- return isMatched;
- }
-
- public boolean isMatchedAndNotEOF() {
- return isMatched() && !isEOF();
- }
-}
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ByteSequenceMatcher.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.request;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+public class ByteSequenceMatcher {
+
+ public interface BytesHandler {
+
+ void handle(byte[] bytes, int length) throws IOException;
+
+ }
+
+ private static final int ZERO_READS_NUMBER = 20;
+
+ private byte[] buffer;
+
+ private int readLength = 0;
+
+ private int zeroReadCounter = ZERO_READS_NUMBER;
+
+ private boolean bufferEOF = false;
+
+ private boolean isEOF = false;
+
+ private boolean isMatched = false;
+
+ private InputStream inputStream;
+
+ private BytesHandler bytesHandler;
+
+ public ByteSequenceMatcher(InputStream inputStream, int bufferSize) {
+ this.inputStream = inputStream;
+ this.buffer = new byte[bufferSize];
+ }
+
+ public BytesHandler getBytesHandler() {
+ return bytesHandler;
+ }
+
+ public void setBytesHandler(BytesHandler bytesHandler) {
+ this.bytesHandler = bytesHandler;
+ }
+
+ protected void prefillBuffer(int usedLength) throws IOException {
+ if (usedLength > readLength) {
+ throw new IllegalArgumentException();
+ }
+
+ if (usedLength != readLength && usedLength != 0) {
+ System.arraycopy(buffer, usedLength, buffer, 0, readLength - usedLength);
+ }
+
+ readLength -= usedLength;
+
+
+ while (!bufferEOF) {
+ int remaining = buffer.length - readLength;
+ if (remaining <= 0) {
+ break;
+ }
+ int read = inputStream.read(buffer, readLength, remaining);
+
+ if (read > 0) {
+ readLength += read;
+ } else if (read == 0) {
+ --zeroReadCounter;
+
+ if (zeroReadCounter == 0) {
+ throw new IllegalStateException("Maximum number of zero reads reached");
+ }
+ } else if (read < 0) {
+ bufferEOF = true;
+ }
+ }
+ }
+
+ private boolean match(int startOffset, byte[]... sequences) {
+ int index = startOffset;
+
+ for (byte[] bs : sequences) {
+ for (byte b : bs) {
+
+ if (index >= readLength) {
+ return false;
+ }
+
+ if (buffer[index] != b) {
+ return false;
+ }
+
+ index++;
+ }
+ }
+
+ return true;
+ }
+
+ public void findSequence(int limit, byte[]... sequences) throws IOException {
+ isMatched = false;
+
+ int userLimit = limit;
+ if (userLimit <= 0) {
+ userLimit = Integer.MAX_VALUE;
+ }
+
+ prefillBuffer(0);
+
+ int sequencesLength = 0;
+ for (byte[] bs : sequences) {
+ sequencesLength += bs.length;
+ }
+
+ int i = 0;
+
+ while (!isMatched && i <= readLength - sequencesLength) {
+ if (match(i, sequences)) {
+ isMatched = true;
+ bytesHandler.handle(buffer, i);
+ prefillBuffer(i + sequencesLength);
+ } else {
+ int sequenceLimit = readLength - sequencesLength + 1;
+ int realLimit;
+
+ if (sequenceLimit < userLimit) {
+ realLimit = sequenceLimit;
+ } else {
+ realLimit = userLimit;
+ }
+
+ if (realLimit > 0 && i == realLimit - 1) {
+ // report limit
+ bytesHandler.handle(buffer, realLimit);
+ prefillBuffer(realLimit);
+
+ i = 0;
+ } else {
+ i++;
+ }
+ }
+ }
+
+ flushUnmatchedBytes();
+
+ if (this.readLength == 0) {
+ this.isEOF = true;
+ }
+ }
+
+ private void flushUnmatchedBytes() throws IOException {
+ if (!isMatched) {
+ if (readLength > 0) {
+ bytesHandler.handle(buffer, readLength);
+ prefillBuffer(readLength);
+ }
+ }
+ }
+
+ public boolean isEOF() {
+ return isEOF;
+ }
+
+ public boolean isMatched() {
+ return isMatched;
+ }
+
+ public boolean isMatchedAndNotEOF() {
+ return isMatched() && !isEOF();
+ }
+}
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,206 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.request;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.rmi.server.UID;
-
-import org.richfaces.exception.FileUploadException;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-
-class FileParam extends Param {
-
- private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
-
- private String filename;
- private String contentType;
- private int fileSize;
-
- private ByteArrayOutputStream bOut = null;
- private FileOutputStream fOut = null;
- private File tempFile = null;
-
- public FileParam(String name) {
- super(name);
- }
-
- public Object getFile() {
- if (null != tempFile) {
- return tempFile;
- } else if (null != bOut) {
- return bOut.toByteArray();
- }
- return null;
- }
-
- public String getFilename() {
- return filename;
- }
-
- public void setFilename(String filename) {
- this.filename = filename;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public void setContentType(String contentType) {
- this.contentType = contentType;
- }
-
- public int getFileSize() {
- return fileSize;
- }
-
- public File createTempFile(String tempFilesDirectory) {
- try {
- File dir = null;
- if (tempFilesDirectory != null) {
- dir = new File(tempFilesDirectory);
- }
- tempFile = File.createTempFile(new UID().toString().replace(":", "-"), ".upload", dir);
- fOut = new FileOutputStream(tempFile);
- } catch (IOException ex) {
- if (fOut != null) {
- try {
- fOut.close();
- } catch (IOException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
-
- throw new FileUploadException("Could not create temporary file");
- }
- return tempFile;
- }
-
- public void deleteFile() {
- try {
- if (fOut != null) {
- fOut.close();
- }
- if (tempFile != null) {
- tempFile.delete();
- }
- } catch (Exception e) {
- throw new FileUploadException("Could not delete temporary file");
- }
- }
-
- public byte[] getData() {
- if (bOut != null) {
- return bOut.toByteArray();
- } else if (tempFile != null) {
- if (tempFile.exists()) {
- FileInputStream fIn = null;
- try {
- long fileLength = tempFile.length();
- if (fileLength > Integer.MAX_VALUE) {
- throw new IllegalArgumentException("File content is too long to be allocated as byte[]");
- }
-
- fIn = new FileInputStream(tempFile);
-
- byte[] fileData = new byte[(int) fileLength];
- int totalRead = 0;
- int read = 0;
- do {
- read = fIn.read(fileData, totalRead, fileData.length - totalRead);
- if (read > 0) {
- totalRead += read;
- }
- } while (read > 0);
-
- return fileData;
- } catch (IOException ex) { /* too bad? */
- LOGGER.error(ex.getMessage(), ex);
- } finally {
- if (fIn != null) {
- try {
- fIn.close();
- } catch (IOException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
- }
- }
- }
-
- return null;
- }
-
- public InputStream getInputStream() {
- if (bOut != null) {
- return new ByteArrayInputStream(bOut.toByteArray());
- } else if (tempFile != null) {
- try {
- return new FileInputStream(tempFile) {
- @Override
- public void close() throws IOException {
- super.close();
- tempFile.delete();
- }
- };
- } catch (FileNotFoundException ex) {
- LOGGER.error(ex.getMessage(), ex);
- }
- }
-
- return null;
- }
-
- @Override
- public void complete() throws IOException {
- if (fOut != null) {
- try {
- fOut.close();
- } catch (IOException ex) {
- LOGGER.error(ex.getMessage(), ex);
- }
- fOut = null;
- }
- }
-
- public void handle(byte[] bytes, int length) throws IOException {
- // read += length;
- if (fOut != null) {
- fOut.write(bytes, 0, length);
- fOut.flush();
- } else {
- if (bOut == null) {
- bOut = new ByteArrayOutputStream();
- }
- bOut.write(bytes, 0, length);
- }
-
- fileSize += length;
- }
-}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/FileParam.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,206 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.request;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.rmi.server.UID;
+
+import org.richfaces.exception.FileUploadException;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+
+class FileParam extends Param {
+
+ private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
+
+ private String filename;
+ private String contentType;
+ private int fileSize;
+
+ private ByteArrayOutputStream bOut = null;
+ private FileOutputStream fOut = null;
+ private File tempFile = null;
+
+ public FileParam(String name) {
+ super(name);
+ }
+
+ public Object getFile() {
+ if (null != tempFile) {
+ return tempFile;
+ } else if (null != bOut) {
+ return bOut.toByteArray();
+ }
+ return null;
+ }
+
+ public String getFilename() {
+ return filename;
+ }
+
+ public void setFilename(String filename) {
+ this.filename = filename;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public int getFileSize() {
+ return fileSize;
+ }
+
+ public File createTempFile(String tempFilesDirectory) {
+ try {
+ File dir = null;
+ if (tempFilesDirectory != null) {
+ dir = new File(tempFilesDirectory);
+ }
+ tempFile = File.createTempFile(new UID().toString().replace(":", "-"), ".upload", dir);
+ fOut = new FileOutputStream(tempFile);
+ } catch (IOException ex) {
+ if (fOut != null) {
+ try {
+ fOut.close();
+ } catch (IOException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+
+ throw new FileUploadException("Could not create temporary file");
+ }
+ return tempFile;
+ }
+
+ public void deleteFile() {
+ try {
+ if (fOut != null) {
+ fOut.close();
+ }
+ if (tempFile != null) {
+ tempFile.delete();
+ }
+ } catch (Exception e) {
+ throw new FileUploadException("Could not delete temporary file");
+ }
+ }
+
+ public byte[] getData() {
+ if (bOut != null) {
+ return bOut.toByteArray();
+ } else if (tempFile != null) {
+ if (tempFile.exists()) {
+ FileInputStream fIn = null;
+ try {
+ long fileLength = tempFile.length();
+ if (fileLength > Integer.MAX_VALUE) {
+ throw new IllegalArgumentException("File content is too long to be allocated as byte[]");
+ }
+
+ fIn = new FileInputStream(tempFile);
+
+ byte[] fileData = new byte[(int) fileLength];
+ int totalRead = 0;
+ int read = 0;
+ do {
+ read = fIn.read(fileData, totalRead, fileData.length - totalRead);
+ if (read > 0) {
+ totalRead += read;
+ }
+ } while (read > 0);
+
+ return fileData;
+ } catch (IOException ex) { /* too bad? */
+ LOGGER.error(ex.getMessage(), ex);
+ } finally {
+ if (fIn != null) {
+ try {
+ fIn.close();
+ } catch (IOException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public InputStream getInputStream() {
+ if (bOut != null) {
+ return new ByteArrayInputStream(bOut.toByteArray());
+ } else if (tempFile != null) {
+ try {
+ return new FileInputStream(tempFile) {
+ @Override
+ public void close() throws IOException {
+ super.close();
+ tempFile.delete();
+ }
+ };
+ } catch (FileNotFoundException ex) {
+ LOGGER.error(ex.getMessage(), ex);
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public void complete() throws IOException {
+ if (fOut != null) {
+ try {
+ fOut.close();
+ } catch (IOException ex) {
+ LOGGER.error(ex.getMessage(), ex);
+ }
+ fOut = null;
+ }
+ }
+
+ public void handle(byte[] bytes, int length) throws IOException {
+ // read += length;
+ if (fOut != null) {
+ fOut.write(bytes, 0, length);
+ fOut.flush();
+ } else {
+ if (bOut == null) {
+ bOut = new ByteArrayOutputStream();
+ }
+ bOut.write(bytes, 0, length);
+ }
+
+ fileSize += length;
+ }
+}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,662 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.request;
-
-import java.io.ByteArrayOutputStream;
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
-import org.richfaces.exception.FileUploadException;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.model.UploadItem;
-import org.richfaces.request.ByteSequenceMatcher.BytesHandler;
-
-public class MultipartRequest extends HttpServletRequestWrapper {
-
- public static final String TEXT_HTML = "text/html";
-
- /** Session bean name where progress bar's percent map will be stored */
- public static final String PERCENT_BEAN_NAME = "_richfaces_upload_percents";
-
- private static final BytesHandler NOOP_HANDLER = new BytesHandler() {
- public void handle(byte[] bytes, int length) {
- // do nothing
- }
- };
-
- /** Session bean name where request size will be stored */
- private static final String REQUEST_SIZE_BEAN_NAME = "_richfaces_request_size";
-
- private static final String PARAM_NAME = "name";
- private static final String PARAM_FILENAME = "filename";
- private static final String PARAM_CONTENT_TYPE = "Content-Type";
-
- private static final int BUFFER_SIZE = 2048;
- private static final int CHUNK_SIZE = 1024;
- private static final int MAX_HEADER_SIZE = 32768;
-
- private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
-
- private static final byte CR = 0x0d;
- private static final byte LF = 0x0a;
- private static final byte[] CR_LF = {CR, LF};
- private static final byte[] HYPHENS = {0x2d, 0x2d}; // '--'
-
- private static final Pattern PARAM_VALUE_PATTERN = Pattern.compile("^\\s*([^\\s=]+)\\s*[=:]\\s*(.+)\\s*$");
-
- private static final Pattern FILE_NAME_PATTERN = Pattern.compile(".*filename=\"(.*)\"");
-
- private boolean createTempFiles;
-
- private String tempFilesDirectory;
-
- private String uid;
-
- private String encoding = null;
-
- private Integer contentLength = 0;
-
- private int bytesRead = 0;
-
- // we shouldn't allow to stop until request reaches PhaseListener because of portlets
- private volatile boolean canStop = false;
-
- private Map<String, Param> parameters = null;
-
- private Map<String, Object> percentMap = null;
-
- private Map<String, Integer> requestSizeMap = null;
-
- private List<String> keys = new ArrayList<String>();
-
- private byte[] boundaryMarker;
-
- private ByteSequenceMatcher sequenceMatcher;
-
- private boolean shouldStop = false;
- private boolean canceled;
-
- private boolean initialized = false;
-
- private HeadersHandler headersHandler = null;
-
- public MultipartRequest(HttpServletRequest request, boolean createTempFiles, String tempFilesDirectory,
- int maxRequestSize, String uid) {
- super(request);
- this.createTempFiles = createTempFiles;
- this.tempFilesDirectory = tempFilesDirectory;
- this.uid = uid;
-
- String contentLengthStr = request.getHeader("Content-Length");
- this.contentLength = Integer.parseInt(contentLengthStr);
- if (contentLengthStr != null && maxRequestSize > 0 && contentLength > maxRequestSize) {
- // TODO : we should make decision if can generate exception in this
- // place
- // throw new FileUploadException(
- // "Multipart request is larger than allowed size");
- }
- }
-
- private class ControlledProgressInputStream extends FilterInputStream {
-
- protected ControlledProgressInputStream(InputStream in) {
- super(in);
- }
-
- @Override
- public int read() throws IOException {
- int read = super.read();
- if (read >= 0) {
- bytesRead++;
- fillProgressInfo();
- }
- return read;
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- int read = super.read(b);
- if (read > 0) {
- bytesRead += read;
- fillProgressInfo();
- }
- return read;
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- int read = super.read(b, off, len);
- if (read > 0) {
- bytesRead += read;
- fillProgressInfo();
- }
- return read;
- }
- }
-
- private String decodeFileName(String name) {
- String fileName = null;
- try {
- StringBuffer buffer = new StringBuffer();
- String[] codes = name.split(";");
- if (codes != null) {
- for (String code : codes) {
- if (code.startsWith("&")) {
- String sCode = code.replaceAll("[&#]*", "");
- Integer iCode = Integer.parseInt(sCode);
- buffer.append(Character.toChars(iCode));
- } else {
- buffer.append(code);
- }
- }
- fileName = buffer.toString();
- }
- } catch (Exception e) {
- fileName = name;
- }
-
- return fileName;
- }
-
- public void cancel() {
- this.canceled = true;
-
- if (parameters != null) {
- Iterator<Param> it = parameters.values().iterator();
- while (it.hasNext()) {
- Param p = it.next();
- if (p instanceof FileParam) {
- ((FileParam) p).deleteFile();
- }
- }
- }
- }
-
- private void readNext() throws IOException {
- Param p = readHeader();
- if (p != null) {
- try {
- readData(p);
- } finally {
- try {
- p.complete();
- } catch (IOException e) {
- LOGGER.error(e.getMessage(), e);
- }
- }
- }
- }
-
- private Param createParam(Map<String, String> headers) {
- Param param = null;
- String paramName = headers.get(PARAM_NAME);
- if (paramName != null) {
- if (headers.containsKey(PARAM_FILENAME)) {
- FileParam fp = new FileParam(paramName);
- this.keys.add(paramName);
-
- if (createTempFiles) {
- fp.createTempFile(tempFilesDirectory);
- }
- fp.setContentType(headers.get(PARAM_CONTENT_TYPE));
- fp.setFilename(decodeFileName(headers.get(PARAM_FILENAME)));
- param = fp;
- } else {
- if (parameters.containsKey(paramName)) {
- param = parameters.get(paramName);
- } else {
- param = new ValueParam(paramName, encoding);
- }
- }
-
- if (!parameters.containsKey(paramName)) {
- parameters.put(paramName, param);
- }
- }
-
- return param;
- }
-
- private class HeadersHandler implements BytesHandler {
-
- private ByteArrayOutputStream baos = new ByteArrayOutputStream(BUFFER_SIZE);
-
- public void handle(byte[] bytes, int length) throws IOException {
- if (length != 0) {
- if (baos.size() + length > MAX_HEADER_SIZE) {
- throw new IOException("Header section is too big");
- }
-
- baos.write(bytes, 0, length);
- }
- }
-
- public boolean dataEquals(byte[] bytes) {
- return (baos.size() == bytes.length) && Arrays.equals(HYPHENS, baos.toByteArray());
- }
-
- public String asString() throws UnsupportedEncodingException {
- if (encoding != null) {
- return baos.toString(encoding);
- } else {
- return baos.toString();
- }
- }
-
- public void reset() {
- baos.reset();
- }
-
- }
-
- private Param readHeader() throws IOException {
- if (sequenceMatcher.isEOF()) {
- return null;
- }
-
- if (headersHandler == null) {
- headersHandler = new HeadersHandler();
- } else {
- headersHandler.reset();
- }
-
- sequenceMatcher.setBytesHandler(headersHandler);
- sequenceMatcher.findSequence(-1, CR_LF);
-
- if (sequenceMatcher.isMatchedAndNotEOF() && !headersHandler.dataEquals(HYPHENS)) {
- headersHandler.reset();
-
- sequenceMatcher.findSequence(-1, CR_LF, CR_LF);
-
- if (!sequenceMatcher.isMatchedAndNotEOF()) {
- throw new IOException("Request header cannot be read");
- }
-
- String headersString = headersHandler.asString();
- Map<String, String> headers = new HashMap<String, String>();
- String[] split = headersString.split("\r\n");
- for (String headerString : split) {
- parseParams(headerString, "; ", headers);
- }
-
- return createParam(headers);
- }
-
- return null;
- }
-
- private void readProlog() throws IOException {
- sequenceMatcher.setBytesHandler(NOOP_HANDLER);
- sequenceMatcher.findSequence(-1, HYPHENS, boundaryMarker);
- if (!sequenceMatcher.isMatchedAndNotEOF()) {
- throw new IOException("Request prolog cannot be read");
- }
- }
-
- private void readData(final Param param) throws IOException {
- sequenceMatcher.setBytesHandler(param);
- sequenceMatcher.findSequence(CHUNK_SIZE, CR_LF, HYPHENS, boundaryMarker);
- if (!this.sequenceMatcher.isMatchedAndNotEOF()) {
- throw new IOException("Request data cannot be read");
- }
- }
-
- private void initialize() throws IOException {
- if (!initialized) {
- initialized = true;
-
- this.boundaryMarker = getBoundaryMarker(super.getContentType());
- if (this.boundaryMarker == null) {
- throw new FileUploadException("The request was rejected because " + "no multipart boundary was found");
- }
-
- if (HYPHENS.length + boundaryMarker.length + CHUNK_SIZE + CR_LF.length > BUFFER_SIZE) {
- throw new FileUploadException("Boundary marker is too long");
- }
-
- this.encoding = getCharacterEncoding();
-
- this.parameters = new HashMap<String, Param>();
-
- InputStream input = new ControlledProgressInputStream(getInputStream());
-
- this.sequenceMatcher = new ByteSequenceMatcher(input, BUFFER_SIZE);
-
- setupProgressData();
-
- readProlog();
- }
- }
-
- public void parseRequest() {
- canStop = true;
-
- setupProgressData();
-
- try {
- initialize();
-
- while (!sequenceMatcher.isEOF()) {
- readNext();
- }
- } catch (IOException e) {
- this.cancel();
-
- if (!this.shouldStop) {
- throw new FileUploadException("IO Error parsing multipart request", e);
- }
- } finally {
- canStop = false;
- }
- }
-
- @SuppressWarnings("unchecked")
- private void setupProgressData() {
- if (percentMap == null || requestSizeMap == null) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (facesContext != null) {
- ExternalContext externalContext = facesContext.getExternalContext();
- if (externalContext != null) {
- Map<String, Object> sessionMap = externalContext.getSessionMap();
- if (sessionMap != null) {
- String uploadId = getUploadId();
-
- synchronized (sessionMap) {
- if (percentMap == null) {
- percentMap = (Map<String, Object>) sessionMap.get(PERCENT_BEAN_NAME);
- if (percentMap == null) {
- percentMap = new ConcurrentHashMap<String, Object>();
- sessionMap.put(PERCENT_BEAN_NAME, percentMap);
- }
- }
-
- if (requestSizeMap == null) {
- requestSizeMap = (Map<String, Integer>) sessionMap.get(REQUEST_SIZE_BEAN_NAME);
- if (requestSizeMap == null) {
- requestSizeMap = new ConcurrentHashMap<String, Integer>();
- sessionMap.put(REQUEST_SIZE_BEAN_NAME, requestSizeMap);
- }
- }
- }
-
- percentMap.put(uploadId, Double.valueOf(0));
-
- requestSizeMap.put(uploadId, getSize());
- }
- }
- }
- }
- }
-
- private void fillProgressInfo() {
- setupProgressData();
-
- if (percentMap != null) {
- Double percent = (Double) (100.0 * this.bytesRead / this.contentLength);
- percentMap.put(uid, percent);
- // this.percent = percent;
- }
- }
-
- private byte[] getBoundaryMarker(String contentType) {
- Map<String, String> params = parseParams(contentType, ";");
- String boundaryStr = (String) params.get("boundary");
-
- if (boundaryStr == null) {
- return null;
- }
-
- try {
- return boundaryStr.getBytes("ISO-8859-1");
- } catch (UnsupportedEncodingException e) {
- return boundaryStr.getBytes();
- }
- }
-
- private Map<String, String> parseParams(String paramStr, String separator) {
- Map<String, String> paramMap = new HashMap<String, String>();
- parseParams(paramStr, separator, paramMap);
- return paramMap;
- }
-
- private void parseParams(String paramStr, String separator, Map<String, String> paramMap) {
- String[] parts = paramStr.split(separator);
-
- for (String part : parts) {
- Matcher m = PARAM_VALUE_PATTERN.matcher(part);
- if (m.matches()) {
- String key = m.group(1);
- String value = m.group(2);
-
- // Strip double quotes
- if (value.startsWith("\"") && value.endsWith("\"")) {
- value = value.substring(1, value.length() - 1);
- }
- if (!"filename".equals(key)) {
- paramMap.put(key, value);
- } else {
- paramMap.put(key, parseFileName(paramStr));
- }
- }
- }
- }
-
- private String parseFileName(String parseStr) {
- Matcher m = FILE_NAME_PATTERN.matcher(parseStr);
- if (m.matches()) {
- String name = m.group(1);
- if (name.startsWith("&")) {
- return decodeFileName(name);
- } else {
- return name;
- }
- }
- return null;
- }
-
- private Param getParam(String name) {
- Param param = null;
- if (parameters != null) {
- param = parameters.get(name);
- }
-
- if (param == null) {
- if (!canceled) {
- try {
- initialize();
-
- while (param == null && !sequenceMatcher.isEOF()) {
- readNext();
- param = parameters.get(name);
- }
- } catch (IOException e) {
- this.cancel();
- throw new FileUploadException("IO Error parsing multipart request", e);
- }
- }
- }
-
- return param;
- }
-
- public Integer getSize() {
- return contentLength;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Enumeration getParameterNames() {
- if (parameters == null) {
- parseRequest();
- }
-
- return Collections.enumeration(parameters.keySet());
- }
-
- public byte[] getFileBytes(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getData() : null;
- }
-
- @Override
- public String getParameter(String name) {
- Param p = getParam(name);
- if (p != null && p instanceof ValueParam) {
- ValueParam vp = (ValueParam) p;
- if (vp.getValue() instanceof String) {
- return (String) vp.getValue();
- }
- } else if (p != null && p instanceof FileParam) {
- return "---BINARY DATA---";
- } else {
- return super.getParameter(name);
- }
-
- return null;
- }
-
- @Override
- public String[] getParameterValues(String name) {
- parseRequest();
-
- Param p = getParam(name);
- if (p != null && p instanceof ValueParam) {
- ValueParam vp = (ValueParam) p;
- if (vp.getValue() instanceof List<?>) {
- @SuppressWarnings("unchecked")
- List<String> vals = (List<String>) vp.getValue();
- String[] values = new String[vals.size()];
- vals.toArray(values);
- return values;
- } else {
- return new String[] {(String) vp.getValue()};
- }
- } else {
- return super.getParameterValues(name);
- }
- }
-
- @Override
- public Map<String, Object> getParameterMap() {
- if (parameters == null) {
- parseRequest();
- }
-
- @SuppressWarnings("unchecked")
- Map<String, Object> params = new HashMap<String, Object>(super.getParameterMap());
-
- for (String name : parameters.keySet()) {
- Param p = parameters.get(name);
- if (p instanceof ValueParam) {
- ValueParam vp = (ValueParam) p;
- if (vp.getValue() instanceof String) {
- params.put(name, vp.getValue());
- } else if (vp.getValue() instanceof List) {
- params.put(name, getParameterValues(name));
- }
- }
- }
-
- return params;
- }
-
- public UploadItem getUploadItem(String name) {
- Param param = getParam(name);
- if (param instanceof FileParam) {
- FileParam fileParam = (FileParam) param;
- return new UploadItem(fileParam.getFilename(), fileParam.getFileSize(), fileParam.getContentType(),
- fileParam.getFile());
- } else {
- return null;
- }
- }
-
- public boolean isFormUpload() {
- return "_richfaces_form_upload".equals(uid);
- }
-
- @Override
- public String getHeader(String name) {
- if ("Accept".equals(name)) {
- return TEXT_HTML;
- } else if ("Faces-Request".equals(name)) {
- return "partial/ajax";
- } else {
- return super.getHeader(name);
- }
- }
-
- public void stop() {
- if (canStop) {
- shouldStop = true;
- }
- }
-
- public boolean isStopped() {
- return this.shouldStop;
- }
-
- public boolean isDone() {
- return !(this.shouldStop && (this.canceled || this.contentLength != null
- && this.contentLength.intValue() != this.bytesRead));
- }
-
- @Override
- public String getContentType() {
- return "application/x-www-form-urlencoded";
- }
-
- public String getUploadId() {
- return uid;
- }
-
- public void clearRequestData() {
- String uploadId = getUploadId();
-
- if (percentMap != null) {
- percentMap.remove(uploadId);
- }
-
- if (requestSizeMap != null) {
- requestSizeMap.remove(uploadId);
- }
- }
-}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,662 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.request;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.richfaces.exception.FileUploadException;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.model.UploadItem;
+import org.richfaces.request.ByteSequenceMatcher.BytesHandler;
+
+public class MultipartRequest extends HttpServletRequestWrapper {
+
+ public static final String TEXT_HTML = "text/html";
+
+ /** Session bean name where progress bar's percent map will be stored */
+ public static final String PERCENT_BEAN_NAME = "_richfaces_upload_percents";
+
+ private static final BytesHandler NOOP_HANDLER = new BytesHandler() {
+ public void handle(byte[] bytes, int length) {
+ // do nothing
+ }
+ };
+
+ /** Session bean name where request size will be stored */
+ private static final String REQUEST_SIZE_BEAN_NAME = "_richfaces_request_size";
+
+ private static final String PARAM_NAME = "name";
+ private static final String PARAM_FILENAME = "filename";
+ private static final String PARAM_CONTENT_TYPE = "Content-Type";
+
+ private static final int BUFFER_SIZE = 2048;
+ private static final int CHUNK_SIZE = 1024;
+ private static final int MAX_HEADER_SIZE = 32768;
+
+ private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
+
+ private static final byte CR = 0x0d;
+ private static final byte LF = 0x0a;
+ private static final byte[] CR_LF = {CR, LF};
+ private static final byte[] HYPHENS = {0x2d, 0x2d}; // '--'
+
+ private static final Pattern PARAM_VALUE_PATTERN = Pattern.compile("^\\s*([^\\s=]+)\\s*[=:]\\s*(.+)\\s*$");
+
+ private static final Pattern FILE_NAME_PATTERN = Pattern.compile(".*filename=\"(.*)\"");
+
+ private boolean createTempFiles;
+
+ private String tempFilesDirectory;
+
+ private String uid;
+
+ private String encoding = null;
+
+ private Integer contentLength = 0;
+
+ private int bytesRead = 0;
+
+ // we shouldn't allow to stop until request reaches PhaseListener because of portlets
+ private volatile boolean canStop = false;
+
+ private Map<String, Param> parameters = null;
+
+ private Map<String, Object> percentMap = null;
+
+ private Map<String, Integer> requestSizeMap = null;
+
+ private List<String> keys = new ArrayList<String>();
+
+ private byte[] boundaryMarker;
+
+ private ByteSequenceMatcher sequenceMatcher;
+
+ private boolean shouldStop = false;
+ private boolean canceled;
+
+ private boolean initialized = false;
+
+ private HeadersHandler headersHandler = null;
+
+ public MultipartRequest(HttpServletRequest request, boolean createTempFiles, String tempFilesDirectory,
+ int maxRequestSize, String uid) {
+ super(request);
+ this.createTempFiles = createTempFiles;
+ this.tempFilesDirectory = tempFilesDirectory;
+ this.uid = uid;
+
+ String contentLengthStr = request.getHeader("Content-Length");
+ this.contentLength = Integer.parseInt(contentLengthStr);
+ if (contentLengthStr != null && maxRequestSize > 0 && contentLength > maxRequestSize) {
+ // TODO : we should make decision if can generate exception in this
+ // place
+ // throw new FileUploadException(
+ // "Multipart request is larger than allowed size");
+ }
+ }
+
+ private class ControlledProgressInputStream extends FilterInputStream {
+
+ protected ControlledProgressInputStream(InputStream in) {
+ super(in);
+ }
+
+ @Override
+ public int read() throws IOException {
+ int read = super.read();
+ if (read >= 0) {
+ bytesRead++;
+ fillProgressInfo();
+ }
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ int read = super.read(b);
+ if (read > 0) {
+ bytesRead += read;
+ fillProgressInfo();
+ }
+ return read;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int read = super.read(b, off, len);
+ if (read > 0) {
+ bytesRead += read;
+ fillProgressInfo();
+ }
+ return read;
+ }
+ }
+
+ private String decodeFileName(String name) {
+ String fileName = null;
+ try {
+ StringBuffer buffer = new StringBuffer();
+ String[] codes = name.split(";");
+ if (codes != null) {
+ for (String code : codes) {
+ if (code.startsWith("&")) {
+ String sCode = code.replaceAll("[&#]*", "");
+ Integer iCode = Integer.parseInt(sCode);
+ buffer.append(Character.toChars(iCode));
+ } else {
+ buffer.append(code);
+ }
+ }
+ fileName = buffer.toString();
+ }
+ } catch (Exception e) {
+ fileName = name;
+ }
+
+ return fileName;
+ }
+
+ public void cancel() {
+ this.canceled = true;
+
+ if (parameters != null) {
+ Iterator<Param> it = parameters.values().iterator();
+ while (it.hasNext()) {
+ Param p = it.next();
+ if (p instanceof FileParam) {
+ ((FileParam) p).deleteFile();
+ }
+ }
+ }
+ }
+
+ private void readNext() throws IOException {
+ Param p = readHeader();
+ if (p != null) {
+ try {
+ readData(p);
+ } finally {
+ try {
+ p.complete();
+ } catch (IOException e) {
+ LOGGER.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ private Param createParam(Map<String, String> headers) {
+ Param param = null;
+ String paramName = headers.get(PARAM_NAME);
+ if (paramName != null) {
+ if (headers.containsKey(PARAM_FILENAME)) {
+ FileParam fp = new FileParam(paramName);
+ this.keys.add(paramName);
+
+ if (createTempFiles) {
+ fp.createTempFile(tempFilesDirectory);
+ }
+ fp.setContentType(headers.get(PARAM_CONTENT_TYPE));
+ fp.setFilename(decodeFileName(headers.get(PARAM_FILENAME)));
+ param = fp;
+ } else {
+ if (parameters.containsKey(paramName)) {
+ param = parameters.get(paramName);
+ } else {
+ param = new ValueParam(paramName, encoding);
+ }
+ }
+
+ if (!parameters.containsKey(paramName)) {
+ parameters.put(paramName, param);
+ }
+ }
+
+ return param;
+ }
+
+ private class HeadersHandler implements BytesHandler {
+
+ private ByteArrayOutputStream baos = new ByteArrayOutputStream(BUFFER_SIZE);
+
+ public void handle(byte[] bytes, int length) throws IOException {
+ if (length != 0) {
+ if (baos.size() + length > MAX_HEADER_SIZE) {
+ throw new IOException("Header section is too big");
+ }
+
+ baos.write(bytes, 0, length);
+ }
+ }
+
+ public boolean dataEquals(byte[] bytes) {
+ return (baos.size() == bytes.length) && Arrays.equals(HYPHENS, baos.toByteArray());
+ }
+
+ public String asString() throws UnsupportedEncodingException {
+ if (encoding != null) {
+ return baos.toString(encoding);
+ } else {
+ return baos.toString();
+ }
+ }
+
+ public void reset() {
+ baos.reset();
+ }
+
+ }
+
+ private Param readHeader() throws IOException {
+ if (sequenceMatcher.isEOF()) {
+ return null;
+ }
+
+ if (headersHandler == null) {
+ headersHandler = new HeadersHandler();
+ } else {
+ headersHandler.reset();
+ }
+
+ sequenceMatcher.setBytesHandler(headersHandler);
+ sequenceMatcher.findSequence(-1, CR_LF);
+
+ if (sequenceMatcher.isMatchedAndNotEOF() && !headersHandler.dataEquals(HYPHENS)) {
+ headersHandler.reset();
+
+ sequenceMatcher.findSequence(-1, CR_LF, CR_LF);
+
+ if (!sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request header cannot be read");
+ }
+
+ String headersString = headersHandler.asString();
+ Map<String, String> headers = new HashMap<String, String>();
+ String[] split = headersString.split("\r\n");
+ for (String headerString : split) {
+ parseParams(headerString, "; ", headers);
+ }
+
+ return createParam(headers);
+ }
+
+ return null;
+ }
+
+ private void readProlog() throws IOException {
+ sequenceMatcher.setBytesHandler(NOOP_HANDLER);
+ sequenceMatcher.findSequence(-1, HYPHENS, boundaryMarker);
+ if (!sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request prolog cannot be read");
+ }
+ }
+
+ private void readData(final Param param) throws IOException {
+ sequenceMatcher.setBytesHandler(param);
+ sequenceMatcher.findSequence(CHUNK_SIZE, CR_LF, HYPHENS, boundaryMarker);
+ if (!this.sequenceMatcher.isMatchedAndNotEOF()) {
+ throw new IOException("Request data cannot be read");
+ }
+ }
+
+ private void initialize() throws IOException {
+ if (!initialized) {
+ initialized = true;
+
+ this.boundaryMarker = getBoundaryMarker(super.getContentType());
+ if (this.boundaryMarker == null) {
+ throw new FileUploadException("The request was rejected because " + "no multipart boundary was found");
+ }
+
+ if (HYPHENS.length + boundaryMarker.length + CHUNK_SIZE + CR_LF.length > BUFFER_SIZE) {
+ throw new FileUploadException("Boundary marker is too long");
+ }
+
+ this.encoding = getCharacterEncoding();
+
+ this.parameters = new HashMap<String, Param>();
+
+ InputStream input = new ControlledProgressInputStream(getInputStream());
+
+ this.sequenceMatcher = new ByteSequenceMatcher(input, BUFFER_SIZE);
+
+ setupProgressData();
+
+ readProlog();
+ }
+ }
+
+ public void parseRequest() {
+ canStop = true;
+
+ setupProgressData();
+
+ try {
+ initialize();
+
+ while (!sequenceMatcher.isEOF()) {
+ readNext();
+ }
+ } catch (IOException e) {
+ this.cancel();
+
+ if (!this.shouldStop) {
+ throw new FileUploadException("IO Error parsing multipart request", e);
+ }
+ } finally {
+ canStop = false;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setupProgressData() {
+ if (percentMap == null || requestSizeMap == null) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext != null) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ if (externalContext != null) {
+ Map<String, Object> sessionMap = externalContext.getSessionMap();
+ if (sessionMap != null) {
+ String uploadId = getUploadId();
+
+ synchronized (sessionMap) {
+ if (percentMap == null) {
+ percentMap = (Map<String, Object>) sessionMap.get(PERCENT_BEAN_NAME);
+ if (percentMap == null) {
+ percentMap = new ConcurrentHashMap<String, Object>();
+ sessionMap.put(PERCENT_BEAN_NAME, percentMap);
+ }
+ }
+
+ if (requestSizeMap == null) {
+ requestSizeMap = (Map<String, Integer>) sessionMap.get(REQUEST_SIZE_BEAN_NAME);
+ if (requestSizeMap == null) {
+ requestSizeMap = new ConcurrentHashMap<String, Integer>();
+ sessionMap.put(REQUEST_SIZE_BEAN_NAME, requestSizeMap);
+ }
+ }
+ }
+
+ percentMap.put(uploadId, Double.valueOf(0));
+
+ requestSizeMap.put(uploadId, getSize());
+ }
+ }
+ }
+ }
+ }
+
+ private void fillProgressInfo() {
+ setupProgressData();
+
+ if (percentMap != null) {
+ Double percent = (Double) (100.0 * this.bytesRead / this.contentLength);
+ percentMap.put(uid, percent);
+ // this.percent = percent;
+ }
+ }
+
+ private byte[] getBoundaryMarker(String contentType) {
+ Map<String, String> params = parseParams(contentType, ";");
+ String boundaryStr = (String) params.get("boundary");
+
+ if (boundaryStr == null) {
+ return null;
+ }
+
+ try {
+ return boundaryStr.getBytes("ISO-8859-1");
+ } catch (UnsupportedEncodingException e) {
+ return boundaryStr.getBytes();
+ }
+ }
+
+ private Map<String, String> parseParams(String paramStr, String separator) {
+ Map<String, String> paramMap = new HashMap<String, String>();
+ parseParams(paramStr, separator, paramMap);
+ return paramMap;
+ }
+
+ private void parseParams(String paramStr, String separator, Map<String, String> paramMap) {
+ String[] parts = paramStr.split(separator);
+
+ for (String part : parts) {
+ Matcher m = PARAM_VALUE_PATTERN.matcher(part);
+ if (m.matches()) {
+ String key = m.group(1);
+ String value = m.group(2);
+
+ // Strip double quotes
+ if (value.startsWith("\"") && value.endsWith("\"")) {
+ value = value.substring(1, value.length() - 1);
+ }
+ if (!"filename".equals(key)) {
+ paramMap.put(key, value);
+ } else {
+ paramMap.put(key, parseFileName(paramStr));
+ }
+ }
+ }
+ }
+
+ private String parseFileName(String parseStr) {
+ Matcher m = FILE_NAME_PATTERN.matcher(parseStr);
+ if (m.matches()) {
+ String name = m.group(1);
+ if (name.startsWith("&")) {
+ return decodeFileName(name);
+ } else {
+ return name;
+ }
+ }
+ return null;
+ }
+
+ private Param getParam(String name) {
+ Param param = null;
+ if (parameters != null) {
+ param = parameters.get(name);
+ }
+
+ if (param == null) {
+ if (!canceled) {
+ try {
+ initialize();
+
+ while (param == null && !sequenceMatcher.isEOF()) {
+ readNext();
+ param = parameters.get(name);
+ }
+ } catch (IOException e) {
+ this.cancel();
+ throw new FileUploadException("IO Error parsing multipart request", e);
+ }
+ }
+ }
+
+ return param;
+ }
+
+ public Integer getSize() {
+ return contentLength;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Enumeration getParameterNames() {
+ if (parameters == null) {
+ parseRequest();
+ }
+
+ return Collections.enumeration(parameters.keySet());
+ }
+
+ public byte[] getFileBytes(String name) {
+ Param p = getParam(name);
+ return (p != null && p instanceof FileParam) ? ((FileParam) p).getData() : null;
+ }
+
+ @Override
+ public String getParameter(String name) {
+ Param p = getParam(name);
+ if (p != null && p instanceof ValueParam) {
+ ValueParam vp = (ValueParam) p;
+ if (vp.getValue() instanceof String) {
+ return (String) vp.getValue();
+ }
+ } else if (p != null && p instanceof FileParam) {
+ return "---BINARY DATA---";
+ } else {
+ return super.getParameter(name);
+ }
+
+ return null;
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ parseRequest();
+
+ Param p = getParam(name);
+ if (p != null && p instanceof ValueParam) {
+ ValueParam vp = (ValueParam) p;
+ if (vp.getValue() instanceof List<?>) {
+ @SuppressWarnings("unchecked")
+ List<String> vals = (List<String>) vp.getValue();
+ String[] values = new String[vals.size()];
+ vals.toArray(values);
+ return values;
+ } else {
+ return new String[] {(String) vp.getValue()};
+ }
+ } else {
+ return super.getParameterValues(name);
+ }
+ }
+
+ @Override
+ public Map<String, Object> getParameterMap() {
+ if (parameters == null) {
+ parseRequest();
+ }
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> params = new HashMap<String, Object>(super.getParameterMap());
+
+ for (String name : parameters.keySet()) {
+ Param p = parameters.get(name);
+ if (p instanceof ValueParam) {
+ ValueParam vp = (ValueParam) p;
+ if (vp.getValue() instanceof String) {
+ params.put(name, vp.getValue());
+ } else if (vp.getValue() instanceof List) {
+ params.put(name, getParameterValues(name));
+ }
+ }
+ }
+
+ return params;
+ }
+
+ public UploadItem getUploadItem(String name) {
+ Param param = getParam(name);
+ if (param instanceof FileParam) {
+ FileParam fileParam = (FileParam) param;
+ return new UploadItem(fileParam.getFilename(), fileParam.getFileSize(), fileParam.getContentType(),
+ fileParam.getFile());
+ } else {
+ return null;
+ }
+ }
+
+ public boolean isFormUpload() {
+ return "_richfaces_form_upload".equals(uid);
+ }
+
+ @Override
+ public String getHeader(String name) {
+ if ("Accept".equals(name)) {
+ return TEXT_HTML;
+ } else if ("Faces-Request".equals(name)) {
+ return "partial/ajax";
+ } else {
+ return super.getHeader(name);
+ }
+ }
+
+ public void stop() {
+ if (canStop) {
+ shouldStop = true;
+ }
+ }
+
+ public boolean isStopped() {
+ return this.shouldStop;
+ }
+
+ public boolean isDone() {
+ return !(this.shouldStop && (this.canceled || this.contentLength != null
+ && this.contentLength.intValue() != this.bytesRead));
+ }
+
+ @Override
+ public String getContentType() {
+ return "application/x-www-form-urlencoded";
+ }
+
+ public String getUploadId() {
+ return uid;
+ }
+
+ public void clearRequestData() {
+ String uploadId = getUploadId();
+
+ if (percentMap != null) {
+ percentMap.remove(uploadId);
+ }
+
+ if (requestSizeMap != null) {
+ requestSizeMap.remove(uploadId);
+ }
+ }
+}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/Param.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.request;
-
-import java.io.IOException;
-
-import org.richfaces.request.ByteSequenceMatcher.BytesHandler;
-
-abstract class Param implements BytesHandler {
- private String name;
-
- public Param(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public abstract void complete() throws IOException;
-}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request/Param.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/Param.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.request;
+
+import java.io.IOException;
+
+import org.richfaces.request.ByteSequenceMatcher.BytesHandler;
+
+abstract class Param implements BytesHandler {
+ private String name;
+
+ public Param(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public abstract void complete() throws IOException;
+}
\ No newline at end of file
Deleted: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright ${year}, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.richfaces.request;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-class ValueParam extends Param {
-
- private Object value = null;
- private ByteArrayOutputStream buf = new ByteArrayOutputStream();
- private String encoding;
-
- public ValueParam(String name, String encoding) {
- super(name);
- this.encoding = encoding;
- }
-
- @SuppressWarnings("unchecked")
- public void complete() throws IOException {
- String val = this.encoding == null ? new String(buf.toByteArray()) : new String(buf.toByteArray(),
- this.encoding);
- if (value == null) {
- value = val;
- } else {
- if (!(value instanceof List<?>)) {
- List<String> v = new ArrayList<String>();
- v.add((String) value);
- value = v;
- }
-
- ((List<String>) value).add(val);
- }
- buf.reset();
- }
-
- public Object getValue() {
- return value;
- }
-
- public void handle(byte[] bytes, int length) throws IOException {
- // read += length;
- buf.write(bytes, 0, length);
- }
-}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/request/ValueParam.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.request;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+class ValueParam extends Param {
+
+ private Object value = null;
+ private ByteArrayOutputStream buf = new ByteArrayOutputStream();
+ private String encoding;
+
+ public ValueParam(String name, String encoding) {
+ super(name);
+ this.encoding = encoding;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void complete() throws IOException {
+ String val = this.encoding == null ? new String(buf.toByteArray()) : new String(buf.toByteArray(),
+ this.encoding);
+ if (value == null) {
+ value = val;
+ } else {
+ if (!(value instanceof List<?>)) {
+ List<String> v = new ArrayList<String>();
+ v.add((String) value);
+ value = v;
+ }
+
+ ((List<String>) value).add(val);
+ }
+ buf.reset();
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void handle(byte[] bytes, int length) throws IOException {
+ // read += length;
+ buf.write(bytes, 0, length);
+ }
+}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java (from rev 20419, trunk/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/java/org/richfaces/view/facelets/FileUploadHandler.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.richfaces.view.facelets;
+
+import javax.el.MethodExpression;
+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.richfaces.component.AbstractFileUpload;
+import org.richfaces.event.FileUploadListener;
+import org.richfaces.event.UploadEvent;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FileUploadHandler extends ComponentHandler {
+
+ public FileUploadHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(new MetaRule() {
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(AbstractFileUpload.class)) {
+ if ("fileUploadListener".equals(name)) {
+ return new MethodMetadata(attribute, UploadEvent.class) {
+ @Override
+ public void applyMetadata(final FaceletContext ctx, Object instance) {
+ final MethodExpression expression = getMethodExpression(ctx);
+ ((AbstractFileUpload) instance).addFileUploadListener(new FileUploadListener(){
+ public void processUpload(UploadEvent event) {
+ expression.invoke(ctx.getFacesContext().getELContext(), new Object[] {event});
+ }
+ });
+ }
+ };
+ }
+ }
+ return null;
+ }
+ });
+ return metaRuleset;
+ }
+}
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/fileupload.faces-config.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<faces-config version="2.0"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <factory>
+ <partial-view-context-factory>org.richfaces.context.FileUploadPartialViewContextFactory</partial-view-context-factory>
+ </factory>
+</faces-config>
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.ecss 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+.rf-fu {
+ background: '#{richSkin.generalBackgroundColor}';
+ border-color: '#{richSkin.panelBorderColor}';
+ border-style: solid;
+ border-width: 1px;
+ width: 400px; /*TODO Remove it*/
+}
+
+.rf-fu-hdr {
+ background-color: '#{richSkin.headerBackgroundColor}';
+ background-image: url("#{resource['org.richfaces.renderkit.html.GradientA']}");
+ border-color: '#{richSkin.headerBackgroundColor}';
+ border-style: solid;
+ border-width: 1px;
+ margin-left: 1px;
+ margin-top: 1px;
+ white-space: nowrap;
+}
+
+.rf-fu-lst {
+ height: 210px; /*TODO Remove it*/
+ overflow-x: hidden;
+ overflow-y: auto;
+}
+
+.rf-fu-cntr-hdn {
+ display: none;
+}
+
+.rf-fu-btns-lft, .rf-fu-btns-rgh, .rf-fu-itm-lft, .rf-fu-itm-rgh {
+ display: inline-block;
+ overflow: hidden;
+}
+
+.rf-fu-btns-lft {
+ width: 66%;
+}
+
+.rf-fu-btns-rgh {
+ text-align: right;
+ width: 34%;
+}
+
+.rf-fu-btn-add, .rf-fu-btn-add-dis, .rf-fu-btn-upl, .rf-fu-btn-clr {
+ background-position:left top;
+ background-repeat:repeat-x;
+ border-style: solid;
+ border-width: 1px;
+ cursor: default;
+ display: inline-block;
+ margin: 4px;
+ vertical-align: top;
+}
+
+.rf-fu-btn-add, .rf-fu-btn-upl, .rf-fu-btn-clr {
+ background-color: '#{richSkin.trimColor}';
+ background-image: url("#{resource['org.richfaces.images:fuBtnGrad.png']}");
+ border-color: '#{richSkin.panelBorderColor}';
+}
+
+.rf-fu-btn-add-dis {
+ background-color: '#{richSkin.tableFooterBackgroundColor}';
+ background-image: url("#{resource['org.richfaces.images:fuBtnDisGrad.png']}");
+ border-color: '#{richSkin.tableFooterBackgroundColor}';
+}
+
+.rf-fu-btn-upl, .rf-fu-btn-clr {
+ display: none;
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st, .rf-fu-itm-lnk {
+ font-family: '#{richSkin.generalFamilyFont}';
+ font-size: '#{richSkin.generalSizeFont}';
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr, .rf-fu-itm-lbl, .rf-fu-itm-st {
+ color: '#{richSkin.generalTextColor}';
+}
+
+.rf-fu-btn-cnt-add, .rf-fu-btn-cnt-add-dis, .rf-fu-btn-cnt-upl, .rf-fu-btn-cnt-clr {
+ background-position: 2px 2px;
+ background-repeat: no-repeat;
+ display: inline-block;
+ padding: 3px 5px 3px 21px;
+}
+
+.rf-fu-btn-cnt-add {
+ background-image: url("#{resource['org.richfaces:fu-add.gif']}");
+ overflow: hidden;
+ position: relative;
+}
+
+.rf-fu-btn-cnt-add-dis {
+ background-image: url("#{resource['org.richfaces:fu-add-dis.gif']}");
+ color: '#{richSkin.tabDisabledTextColor}';
+}
+
+.rf-fu-btn-cnt-upl, .rf-fu-itm-st {
+ font-weight: bold;
+}
+
+.rf-fu-btn-cnt-upl {
+ background-image: url("#{resource['org.richfaces:fu-upl.gif']}");
+}
+
+.rf-fu-btn-cnt-clr {
+ background-image: url("#{resource['org.richfaces:fu-clr.gif']}");
+}
+
+.rf-fu-inp-cntr {
+ display: block;
+ height: 1px;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.rf-fu-inp {
+ filter: "alpha(opacity=0)";
+ font-size: 10em;
+ margin: 0;
+ opacity: 0;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.rf-fu-itm {
+ border-bottom-color: '#{richSkin.panelBorderColor}';
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ padding: 12px;
+ white-space: nowrap;
+}
+
+.rf-fu-itm-lft, .rf-fu-itm-rgh {
+ vertical-align: middle;
+}
+
+.rf-fu-itm-lft {
+ width: 85%;
+}
+
+.rf-fu-itm-rgh {
+ width: 14%;
+}
+
+.rf-fu-itm-lnk {
+ color: '#{richSkin.generalLinkColor}';
+}
+
+.rf-fu-itm-st {
+ display: none;
+ margin-top: 5px;
+}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fileupload.js 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,274 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright ${year}, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+(function(richfaces, jQuery) {
+
+ var UID = "rf_fu_uid";
+
+ var ITEM_HTML = '<div class="rf-fu-itm">'
+ + '<span class="rf-fu-itm-lft"><span class="rf-fu-itm-lbl"/><span class="rf-fu-itm-st"/></span>'
+ + '<span class="rf-fu-itm-rgh"><a href="javascript:void(0)" class="rf-fu-itm-lnk"/></span></div>';
+
+ var ITEM_STATE = {
+ NEW: "new",
+ UPLOADING: "uploading",
+ DONE: "done",
+ SIZE_EXCEEDED: "sizeExceeded",
+ STOPPED: "stopped",
+ SERVER_ERROR: "serverError"
+ };
+
+ var pressButton = function(event) {
+ jQuery(this).children(":first").css("background-position", "3px 3px").css("padding", "4px 4px 2px 22px");
+ };
+
+ var unpressButton = function(event) {
+ jQuery(this).children(":first").css("background-position", "2px 2px").css("padding", "3px 5px 3px 21px");
+ };
+
+ richfaces.ui = richfaces.ui || {};
+
+ richfaces.ui.FileUpload = richfaces.BaseComponent.extendClass({
+
+ name: "FileUpload",
+
+ items: [],
+ submitedItems: [],
+
+ doneLabel: "Done",
+ sizeExceededLabel: "File size is exceeded",
+ stoppedLabel: "",
+ serverErrorLabel: "Server error",
+ clearLabel: "Clear",
+ deleteLabel: "Delete",
+
+ init: function(id, options) {
+ this.id = id;
+ jQuery.extend(this, options);
+ if (this.acceptedTypes) {
+ this.acceptedTypes = jQuery.trim(this.acceptedTypes).split(/\s*,\s*/);
+ }
+ this.element = jQuery(this.attachToDom());
+ this.form = this.element.parents("form:first");
+ var header = this.element.children(".rf-fu-hdr:first");
+ var leftButtons = header.children(".rf-fu-btns-lft:first");
+ this.addButton = leftButtons.children(".rf-fu-btn-add:first");
+ this.uploadButton = this.addButton.next();
+ this.clearButton = leftButtons.next().children(".rf-fu-btn-clr:first");
+ this.inputContainer = this.addButton.find(".rf-fu-inp-cntr:first");
+ this.input = this.inputContainer.children("input");
+ this.list = header.next();
+ this.hiddenContainer = this.list.next();
+ this.iframe = this.hiddenContainer.children("iframe:first");
+ this.progressBarElement = this.iframe.next();
+ this.progressBar = richfaces.$(this.progressBarElement);
+ this.cleanInput = this.input.clone();
+ this.addProxy = jQuery.proxy(this.__addItem, this);
+ this.input.change(this.addProxy);
+ this.addButton.mousedown(pressButton).mouseup(unpressButton).mouseout(unpressButton);
+ this.uploadButton.click(jQuery.proxy(this.__startUpload, this)).mousedown(pressButton)
+ .mouseup(unpressButton).mouseout(unpressButton);
+ this.clearButton.click(jQuery.proxy(this.__removeAllItems, this)).mousedown(pressButton)
+ .mouseup(unpressButton).mouseout(unpressButton);
+ this.iframe.load(jQuery.proxy(this.__load, this));
+ if (this.onfilesubmit) {
+ richfaces.Event.bind(this.element, "onfilesubmit", new Function("event", this.onfilesubmit));
+ }
+ if (this.onuploadcomplete) {
+ richfaces.Event.bind(this.element, "onuploadcomplete", new Function("event", this.onuploadcomplete));
+ }
+ },
+
+ __addItem: function() {
+ var fileName = this.input.val();
+ if (this.__accept(fileName) && (!this.noDuplicate || !this.__isFileAlreadyAdded(fileName))) {
+ this.input.hide();
+ this.input.unbind("change", this.addProxy);
+ var item = new Item(this);
+ this.list.append(item.getJQuery());
+ this.items.push(item);
+ this.input = this.cleanInput.clone();
+ this.inputContainer.append(this.input);
+ this.input.change(this.addProxy);
+ this.__updateButtons();
+ }
+ },
+
+ __removeItem: function(item) {
+ this.items.splice(this.items.indexOf(item), 1);
+ this.submitedItems.splice(this.submitedItems.indexOf(item), 1);
+ this.__updateButtons();
+ },
+
+ __removeAllItems: function(item) {
+ this.inputContainer.children(":not(:visible)").remove();
+ this.list.empty();
+ this.items.splice(0);
+ this.submitedItems.splice(0);
+ this.__updateButtons();
+ },
+
+ __updateButtons: function() {
+ if (!this.loadableItem && this.list.children(".rf-fu-itm").size()) {
+ if (this.items.length) {
+ this.uploadButton.css("display", "inline-block");
+ } else {
+ this.uploadButton.hide();
+ }
+ this.clearButton.css("display", "inline-block");
+ } else {
+ this.uploadButton.hide();
+ this.clearButton.hide();
+ }
+ },
+
+ __startUpload: function() {
+ this.loadableItem = this.items.shift();
+ this.__updateButtons();
+ this.loadableItem.startUploading();
+ },
+
+ __submit: function() {
+ var originalAction = this.form.attr("action");
+ var originalEncoding = this.form.attr("encoding");
+ var originalEnctype = this.form.attr("enctype");
+ try {
+ this.form.attr("action", originalAction + "?" + UID + "=" + this.loadableItem.uid);
+ this.form.attr("encoding", "multipart/form-data");
+ this.form.attr("enctype", "multipart/form-data");
+ richfaces.submitForm(this.form, {"org.richfaces.ajax.component": this.id}, this.id);
+ richfaces.Event.fire(this.element, "onfilesubmit", this.loadableItem.model);
+ } finally {
+ this.form.attr("action", originalAction);
+ this.form.attr("encoding", originalEncoding);
+ this.form.attr("enctype", originalEnctype);
+ this.loadableItem.input.removeAttr("name");
+ }
+ },
+
+ __load: function(event) {
+ if (this.loadableItem) {
+ var contentDocument = event.target.contentWindow.document;
+ contentDocument = contentDocument.XMLDocument || contentDocument;
+ var documentElement = contentDocument.documentElement;
+ var responseStatus, id;
+ if (documentElement.tagName.toUpperCase() == "PARTIAL-RESPONSE") {
+ responseStatus = ITEM_STATE.DONE;
+ } else if ((id = documentElement.id) && id.indexOf(UID + this.loadableItem.uid + ":") == 0) {
+ responseStatus = id.split(":")[1];
+ }
+ if (responseStatus) {
+ responseStatus == ITEM_STATE.DONE && jsf.ajax.response({responseXML: contentDocument}, {});
+ this.loadableItem.finishUploading(responseStatus);
+ this.submitedItems.push(this.loadableItem);
+ if (responseStatus == ITEM_STATE.DONE && this.items.length) {
+ this.__startUpload();
+ } else {
+ this.loadableItem = null;
+ this.__updateButtons();
+ var items = [];
+ for (var i in this.submitedItems) {
+ items.push(this.submitedItems[i].model);
+ }
+ for (var i in this.items) {
+ items.push(this.items[i].model);
+ }
+ richfaces.Event.fire(this.element, "onuploadcomplete", items);
+ }
+ }
+ }
+ },
+
+ __accept: function(fileName) {
+ var result = !this.acceptedTypes;
+ for (var i = 0; !result && i < this.acceptedTypes.length; i++) {
+ var extension = this.acceptedTypes[i];
+ result = fileName.indexOf(extension, fileName.length - extension.length) !== -1;
+ }
+ return result;
+ },
+
+ __isFileAlreadyAdded: function(fileName) {
+ var result = false;
+ for (var i = 0; !result && i < this.items.length; i++) {
+ result = this.items[i].model.name == fileName;
+ }
+ result = result || (this.loadableItem && this.loadableItem.model.name == fileName);
+ for (var i = 0; !result && i < this.submitedItems.length; i++) {
+ result = this.submitedItems[i].model.name == fileName;
+ }
+ return result;
+ }
+ });
+
+ var Item = function(fileUpload) {
+ this.fileUpload = fileUpload;
+ this.input = fileUpload.input;
+ this.model = {name: this.input.val(), state: ITEM_STATE.NEW};
+ };
+
+ jQuery.extend(Item.prototype, {
+ getJQuery: function() {
+ this.element = jQuery(ITEM_HTML);
+ var leftArea = this.element.children(".rf-fu-itm-lft:first");
+ this.label = leftArea.children(".rf-fu-itm-lbl:first");
+ this.state = this.label.nextAll(".rf-fu-itm-st:first");
+ this.link = leftArea.next().children("a");
+ this.label.html(this.model.name);
+ this.link.html(this.fileUpload["deleteLabel"]);
+ this.link.click(jQuery.proxy(this.removeOrStop, this));
+ return this.element;
+ },
+
+ removeOrStop: function() {
+ this.input.remove();
+ this.element.remove();
+ this.fileUpload.__removeItem(this);
+ },
+
+ startUploading: function() {
+ this.state.css("display", "block");
+ this.link.html("");
+ this.input.attr("name", this.fileUpload.id);
+ this.model.state = ITEM_STATE.UPLOADING;
+ this.uid = Math.random();
+ this.fileUpload.__submit();
+ var params = {};
+ params[UID] = this.uid;
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.setValue(0);
+ this.state.html(this.fileUpload.progressBarElement.detach());
+ this.fileUpload.progressBar.enable(params);
+ }
+ },
+
+ finishUploading: function(state) {
+ if (this.fileUpload.progressBar) {
+ this.fileUpload.progressBar.disable();
+ this.fileUpload.hiddenContainer.append(this.fileUpload.progressBarElement.detach());
+ }
+ this.input.remove();
+ this.state.html(this.fileUpload[state + "Label"]);
+ this.link.html(this.fileUpload["clearLabel"]);
+ this.model.state = state;
+ }
+ });
+}(window.RichFaces, jQuery));
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add-dis.gif)
===================================================================
(Binary files differ)
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-add.gif)
===================================================================
(Binary files differ)
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-clr.gif)
===================================================================
(Binary files differ)
Copied: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif (from rev 20419, trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/fu-upl.gif)
===================================================================
(Binary files differ)
Modified: branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/input/ui/src/main/resources/META-INF/richfaces/resource-mappings.properties 2010-12-06 19:04:32 UTC (rev 20420)
@@ -10,4 +10,8 @@
org.richfaces.images\:inplaceBtnPressGrad.png=org.richfaces.renderkit.html.BaseGradient\
{width=8, height=18, baseColorParam=tabBackgroundColor, gradientColorParam=generalBackgroundColor}
org.richfaces.images\:insldrTrackGrad.png=org.richfaces.renderkit.html.BaseGradient\
- {width=7, height=10, gradientHeight=7, baseColorParam=tabBackgroundColor, gradientColorParam=controlBackgroundColor}
\ No newline at end of file
+ {width=7, height=10, gradientHeight=7, baseColorParam=tabBackgroundColor, gradientColorParam=controlBackgroundColor}
+org.richfaces.images\:fuBtnGrad.png=org.richfaces.renderkit.html.BaseGradient\
+ {baseColorParam=additionalBackgroundColor, gradientColorParam=trimColor, height=18, width=1}
+org.richfaces.images\:fuBtnDisGrad.png=org.richfaces.renderkit.html.BaseGradient\
+ {baseColorParam=tableSubfooterBackgroundColor, gradientColorParam=tableFooterBackgroundColor, height=18, width=1}
\ No newline at end of file
Copied: branches/RF-8742-1/ui/input/ui/src/main/templates/fileupload.template.xml (from rev 20419, trunk/ui/input/ui/src/main/templates/fileupload.template.xml)
===================================================================
--- branches/RF-8742-1/ui/input/ui/src/main/templates/fileupload.template.xml (rev 0)
+++ branches/RF-8742-1/ui/input/ui/src/main/templates/fileupload.template.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+
+You should have received a copy of the GNU Lesser General Public
+License along with this software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site: http://www.fsf.org.
+-->
+<cdk:root xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el" xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+ xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite" xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.FileUploadRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.FileUploadRendererBase</cdk:superclass>
+ <cdk:component-family>org.richfaces.FileUpload</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.FileUploadRenderer</cdk:renderer-type>
+ <cdk:resource-dependency library="org.richfaces" name="fileupload.ecss" />
+ <cdk:resource-dependency library="org.richfaces" name="ajax.reslib" />
+ <cdk:resource-dependency library="org.richfaces" name="base-component.reslib" />
+ <cdk:resource-dependency name="richfaces-event.js" />
+ <cdk:resource-dependency library="org.richfaces" name="fileupload.js" />
+ </cc:interface>
+ <cc:implementation>
+ <cdk:object name="attributes" value="#{component.attributes}"/>
+ <cdk:object name="enabled" value="#{attributes['enabled']}"/>
+ <div id="#{clientId}" class="rf-fu #{attributes['styleClass']}"
+ cdk:passThroughWithExclusions="">
+ <div class="rf-fu-hdr">
+ <span class="rf-fu-btns-lft">
+ <span class="rf-fu-btn-add#{enabled ? '' : '-dis'}">
+ <span class="rf-fu-btn-cnt-add#{enabled ? '' : '-dis'}">
+ <c:if test="#{enabled}">
+ <span class="rf-fu-inp-cntr"> <!-- This span is needed for IE7 only. -->
+ <input type="file" class="rf-fu-inp"/>
+ </span>
+ </c:if>
+ <cdk:object name="addLabel" value="#{attributes['addLabel']}"/>
+ #{addLabel != null ? addLabel : 'Add...'}
+ </span>
+ </span>
+ <c:if test="#{enabled}">
+ <span class="rf-fu-btn-upl">
+ <cdk:object name="uploadLabel" value="#{attributes['uploadLabel']}"/>
+ <span class="rf-fu-btn-cnt-upl">#{uploadLabel != null ? uploadLabel : 'Upload'}</span>
+ </span>
+ </c:if>
+ </span>
+ <c:if test="#{enabled}">
+ <span class="rf-fu-btns-rgh">
+ <span class="rf-fu-btn-clr">
+ <cdk:object name="clearAllLabel" value="#{attributes['clearAllLabel']}"/>
+ <span class="rf-fu-btn-cnt-clr">#{clearAllLabel != null ? clearAllLabel : 'Clear All'}</span>
+ </span>
+ </span>
+ </c:if>
+ </div>
+ <div class="rf-fu-lst"/>
+ <c:if test="#{enabled}">
+ <div class="rf-fu-cntr-hdn">
+ <iframe name="#{clientId}"/>
+ <cdk:object name="progressBar" value="#{component.facets['progress']}"/>
+ <c:if test="#{progressBar != null and progressBar.isRendered()}">
+ <cdk:call expression="progressBar.encodeAll(facesContext)" />
+ </c:if>
+ </div>
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption attributes="acceptedTypes noDuplicate onfilesubmit onuploadcomplete doneLabel
+ sizeExceededLabel stoppedLabel serverErrorLabel clearLabel deleteLabel"/>
+ </cdk:scriptObject>
+ <script type="text/javascript">new RichFaces.ui.FileUpload(#{toScriptArgs(clientId, options)});</script>
+ </c:if>
+ </div>
+ </cc:implementation>
+</cdk:root>
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractTree.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -196,6 +196,19 @@
public abstract Object getRender();
+ public abstract boolean isLimitRender();
+
+ @Attribute(events = @EventName("begin"))
+ public abstract String getOnbegin();
+
+ @Attribute(events = @EventName("beforedomupdate"))
+ public abstract String getOnbeforedomupdate();
+
+ @Attribute(events = @EventName("complete"))
+ public abstract String getOncomplete();
+
+ public abstract String getStatus();
+
@Override
public String getFamily() {
return COMPONENT_FAMILY;
@@ -256,10 +269,6 @@
}
public AbstractTreeNode findTreeNodeComponent() {
- if (getRowKey() == null) {
- return null;
- }
-
FacesContext facesContext = getFacesContext();
String nodeType = getNodeType();
@@ -280,6 +289,7 @@
return null;
}
+ //TODO default TreeNode is created when getRowKey() == null but it's not used for presentational purposes
Application application = facesContext.getApplication();
AbstractTreeNode treeNode = (AbstractTreeNode) application.createComponent(AbstractTreeNode.COMPONENT_TYPE);
treeNode.setId("__defaultTreeNode");
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeEncoderBase.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -162,8 +162,7 @@
writeTreeNodeEndElement();
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ throw new FacesException(e.getMessage(), e);
}
}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeNodeRendererBase.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -53,6 +53,8 @@
private static final String TRIGGER_NODE_AJAX_UPDATE = "__TRIGGER_NODE_AJAX_UPDATE";
+ private static final String LOADING_FACET_NAME = "loading";
+
@Override
public void decode(FacesContext context, UIComponent component) {
super.decode(context, component);
@@ -168,4 +170,21 @@
TreeRenderingContext renderingContext = TreeRenderingContext.get(facesContext);
renderingContext.addHandlers(treeNode);
}
+
+ protected UIComponent getLoadingFacetIfApplicable(UIComponent component) {
+ AbstractTreeNode treeNode = (AbstractTreeNode) component;
+
+ AbstractTree tree = treeNode.findTreeComponent();
+
+ if (tree.getToggleType() != SwitchType.ajax) {
+ return null;
+ }
+
+ UIComponent facet = treeNode.getFacet(LOADING_FACET_NAME);
+ if (facet == null) {
+ facet = tree.getFacet(LOADING_FACET_NAME);
+ }
+
+ return facet;
+ }
}
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/java/org/richfaces/renderkit/TreeRendererBase.java 2010-12-06 19:04:32 UTC (rev 20420)
@@ -23,7 +23,6 @@
import static org.richfaces.component.AbstractTree.SELECTION_META_COMPONENT_ID;
import static org.richfaces.renderkit.util.AjaxRendererUtils.AJAX_FUNCTION_NAME;
-import static org.richfaces.renderkit.util.AjaxRendererUtils.buildAjaxFunction;
import static org.richfaces.renderkit.util.AjaxRendererUtils.buildEventOptions;
import java.io.IOException;
@@ -66,8 +65,11 @@
private static final JSReference SOURCE_JS_REF = new JSReference("source");
+ private static final JSReference COMPLETE_JS_REF = new JSReference("complete");
+
private static final String SELECTION_STATE = "__SELECTION_STATE";
+
/**
* @author Nick Belaevski
*
@@ -98,10 +100,15 @@
return null;
}
- JSFunction ajaxFunction = buildAjaxFunction(context, component, AJAX_FUNCTION_NAME);
+ JSFunction ajaxFunction = new JSFunction(AJAX_FUNCTION_NAME);
+
+ ajaxFunction.addParameter(SOURCE_JS_REF);
+ ajaxFunction.addParameter(JSReference.EVENT);
+
AjaxEventOptions eventOptions = buildEventOptions(context, component);
- eventOptions.setAjaxComponent(SOURCE_JS_REF);
+ eventOptions.set("complete", COMPLETE_JS_REF);
+
eventOptions.setClientParameters(PARAMS_JS_REF);
if (!eventOptions.isEmpty()) {
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.ecss 2010-12-06 19:04:32 UTC (rev 20420)
@@ -27,6 +27,7 @@
.rf-tr-nd {
background: "url(#{resource['org.richfaces.images:line.png']}) repeat-y";
+ min-height: 0px;
}
.rf-tr-nd-last {
@@ -37,7 +38,7 @@
margin-left: 16px;
}
-.rf-trn-ico, .rf-trn-hnd {
+.rf-trn-ico, .rf-trn-hnd, .rf-trn-ldn-fct {
vertical-align: middle;
margin: 0px;
cursor: pointer;
@@ -78,3 +79,16 @@
.rf-tr-nd.rf-tr-nd-colps .rf-tr-nd {
display: none;
}
+
+.rf-trn-ldn-fct {
+ cursor: default;
+ display: none;
+}
+
+.rf-trn-ldn > .rf-trn-ldn-fct {
+ display: inline-block;
+}
+
+.rf-trn-ldn > .rf-trn-ldn-fct + .rf-trn-hnd {
+ display: none;
+}
\ No newline at end of file
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/tree.js 2010-12-06 19:04:32 UTC (rev 20420)
@@ -89,12 +89,16 @@
}
},
+ __getNodeContainer: function() {
+ return this.__rootElt.find(" > .rf-trn:first");
+ },
+
__getHandle: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-hnd:first");
+ return this.__getNodeContainer().find(" > .rf-trn-hnd:first");
},
__getContent: function() {
- return this.__rootElt.find(" > .rf-trn:first > .rf-trn-cnt:first");
+ return this.__getNodeContainer().find(" > .rf-trn-cnt:first");
},
__getIcons: function() {
@@ -156,7 +160,7 @@
},
__canBeToggled: function() {
- return !this.isLeaf() && !this.__rootElt.hasClass("rf-tr-nd-exp-nc");
+ return !this.isLeaf() && !this.__rootElt.hasClass("rf-tr-nd-exp-nc") && !this.__loading;
},
toggle: function() {
@@ -189,6 +193,16 @@
richfaces.Event.callHandler(this.__rootElt, "toggle");
},
+ __makeLoading: function() {
+ this.__loading = true;
+ this.__getNodeContainer().addClass("rf-trn-ldn");
+ },
+
+ __resetLoading: function() {
+ this.__loading = false;
+ this.__getNodeContainer().removeClass("rf-trn-ldn");
+ },
+
__changeToggleState: function(newState) {
if (!this.isLeaf()) {
if (newState ^ this.isExpanded()) {
@@ -216,7 +230,7 @@
case 'ajax':
case 'server':
//TODO - event?
- tree.__sendToggleRequest(null, this.getId(), newState);
+ tree.__sendToggleRequest(null, this, newState);
break;
}
}
@@ -314,7 +328,7 @@
this.__selectionType = options.selectionType || 'client';
if (options.ajaxSubmitFunction) {
- this.__ajaxSubmitFunction = new Function("event", "source", "params", options.ajaxSubmitFunction);
+ this.__ajaxSubmitFunction = new Function("event", "source", "params", "complete", options.ajaxSubmitFunction);
}
if (options.onbeforeselectionchange) {
@@ -387,15 +401,23 @@
},
__sendToggleRequest: function(event, toggleSource, newNodeState) {
+ var toggleSourceId = toggleSource.getId();
+
var clientParams = {};
- clientParams[toggleSource + NEW_NODE_TOGGLE_STATE] = newNodeState;
+ clientParams[toggleSourceId + NEW_NODE_TOGGLE_STATE] = newNodeState;
if (this.getToggleType() == 'server') {
var form = this.__treeRootElt.closest('form');
richfaces.submitForm(form, clientParams);
} else {
- clientParams[toggleSource + TRIGGER_NODE_AJAX_UPDATE] = newNodeState;
- this.__ajaxSubmitFunction(event, toggleSource, clientParams);
+ toggleSource.__makeLoading();
+ clientParams[toggleSourceId + TRIGGER_NODE_AJAX_UPDATE] = newNodeState;
+ this.__ajaxSubmitFunction(event, toggleSourceId, clientParams, function() {
+ var treeNode = richfaces.$(toggleSourceId);
+ if (treeNode) {
+ treeNode.__resetLoading();
+ }
+ });
}
},
@@ -425,7 +447,7 @@
return;
}
- this.__selectionInput.val(newSelection.toString());
+ this.__selectionInput.val(newSelection.getNodeString());
if (this.getSelectionType() == 'client') {
this.__updateSelection(newSelection);
Modified: branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml
===================================================================
--- branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/iteration/ui/src/main/templates/treeNode.template.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -25,7 +25,18 @@
<cdk:call expression="addClientEventHandlers(facesContext, component)" />
- <div class="#{concatClasses('rf-trn', component.attributes['styleClass'], tree.attributes['nodeClass'])}">
+ <div class="#{concatClasses('rf-trn', component.attributes['styleClass'], tree.attributes['nodeClass'])}"
+ cdk:passThroughWithExclusions="">
+ <cdk:object name="loadingFacet" type="UIComponent" value="#{getLoadingFacetIfApplicable(component)}" />
+
+ <c:if test="#{not empty loadingFacet and loadingFacet.isRendered()}">
+ <span class="rf-trn-ldn-fct">
+ <cdk:call>
+ loadingFacet.encodeAll(facesContext);
+ </cdk:call>
+ </span>
+ </c:if>
+
<span class="#{concatClasses(nodeState.handleClass, component.attributes['handleClass'], tree.attributes['handleClass'])}"></span>
<span class="rf-trn-cnt">
Modified: branches/RF-8742-1/ui/misc/pom.xml
===================================================================
--- branches/RF-8742-1/ui/misc/pom.xml 2010-12-06 18:16:22 UTC (rev 20419)
+++ branches/RF-8742-1/ui/misc/pom.xml 2010-12-06 19:04:32 UTC (rev 20420)
@@ -45,4 +45,4 @@
<url>http://fisheye.jboss.org/browse/richfaces/</url>
</scm>
-</project>
\ No newline at end of file
+</project>
Copied: branches/RF-8742-1/ui/misc/ui/src/main/java/org/richfaces/view (from rev 20419, trunk/ui/misc/ui/src/main/java/org/richfaces/view)
14 years, 1 month
JBoss Rich Faces SVN: r20419 - in trunk/ui/input: ui/src/main/java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-12-06 13:16:22 -0500 (Mon, 06 Dec 2010)
New Revision: 20419
Modified:
trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
Log:
RF-9497
Modified: trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java
===================================================================
--- trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 18:00:33 UTC (rev 20418)
+++ trunk/ui/input/api/src/main/java/org/richfaces/event/UploadEvent.java 2010-12-06 18:16:22 UTC (rev 20419)
@@ -20,8 +20,6 @@
*/
package org.richfaces.event;
-import java.util.List;
-
import javax.faces.component.UIComponent;
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
@@ -31,11 +29,11 @@
public class UploadEvent extends FacesEvent {
private static final long serialVersionUID = -7645197191376210068L;
- private List<UploadItem> uploadItems = null;
+ private UploadItem uploadItem = null;
- public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
+ public UploadEvent(UIComponent component, UploadItem uploadItem) {
super(component);
- this.uploadItems = uploadItems;
+ this.uploadItem = uploadItem;
}
public boolean isAppropriateListener(FacesListener listener) {
@@ -52,29 +50,6 @@
* @return the uploadItem
*/
public UploadItem getUploadItem() {
- if (uploadItems != null && uploadItems.size() > 0) {
- return uploadItems.get(0);
- }
- return null;
+ return uploadItem;
}
-
- /**
- * Return list of UploadItems
- *
- * @return the uploadItem
- * @since 3.2.2
- */
- public List<UploadItem> getUploadItems() {
- return uploadItems;
- }
-
- /**
- * Return true if multiple files were uploaded with form
- *
- * @return boolean
- * @since 3.2.2
- */
- public boolean isMultiUpload() {
- return uploadItems != null && uploadItems.size() > 1;
- }
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 18:00:33 UTC (rev 20418)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2010-12-06 18:16:22 UTC (rev 20419)
@@ -26,6 +26,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
import org.richfaces.request.MultipartRequest;
/**
@@ -38,9 +39,11 @@
protected void doDecode(FacesContext context, UIComponent component) {
ExternalContext externalContext = context.getExternalContext();
Object request = externalContext.getRequest();
- if (request instanceof MultipartRequest
- && externalContext.getRequestParameterMap().containsKey(component.getClientId(context))) {
- component.queueEvent(new UploadEvent(component, ((MultipartRequest) request).getUploadItems()));
+ if (request instanceof MultipartRequest) {
+ UploadItem uploadItem = ((MultipartRequest) request).getUploadItem(component.getClientId(context));
+ if (uploadItem != null) {
+ component.queueEvent(new UploadEvent(component, uploadItem));
+ }
}
}
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06 18:00:33 UTC (rev 20418)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/request/MultipartRequest.java 2010-12-06 18:16:22 UTC (rev 20419)
@@ -536,31 +536,6 @@
return (p != null && p instanceof FileParam) ? ((FileParam) p).getData() : null;
}
- public InputStream getFileInputStream(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getInputStream() : null;
- }
-
- public String getFileContentType(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getContentType() : null;
- }
-
- public Object getFile(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getFile() : null;
- }
-
- public String getFileName(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getFilename() : null;
- }
-
- public int getFileSize(String name) {
- Param p = getParam(name);
- return (p != null && p instanceof FileParam) ? ((FileParam) p).getFileSize() : -1;
- }
-
@Override
public String getParameter(String name) {
Param p = getParam(name);
@@ -623,12 +598,15 @@
return params;
}
- public List<UploadItem> getUploadItems() {
- List<UploadItem> uploadItems = new ArrayList<UploadItem>();
- for (String k : keys) {
- uploadItems.add(new UploadItem(getFileName(k), getFileSize(k), getFileContentType(k), getFile(k)));
+ public UploadItem getUploadItem(String name) {
+ Param param = getParam(name);
+ if (param instanceof FileParam) {
+ FileParam fileParam = (FileParam) param;
+ return new UploadItem(fileParam.getFilename(), fileParam.getFileSize(), fileParam.getContentType(),
+ fileParam.getFile());
+ } else {
+ return null;
}
- return uploadItems;
}
public boolean isFormUpload() {
14 years, 1 month
JBoss Rich Faces SVN: r20418 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 13:00:33 -0500 (Mon, 06 Dec 2010)
New Revision: 20418
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFiltering.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableScroller.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingColumn.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingComponentControl.java
Removed:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/facets.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/filtering.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-column.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-component-control.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java
Log:
rich:extendedDataTable - 74 tests for simple, facets, filtering and sorting (RFPL-918)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/facets.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/facets.xhtml 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/facets.xhtml 2010-12-06 18:00:33 UTC (rev 20418)
@@ -125,16 +125,16 @@
<h:inputText id="headerInput" value="#{richExtendedDataTableBean.facets['header']}" />
<h:outputLabel value="State Column Header:" />
- <h:inputText id="columnStateHeaderInput" value="#{richExtendedDataTableBean.facets['columnStateHeader']}" />
+ <h:inputText id="stateHeaderInput" value="#{richExtendedDataTableBean.facets['columnStateHeader']}" />
<h:outputLabel value="State Column Footer:" />
- <h:inputText id="columnStateFooterInput" value="#{richExtendedDataTableBean.facets['columnStateFooter']}" />
+ <h:inputText id="stateFooterInput" value="#{richExtendedDataTableBean.facets['columnStateFooter']}" />
<h:outputLabel value="Capital Column Header:" />
- <h:inputText id="columnCapitalHeaderInput" value="#{richExtendedDataTableBean.facets['columnCapitalHeader']}" />
+ <h:inputText id="capitalHeaderInput" value="#{richExtendedDataTableBean.facets['columnCapitalHeader']}" />
<h:outputLabel value="Capital Column Footer:" />
- <h:inputText id="columnCapitalFooterInput" value="#{richExtendedDataTableBean.facets['columnCapitalFooter']}" />
+ <h:inputText id="capitalFooterInput" value="#{richExtendedDataTableBean.facets['columnCapitalFooter']}" />
</h:panelGrid>
</a4j:ajax>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/filtering.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/filtering.xhtml 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/filtering.xhtml 2010-12-06 18:00:33 UTC (rev 20418)
@@ -79,14 +79,14 @@
<br/>
<h:outputText value="Show data in table: " />
<h:selectBooleanCheckbox id="noDataCheckbox" value="#{richExtendedDataTableBean.state}">
- <a4j:ajax render="richDataTable scroller1"/>
+ <a4j:ajax render="richEDT scroller1"/>
</h:selectBooleanCheckbox>
<br/><br/>
- <rich:dataScroller id="scroller1" for="richDataTable" page="#{richExtendedDataTableBean.page}" maxPages="7" render="richDataTable"/>
+ <rich:dataScroller id="scroller1" for="richEDT" page="#{richExtendedDataTableBean.page}" maxPages="7" render="richEDT"/>
</ui:define>
<ui:define name="component">
- <rich:extendedDataTable id="richDataTable"
+ <rich:extendedDataTable id="richEDT"
beforeselectionchange="#{richExtendedDataTableBean.attributes['beforeselectionchange'].value}"
clientFirst="#{richExtendedDataTableBean.attributes['clientFirst'].value}"
clientRows="#{richExtendedDataTableBean.attributes['clientRows'].value}"
@@ -138,7 +138,7 @@
</h:panelGroup>
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
<f:facet name="footer">
<h:outputText id="columnFooterSex" value="Sex" />
@@ -217,7 +217,7 @@
</rich:column>
<f:facet name="footer">
- <rich:dataScroller id="scroller2" for="richDataTable" page="#{richExtendedDataTableBean.page}" maxPages="7" render="richDataTable" />
+ <rich:dataScroller id="scroller2" for="richEDT" page="#{richExtendedDataTableBean.page}" maxPages="7" render="richEDT" />
</f:facet>
</rich:extendedDataTable>
</ui:define>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-column.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-column.xhtml 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-column.xhtml 2010-12-06 18:00:33 UTC (rev 20418)
@@ -113,7 +113,7 @@
<f:facet name="header">
<a4j:commandLink id="sortBySex" value="Sex" render="richEDT" action="#{richExtendedDataTableBean.sorting['columnSex'].reverseOrder}" />
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
</rich:column>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-component-control.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-component-control.xhtml 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richExtendedDataTable/sorting-using-component-control.xhtml 2010-12-06 18:00:33 UTC (rev 20418)
@@ -117,7 +117,7 @@
</rich:componentControl>
</h:commandLink>
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
</rich:column>
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -82,6 +82,8 @@
}
public void testRendered() {
+ assertTrue(model.isVisible());
+
attributes.setRendered(false);
assertFalse(model.isVisible());
@@ -91,6 +93,9 @@
}
public void testNoDataLabel() {
+ assertTrue(model.isVisible());
+ assertFalse(model.isNoData());
+
attributes.setNoDataLabel(NO_DATA);
attributes.setShowData(false);
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -25,7 +25,9 @@
import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+import org.richfaces.tests.metamer.ftest.abstractions.DataTable;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
import static org.jboss.test.selenium.locator.reference.ReferencedLocator.*;
/**
@@ -34,25 +36,78 @@
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
*/
-public class ExtendedDataTable extends AbstractModel<JQueryLocator> {
+public class ExtendedDataTable extends AbstractModel<JQueryLocator> implements DataTable {
AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
- ReferencedLocator<JQueryLocator> tableRows = ref(root, "> div.rf-edt-b table table tr");
+ ReferencedLocator<JQueryLocator> tbody = ref(root, "> div.rf-edt-b > div > table > tbody > tr > td > div.rf-edt-cnt > table > tbody");
+ ReferencedLocator<JQueryLocator> firstColumnRows = ref(tbody, "> tr > td:nth-child(1) > div.rf-edt-c > div.rf-edt-c-cnt");
+ ReferencedLocator<JQueryLocator> firstRowColumns = ref(tbody, "> tr:eq(0) > td > div.rf-edt-c > div.rf-edt-c-cnt");
+ ReferencedLocator<JQueryLocator> body = ref(root, "> div.rf-edt-b");
+ ReferencedLocator<JQueryLocator> columns = ref(tbody, "> tr");
+ JQueryLocator columnToElement = jq("td");
+ JQueryLocator elementToContent = jq("div.rf-edt-c > div.rf-edt-c-cnt");
+ ReferencedLocator<JQueryLocator> tableHeader = ref(root, "> div.rf-edt-tbl-hdr");
+ ReferencedLocator<JQueryLocator> columnHeader = ref(root, "> div.rf-edt-hdr > table > tbody > tr > td > div.rf-edt-cnt > table > tbody > tr > td");
+ JQueryLocator columnHeaderToContent = jq("div.rf-edt-hdr-c > div.rf-edt-hdr-c-cnt");
+ ReferencedLocator<JQueryLocator> columnFooter = ref(root, "> div.rf-edt-ftr > table > tbody > tr > td > div.rf-edt-cnt > table > tbody > tr > td");
+ JQueryLocator columnFooterToContent = jq("div.rf-edt-ftr-c > div.rf-edt-ftr-c-cnt");
+
public ExtendedDataTable(JQueryLocator root) {
super(root);
}
-
+
public ExtendedDataTable(String name, JQueryLocator root) {
super(name, root);
}
- public int getCountOfTableRows() {
- return selenium.getCount(tableRows);
- }
-
public String getTableText() {
return selenium.getText(root.getLocator());
}
+
+ @Override
+ public int getRows() {
+ return selenium.getCount(firstColumnRows);
+ }
+
+ @Override
+ public int getColumns() {
+ return selenium.getCount(firstRowColumns);
+ }
+
+ @Override
+ public boolean isVisible() {
+ return selenium.isElementPresent(root.getLocator()) && selenium.isVisible(root.getLocator());
+ }
+
+ @Override
+ public boolean isNoData() {
+ return selenium.isElementPresent(body) && getRows() == 0;
+ }
+
+ @Override
+ public JQueryLocator getNoData() {
+ return body.getReferenced();
+ }
+
+ @Override
+ public JQueryLocator getElement(int column, int row) {
+ return columns.getNthOccurence(row).getChild(columnToElement).getNthChildElement(column).getChild(elementToContent);
+ }
+
+ @Override
+ public JQueryLocator getColumnHeader(int column) {
+ return columnHeader.getNthOccurence(column).getChild(columnHeaderToContent);
+ }
+
+ @Override
+ public JQueryLocator getColumnFooter(int column) {
+ return columnFooter.getNthOccurence(column).getChild(columnFooterToContent);
+ }
+
+ @Override
+ public JQueryLocator getHeader() {
+ return tableHeader.getReferenced();
+ }
}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFacets.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFacets.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFacets.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFacetsTest;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableFacets extends DataTableFacetsTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/facets.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ public void testNoDataInstantChange() {
+ super.testNoDataInstantChange();
+ }
+
+ @Test
+ public void testNoDataEmpty() {
+ super.testNoDataEmpty();
+ }
+
+ @Test
+ public void testNoDataLabelWithEmptyNoDataFacet() {
+ super.testNoDataLabelWithEmptyNoDataFacet();
+ }
+
+ @Test
+ public void testHeaderInstantChange() {
+ super.testHeaderInstantChange();
+ }
+
+ @Test
+ public void testHeaderEmpty() {
+ super.testHeaderEmpty();
+ }
+
+ @Test
+ public void testStateHeaderInstantChange() {
+ super.testStateHeaderInstantChange();
+ }
+
+ @Test
+ public void testStateHeaderEmpty() {
+ super.testStateHeaderEmpty();
+ }
+
+ @Test
+ public void testStateFooterInstantChange() {
+ super.testStateFooterInstantChange();
+ }
+
+ @Test
+ public void testStateFooterEmpty() {
+ super.testStateFooterEmpty();
+ }
+
+ @Test
+ public void testCapitalHeaderInstantChange() {
+ super.testCapitalHeaderInstantChange();
+ }
+
+ @Test
+ public void testCapitalHeaderEmpty() {
+ super.testCapitalHeaderEmpty();
+ }
+
+ @Test
+ public void testCapitalFooterInstantChange() {
+ super.testCapitalFooterInstantChange();
+ }
+
+ @Test
+ public void testCapitalFooterEmpty() {
+ super.testCapitalFooterEmpty();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFiltering.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFiltering.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableFiltering.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFilteringTest;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableFiltering extends DataTableFilteringTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/filtering.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ @Override
+ public void testFilterSex() {
+ super.testFilterSex();
+ }
+
+ @Test
+ @Override
+ public void testFilterName() {
+ super.testFilterName();
+ }
+
+ @Test
+ @Override
+ public void testFilterTitle() {
+ super.testFilterTitle();
+ }
+
+ @Test
+ @Override
+ public void testFilterNumberOfKids1() {
+ super.testFilterNumberOfKids1();
+ }
+
+ @Test
+ @Override
+ public void testFilterCombinations() {
+ super.testFilterCombinations();
+ }
+
+ @Test
+ @Override
+ public void testRerenderAll() {
+ super.testRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testFullPageRefresh() {
+ super.testFullPageRefresh();
+ }
+}
Copied: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableScroller.java (from rev 20417, modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java)
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableScroller.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableScroller.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableScrollerTest;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableScroller extends DataTableScrollerTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/scroller.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ @Override
+ public void testRowCountFooterScroller() {
+ super.testRowCountFooterScroller();
+ }
+
+ @Test
+ @Override
+ public void testRowCountOutsideTable() {
+ super.testRowCountOutsideTable();
+ }
+}
Copied: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSimple.java (from rev 20417, modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/ExtendedDataTable.java)
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSimple.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSimple.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSimpleTest;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableSimple extends DataTableSimpleTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/simple.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ public void testRendered() {
+ super.testRendered();
+ }
+
+ @Test
+ public void testNoDataLabel() {
+ super.testNoDataLabel();
+ }
+
+ @Test
+ @Use(field = "first", value = "COUNTS")
+ public void testFirst() {
+ super.testFirst();
+ }
+
+ @Test
+ @Use(field = "rows", value = "COUNTS")
+ public void testRows() {
+ super.testRows();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingColumn.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingColumn.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingColumn.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSortingTest;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableSortingUsingColumn extends DataTableSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/sorting-using-column.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingle() {
+ super.testSortModeSingle();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleReverse() {
+ super.testSortModeSingleReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleDoesntRememberOrder() {
+ super.testSortModeSingleDoesntRememberOrder();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleRerenderAll() {
+ super.testSortModeSingleRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleFullPageRefresh() {
+ super.testSortModeSingleFullPageRefresh();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMulti() {
+ super.testSortModeMulti();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReverse() {
+ super.testSortModeMultiReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReplacingOldOccurences() {
+ super.testSortModeMultiReplacingOldOccurences();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiRerenderAll() {
+ super.testSortModeMultiRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiFullPageRefresh() {
+ super.testSortModeMultiFullPageRefresh();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingComponentControl.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingComponentControl.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSortingUsingComponentControl.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSortingTest;
+import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestExtendedDataTableSortingUsingComponentControl extends DataTableSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richExtendedDataTable/sorting-using-component-control.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingle() {
+ super.testSortModeSingle();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleReverse() {
+ super.testSortModeSingleReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleDoesntRememberOrder() {
+ super.testSortModeSingleDoesntRememberOrder();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleRerenderAll() {
+ super.testSortModeSingleRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleFullPageRefresh() {
+ super.testSortModeSingleFullPageRefresh();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMulti() {
+ super.testSortModeMulti();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReverse() {
+ super.testSortModeMultiReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReplacingOldOccurences() {
+ super.testSortModeMultiReplacingOldOccurences();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiRerenderAll() {
+ super.testSortModeMultiRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiFullPageRefresh() {
+ super.testSortModeMultiFullPageRefresh();
+ }
+}
Deleted: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-12-06 17:58:49 UTC (rev 20417)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestScroller.java 2010-12-06 18:00:33 UTC (rev 20418)
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- *******************************************************************************/
-package org.richfaces.tests.metamer.ftest.richExtendedDataTable;
-
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URL;
-
-import org.jboss.test.selenium.locator.IdLocator;
-import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
-import org.richfaces.tests.metamer.ftest.annotations.Templates;
-import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
-import org.richfaces.tests.metamer.ftest.model.DataScroller;
-import org.richfaces.tests.metamer.ftest.model.ExtendedDataTable;
-import org.testng.annotations.Test;
-
-/**
- * Test of DataScroller tied to Extended Data Table
- *
- * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
- * @version $Revision$
- */
-public class TestScroller extends AbstractMetamerTest {
-
- private static final int TOTAL_ROW_COUNT = 50;
- private static final Integer[] ROW_COUNT_VALUES = new Integer[] { null, 10, 1, TOTAL_ROW_COUNT, 13, 9, 17,
- TOTAL_ROW_COUNT + 1, 2 * TOTAL_ROW_COUNT };
- DataScroller dataScroller1 = new AssertingDataScroller("outside-table", pjq("span.rf-ds[id$=scroller1]"));
- DataScroller dataScroller2 = new AssertingDataScroller("inside-table-footer", pjq("span.rf-ds[id$=scroller2]"));
- ExtendedDataTable table = new ExtendedDataTable(pjq("div.rf-edt[id$=richEDT]"));
- IdLocator attributeRowsInput = id("form:attributes:rowsInput");
-
- @Override
- public URL getTestUrl() {
- return buildUrl(contextPath, "faces/components/richExtendedDataTable/scroller.xhtml");
- }
-
- /**
- * Tests row count for scroller in footer of the EDT.
- *
- * @see {@link #testRowCount(DataScroller)}
- */
- @Test(groups = "client-side-perf")
- public void testRowCountFooterScroller() {
- testRowCount(dataScroller2);
- }
-
- /**
- * <p>
- * Tests row count for scroller outside of the EDT.
- * </p>
- *
- * <p>
- * Templates: doesn't work inside iteration components.
- * </p>
- *
- * @see {@link #testRowCount(DataScroller)}
- */
- @Test
- @Templates(exclude = { "a4jRepeat1", "a4jRepeat2", "hDataTable1", "hDataTable2", "richDataTable1,redDiv",
- "richDataTable2,redDiv", "uiRepeat1", "uiRepeat2" })
- public void testRowCountOutsideTable() {
- testRowCount(dataScroller1);
- }
-
- /**
- * <p>
- * Test the data scroller functionality for different values of row count
- * </p>
- *
- * <p>
- * If desired, sets the value of 'rows' first for each iteration.
- * </p>
- *
- * <p>
- * Then goes to first page and verifies that there is valid number of rows.
- * </p>
- *
- * <p>
- * Verifies that on the first page is less than total number of rows if the scroller has several pages.
- * </p>
- *
- * <p>
- * If the scroller has pages enabled, goes to last page and verifies that this is valid number of pages visible in
- * scroller and the number of rows is valid.
- * </p>
- *
- * <p>
- */
- private void testRowCount(DataScroller dataScroller) {
- for (Integer rowsPerPage : ROW_COUNT_VALUES) {
- if (rowsPerPage != null) {
- selenium.type(attributeRowsInput, String.valueOf(rowsPerPage));
- selenium.waitForPageToLoad();
- }
-
- dataScroller.gotoFirstPage();
- int rowCountPreset = Integer.valueOf(selenium.getValue(attributeRowsInput));
- int rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, Math.min(TOTAL_ROW_COUNT, rowCountPreset));
-
- assertEquals(dataScroller.hasPages(), rowCountActual < TOTAL_ROW_COUNT);
- if (dataScroller.hasPages()) {
- dataScroller.gotoLastPage();
-
- int pagesExpected = pageCountActualExpected(rowCountActual);
- int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
-
- if (countOfVisiblePages < pagesExpected) {
- int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage, pageCountActualExpected(rowCountActual));
- } else {
- assertEquals(countOfVisiblePages, pagesExpected);
- }
-
- int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
- rowCountActual = table.getCountOfTableRows();
- assertEquals(rowCountActual, rowCountExpected);
- }
- }
- }
-
- private int pageCountActualExpected(int rowCountActual) {
- return Double.valueOf(Math.ceil((double) TOTAL_ROW_COUNT / rowCountActual)).intValue();
- }
-
- private int rowCountLastPageExpected(int rowCountPreset) {
- int result = TOTAL_ROW_COUNT % rowCountPreset;
- return (result == 0) ? rowCountPreset : result;
- }
-}
14 years, 1 month
JBoss Rich Faces SVN: r20417 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:58:49 -0500 (Mon, 06 Dec 2010)
New Revision: 20417
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
Log:
removed unnecessary imports
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2010-12-06 17:57:57 UTC (rev 20416)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2010-12-06 17:58:49 UTC (rev 20417)
@@ -24,8 +24,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
-import org.testng.annotations.Test;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:57:57 UTC (rev 20416)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:58:49 UTC (rev 20417)
@@ -32,7 +32,6 @@
import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.model.Capital;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
14 years, 1 month
JBoss Rich Faces SVN: r20416 - in modules/tests/metamer/trunk: ftest-source/src/main/java/org/richfaces/tests/metamer/ftest and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:57:57 -0500 (Mon, 06 Dec 2010)
New Revision: 20416
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFiltering.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableScroller.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSimple.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingColumn.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingComponentControl.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/facets.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
Log:
rich:dataTable - 74 tests for simple, facets, filtering and sorting (RFPL-912)
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/facets.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/facets.xhtml 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/facets.xhtml 2010-12-06 17:57:57 UTC (rev 20416)
@@ -118,16 +118,16 @@
<h:inputText id="headerInput" value="#{richDataTableBean.facets['header']}" />
<h:outputLabel value="State Column Header:" />
- <h:inputText id="columnStateHeaderInput" value="#{richDataTableBean.facets['columnStateHeader']}" />
+ <h:inputText id="stateHeaderInput" value="#{richDataTableBean.facets['columnStateHeader']}" />
<h:outputLabel value="State Column Footer:" />
- <h:inputText id="columnStateFooterInput" value="#{richDataTableBean.facets['columnStateFooter']}" />
+ <h:inputText id="stateFooterInput" value="#{richDataTableBean.facets['columnStateFooter']}" />
<h:outputLabel value="Capital Column Header:" />
- <h:inputText id="columnCapitalHeaderInput" value="#{richDataTableBean.facets['columnCapitalHeader']}" />
+ <h:inputText id="capitalHeaderInput" value="#{richDataTableBean.facets['columnCapitalHeader']}" />
<h:outputLabel value="Capital Column Footer:" />
- <h:inputText id="columnCapitalFooterInput" value="#{richDataTableBean.facets['columnCapitalFooter']}" />
+ <h:inputText id="capitalFooterInput" value="#{richDataTableBean.facets['columnCapitalFooter']}" />
</h:panelGrid>
</a4j:ajax>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/filtering.xhtml 2010-12-06 17:57:57 UTC (rev 20416)
@@ -81,7 +81,7 @@
</h:panelGroup>
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="record.sex" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
<f:facet name="footer">
<h:outputText id="columnFooterSex" value="Sex" />
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-column.xhtml 2010-12-06 17:57:57 UTC (rev 20416)
@@ -70,7 +70,7 @@
<f:facet name="header">
<a4j:commandLink id="sortBySex" value="Sex" render="richDataTable" action="#{richDataTableBean.sorting['columnSex'].reverseOrder}" />
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
</rich:column>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/richDataTable/sorting-using-component-control.xhtml 2010-12-06 17:57:57 UTC (rev 20416)
@@ -73,7 +73,7 @@
</rich:componentControl>
</h:commandLink>
</f:facet>
- <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" />
+ <h:graphicImage library="images" name="#{record.sex == 'MALE' ? 'male.png' : 'female.png'}" alt="#{record.sex}" />
</rich:column>
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/AbstractDataTableTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -57,9 +57,9 @@
ELEMENTS_TOTAL, ELEMENTS_TOTAL + 1 };
protected DataTable model;
- protected EmployeeTableModel employees;
- protected DataTableAttributes attributes;
- protected DataTableFacets facets;
+ protected EmployeeTableModel employees = new EmployeeTableModel();
+ protected DataTableAttributes attributes = new DataTableAttributes();
+ protected DataTableFacets facets = new DataTableFacets();
protected DataScroller dataScroller1 = new AssertingDataScroller("outside-table", pjq("span.rf-ds[id$=scroller1]"));
protected DataScroller dataScroller2 = new AssertingDataScroller("inside-table-footer",
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTable.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -28,10 +28,6 @@
* @version $Revision$
*/
public interface DataTable {
- int getPages();
-
- int getCurrentPage();
-
int getRows();
int getColumns();
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableAttributes.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -21,11 +21,16 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.richfaces.tests.metamer.ftest.AbstractMetamerTest.pjq;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
import org.apache.commons.lang.StringUtils;
+import org.jboss.test.selenium.dom.Event;
+import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.model.SortMode;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
@@ -34,8 +39,12 @@
* @version $Revision$
*/
public class DataTableAttributes extends AbstractComponentAttributes {
+
+ JQueryLocator showDataLocator = pjq("input[id$=noDataCheckbox]");
+
public void setShowData(boolean showData) {
- setProperty("showData", showData);
+ selenium.check(showDataLocator, showData);
+ guardXhr(selenium).fireEvent(showDataLocator, Event.CLICK);
}
public void setFirst(Integer first) {
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -21,6 +21,9 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+
+import org.jboss.test.selenium.locator.ElementLocator;
import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
/**
@@ -30,7 +33,7 @@
public class DataTableFacets extends AbstractComponentAttributes {
public void setNoData(String noData) {
- throw new UnsupportedOperationException("not implemeneted yet");
+ setProperty("noData", noData);
}
public void setHeader(String header) {
@@ -52,4 +55,9 @@
public void setCapitalFooter(String capitalFooter) {
setProperty("capitalFooter", capitalFooter);
}
+
+ @Override
+ protected void applyText(ElementLocator<?> locator, String value) {
+ guardXhr(selenium).type(locator, value);
+ }
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacetsTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -35,21 +35,18 @@
private static final String SAMPLE_STRING = "Abc123!@#ĚščСам";
private static final String EMPTY_STRING = "";
- @Test
public void testNoDataInstantChange() {
attributes.setShowData(false);
facets.setNoData(SAMPLE_STRING);
assertEquals(selenium.getText(model.getNoData()), SAMPLE_STRING);
}
- @Test
public void testNoDataEmpty() {
attributes.setShowData(false);
facets.setNoData(EMPTY_STRING);
assertEquals(selenium.getText(model.getNoData()), EMPTY_STRING);
}
- @Test
public void testNoDataLabelWithEmptyNoDataFacet() {
attributes.setShowData(false);
facets.setNoData(EMPTY_STRING);
@@ -57,61 +54,51 @@
assertEquals(selenium.getText(model.getNoData()), SAMPLE_STRING);
}
- @Test
public void testHeaderInstantChange() {
facets.setHeader(SAMPLE_STRING);
assertEquals(selenium.getText(model.getHeader()), SAMPLE_STRING);
}
- @Test
public void testHeaderEmpty() {
facets.setHeader(EMPTY_STRING);
assertFalse(selenium.isElementPresent(model.getHeader()));
}
- @Test
public void testStateHeaderInstantChange() {
facets.setStateHeader(SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_STATE)), SAMPLE_STRING);
}
- @Test
public void testStateHeaderEmpty() {
- facets.setStateHeader(EMPTY_STRING);
+ facets.setStateFooter(EMPTY_STRING);
assertFalse(selenium.isElementPresent(model.getColumnHeader(COLUMN_STATE)));
}
- @Test
public void testStateFooterInstantChange() {
- facets.setStateHeader(SAMPLE_STRING);
+ facets.setStateFooter(SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_STATE)), SAMPLE_STRING);
}
- @Test
public void testStateFooterEmpty() {
facets.setStateFooter(EMPTY_STRING);
assertFalse(selenium.isElementPresent(model.getColumnFooter(COLUMN_STATE)));
}
- @Test
public void testCapitalHeaderInstantChange() {
facets.setCapitalHeader(SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnHeader(COLUMN_CAPITAL)), SAMPLE_STRING);
}
- @Test
public void testCapitalHeaderEmpty() {
facets.setCapitalHeader(EMPTY_STRING);
assertFalse(selenium.isElementPresent(model.getColumnHeader(COLUMN_CAPITAL)));
}
- @Test
public void testCapitalFooterInstantChange() {
- facets.setCapitalHeader(SAMPLE_STRING);
+ facets.setCapitalFooter(SAMPLE_STRING);
assertEquals(selenium.getText(model.getColumnFooter(COLUMN_CAPITAL)), SAMPLE_STRING);
}
- @Test
public void testCapitalFooterEmpty() {
facets.setCapitalFooter(EMPTY_STRING);
assertFalse(selenium.isElementPresent(model.getColumnFooter(COLUMN_CAPITAL)));
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFilteringTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -30,7 +30,6 @@
import java.util.Collection;
import java.util.List;
-import org.jboss.test.selenium.dom.Event;
import org.jboss.test.selenium.locator.Attribute;
import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
@@ -39,7 +38,6 @@
import org.richfaces.tests.metamer.model.Employee;
import org.richfaces.tests.metamer.model.Employee.Sex;
import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -49,7 +47,7 @@
private static final String[] FILTER_NAMES = new String[] { "ivan", "Гог", null, "Š" };
private static final String[] FILTER_TITLES = new String[] { "Director", null, "CEO" };
- private static final Integer[] FILTER_NUMBER_OF_KIDS = new Integer[] { 2, 100, null, 5 };
+ private static final Integer[] FILTER_NUMBER_OF_KIDS = new Integer[] { 2, 100, 0, 5 };
JQueryLocator selectSex = jq("select");
JQueryLocator inputName = jq("input");
@@ -68,7 +66,6 @@
filterEmployee = new ExpectedEmployee();
}
- @Test
public void testFilterSex() {
filtering.selectSex(Sex.MALE);
filterEmployee.sex = Sex.MALE;
@@ -83,7 +80,6 @@
verifyFiltering();
}
- @Test
public void testFilterName() {
for (String filterName : FILTER_NAMES) {
filtering.selectName(filterName);
@@ -92,7 +88,6 @@
}
}
- @Test
public void testFilterTitle() {
for (String filterTitle : FILTER_TITLES) {
filtering.selectTitle(filterTitle);
@@ -101,7 +96,6 @@
}
}
- @Test
public void testFilterNumberOfKids1() {
for (Integer filterNumberOfKids : FILTER_NUMBER_OF_KIDS) {
filtering.selectNumberOfKids1(filterNumberOfKids);
@@ -110,7 +104,6 @@
}
}
- @Test
public void testFilterCombinations() {
filtering.selectTitle("Technology");
filterEmployee.title = "Technology";
@@ -128,8 +121,8 @@
filterEmployee.name = "9";
verifyFiltering();
- filtering.selectNumberOfKids1(1);
- filterEmployee.numberOfKids1 = 1;
+ filtering.selectNumberOfKids1(0);
+ filterEmployee.numberOfKids1 = 0;
verifyFiltering();
filtering.selectSex(Sex.FEMALE);
@@ -137,50 +130,89 @@
verifyFiltering();
}
- @Test
- public void testRefresh() {
- dataScroller1.gotoFirstPage();
+ public void testRerenderAll() {
+ dataScroller2.setLastPage(dataScroller2.obtainLastPage());
+ dataScroller2.gotoFirstPage();
rows = model.getRows();
filtering.selectName("an");
filterEmployee.name = "an";
+
+ expectedEmployees = filter(EMPLOYEES, getFilter());
- dataScroller1.gotoLastPage();
- int lastPage = dataScroller1.getCurrentPage();
+ dataScroller2.gotoLastPage();
+ int lastPage = dataScroller2.getCurrentPage();
assertTrue(lastPage > 1);
rerenderAll();
- assertEquals(dataScroller1.getCurrentPage(), lastPage);
+ assertEquals(dataScroller2.getCurrentPage(), lastPage);
+ assertTrue(dataScroller2.isLastPage());
verifyPageContent(lastPage);
+
+ dataScroller2.gotoFirstPage();
+ verifyPageContent(1);
+ }
+
+ public void testFullPageRefresh() {
+ dataScroller2.setLastPage(dataScroller2.obtainLastPage());
+ dataScroller2.gotoFirstPage();
+ rows = model.getRows();
+ filtering.selectName("an");
+ filterEmployee.name = "an";
+
+ expectedEmployees = filter(EMPLOYEES, getFilter());
+
+ dataScroller2.gotoLastPage();
+ int lastPage = dataScroller2.getCurrentPage();
+ assertTrue(lastPage > 1);
+
fullPageRefresh();
- assertEquals(dataScroller1.getCurrentPage(), lastPage);
+ assertEquals(dataScroller2.getCurrentPage(), lastPage);
+ assertTrue(dataScroller2.isLastPage());
verifyPageContent(lastPage);
+
+ dataScroller2.gotoFirstPage();
+ verifyPageContent(1);
}
public void verifyFiltering() {
expectedEmployees = filter(EMPLOYEES, getFilter());
- dataScroller1.gotoFirstPage();
+ dataScroller2.setLastPage(dataScroller2.obtainLastPage());
+
+ dataScroller2.gotoFirstPage();
rows = model.getRows();
verifyPageContent(1);
- dataScroller1.gotoPage(2);
- verifyPageContent(2);
+ if (dataScroller2.getLastPage() > 1) {
+ dataScroller2.gotoLastPage();
+ int lastPage = dataScroller2.getCurrentPage();
+ verifyPageContent(lastPage);
- dataScroller1.gotoLastPage();
- int lastPage = dataScroller1.getCurrentPage();
- verifyPageContent(lastPage);
+ if (dataScroller2.getLastPage() > 2) {
+ dataScroller2.gotoPage(2);
+ verifyPageContent(2);
+ }
- dataScroller1.gotoPage(lastPage - 1);
- verifyPageContent(lastPage - 1);
+ if (dataScroller2.getLastPage() > 3) {
+ dataScroller2.gotoPage(lastPage - 1);
+ verifyPageContent(lastPage - 1);
+ }
+ }
+
}
public void verifyPageContent(int page) {
- for (int row = 0; row < model.getRows(); row++) {
- int index = (page - 1) * rows + row;
- Employee expectedEmployee = expectedEmployees.get(index);
- filtering.verifyRow(expectedEmployee, row);
+ if (expectedEmployees.size() == 0) {
+ assertEquals(model.getRows(), 0);
+ assertTrue(model.isNoData());
+ } else {
+ for (int row = 0; row < model.getRows(); row++) {
+ int index = (page - 1) * rows + row;
+ Employee expectedEmployee = expectedEmployees.get(index);
+ filtering.verifyRow(expectedEmployee, row + 1);
+ }
}
}
@@ -256,24 +288,21 @@
public void selectName(String name) {
JQueryLocator input = model.getColumnHeader(COLUMN_NAME).getDescendant(inputName);
- selenium.type(inputName, name);
- guardXhr(selenium).fireEvent(input, Event.BLUR);
+ guardXhr(selenium).type(input, name == null ? "" : name);
}
public void selectTitle(String title) {
JQueryLocator input = model.getColumnHeader(COLUMN_TITLE).getDescendant(inputTitle);
- selenium.type(inputName, title);
- guardXhr(selenium).fireEvent(input, Event.BLUR);
+ guardXhr(selenium).type(input, title == null ? "" : title);
}
public void selectNumberOfKids1(int numberOfKids) {
JQueryLocator input = model.getColumnHeader(COLUMN_NUMBER_OF_KIDS1).getDescendant(inputNumberOfKids1);
- selenium.type(inputName, Integer.toString(numberOfKids));
- guardXhr(selenium).fireEvent(input, Event.BLUR);
+ guardXhr(selenium).type(input, Integer.toString(numberOfKids));
}
public void verifyElement(int column, int row, Object expectedValue) {
- JQueryLocator locator = model.getColumnHeader(COLUMN_NAME);
+ JQueryLocator locator = model.getElement(column, row);
String text = selenium.getText(locator);
assertEquals(text, expectedValue.toString());
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableScrollerTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -23,9 +23,10 @@
import static org.testng.Assert.assertEquals;
+import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Templates;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
import org.richfaces.tests.metamer.ftest.model.DataScroller;
-import org.testng.annotations.Test;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -33,12 +34,14 @@
*/
public abstract class DataTableScrollerTest extends AbstractDataTableTest {
- @Test
+ @Inject
+ @Use("COUNTS")
+ Integer rows;
+
public void testRowCountFooterScroller() {
testRowCount(dataScroller2);
}
- @Test
@Templates(exclude = { "a4jRepeat1", "a4jRepeat2", "hDataTable1", "hDataTable2", "richDataTable1,redDiv",
"richDataTable2,redDiv", "uiRepeat1", "uiRepeat2" })
public void testRowCountOutsideTable() {
@@ -46,35 +49,32 @@
}
private void testRowCount(DataScroller dataScroller) {
- for (Integer rowsPerPage : COUNTS) {
- if (rowsPerPage != null) {
- attributes.setRows(rowsPerPage);
- selenium.waitForPageToLoad();
- }
+ if (rows != null) {
+ attributes.setRows(rows);
+ }
- dataScroller.gotoFirstPage();
- int rowCountPreset = attributes.getRows();
- int rowCountActual = model.getRows();
- assertEquals(rowCountActual, Math.min(ELEMENTS_TOTAL, rowCountPreset));
+ dataScroller.gotoFirstPage();
+ int rowCountPreset = attributes.getRows();
+ int rowCountActual = model.getRows();
+ assertEquals(rowCountActual, Math.min(ELEMENTS_TOTAL, rowCountPreset));
- assertEquals(dataScroller.hasPages(), rowCountActual < ELEMENTS_TOTAL);
- if (dataScroller.hasPages()) {
- dataScroller.gotoLastPage();
+ assertEquals(dataScroller.hasPages(), rowCountActual < ELEMENTS_TOTAL);
+ if (dataScroller.hasPages()) {
+ dataScroller.gotoLastPage();
- int pagesExpected = pageCountActualExpected(rowCountActual);
- int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
+ int pagesExpected = pageCountActualExpected(rowCountActual);
+ int countOfVisiblePages = dataScroller.getCountOfVisiblePages();
- if (countOfVisiblePages < pagesExpected) {
- int lastVisiblePage = dataScroller.getLastVisiblePage();
- assertEquals(lastVisiblePage, pageCountActualExpected(rowCountActual));
- } else {
- assertEquals(countOfVisiblePages, pagesExpected);
- }
+ if (countOfVisiblePages < pagesExpected) {
+ int lastVisiblePage = dataScroller.getLastVisiblePage();
+ assertEquals(lastVisiblePage, pageCountActualExpected(rowCountActual));
+ } else {
+ assertEquals(countOfVisiblePages, pagesExpected);
+ }
- int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
- rowCountActual = model.getRows();
- assertEquals(rowCountActual, rowCountExpected);
- }
+ int rowCountExpected = rowCountLastPageExpected(rowCountPreset);
+ rowCountActual = model.getRows();
+ assertEquals(rowCountActual, rowCountExpected);
}
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSimpleTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -41,15 +41,19 @@
public abstract class DataTableSimpleTest extends AbstractDataTableTest {
protected static final int COLUMNS_TOTAL = 2;
+ private static final String NO_DATA = "There is no data.";
@Inject
+ @Use(empty = true)
protected Integer first = null;
@Inject
+ @Use(empty = true)
protected Integer rows = 30;
private int expectedFirst;
private int expectedRows;
+ private int expectedColumns;
private List<Capital> expectedElements;
@BeforeMethod
@@ -64,39 +68,44 @@
}
if (rows == null) {
- expectedRows = ELEMENTS_TOTAL - first;
+ expectedRows = ELEMENTS_TOTAL - expectedFirst;
} else {
- expectedRows = rows - first;
+ expectedRows = Math.min(rows, ELEMENTS_TOTAL) - expectedFirst;
}
+
+ if (expectedRows > 0) {
+ expectedColumns = COLUMNS_TOTAL;
+ } else {
+ expectedColumns = 0;
+ }
expectedElements = getExpectedElements();
}
- @Test
public void testRendered() {
+ attributes.setRendered(false);
+
assertFalse(model.isVisible());
assertFalse(model.isNoData());
assertEquals(model.getColumns(), 0);
assertEquals(model.getRows(), 0);
}
- @Test
public void testNoDataLabel() {
+ attributes.setNoDataLabel(NO_DATA);
+ attributes.setShowData(false);
+
assertTrue(model.isVisible());
assertTrue(model.isNoData());
assertEquals(model.getColumns(), 0);
assertEquals(model.getRows(), 0);
- assertEquals(selenium.getText(model.getNoData()), "There is no data.");
+ assertEquals(selenium.getText(model.getNoData()), NO_DATA);
}
- @Test
- @Use(field = "first", value = "COUNTS")
public void testFirst() {
verifyTable();
}
- @Test
- @Use(field = "rows", value = "COUNTS")
public void testRows() {
verifyTable();
}
@@ -104,7 +113,7 @@
public void verifyTable() {
assertTrue(model.isVisible());
assertFalse(model.isNoData());
- assertEquals(model.getColumns(), COLUMNS_TOTAL);
+ assertEquals(model.getColumns(), expectedColumns);
assertEquals(model.getRows(), expectedRows);
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableSortingTest.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -21,7 +21,9 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.abstractions;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
import static org.testng.Assert.assertEquals;
import java.lang.reflect.Method;
@@ -33,7 +35,7 @@
import org.apache.commons.lang.StringUtils;
import org.richfaces.model.SortMode;
import org.richfaces.tests.metamer.model.Employee;
-import org.testng.annotations.Test;
+import org.richfaces.tests.metamer.model.Employee.Sex;
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
@@ -41,7 +43,10 @@
*/
public abstract class DataTableSortingTest extends AbstractDataTableTest {
- @Test
+ int rowIndex;
+ int modelIndex;
+ List<Employee> sortedEmployees;
+
public void testSortModeSingle() {
attributes.setSortMode(SortMode.single);
@@ -56,17 +61,65 @@
sortByColumn(COLUMN_NUMBER_OF_KIDS1);
verifySortingByColumns("numberOfKids");
+ }
+ public void testSortModeSingleReverse() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_SEX);
+ sortByColumn(COLUMN_SEX);
+ verifySortingByColumns("sex-");
+
+ sortByColumn(COLUMN_TITLE);
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title-");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("numberOfKids-");
+
+ sortByColumn(COLUMN_NAME);
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("name-");
+ }
+
+ public void testSortModeSingleDoesntRememberOrder() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_NAME);
+ sortByColumn(COLUMN_TITLE);
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("name");
+ }
+
+ public void testSortModeSingleRerenderAll() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("name");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("numberOfKids");
+
rerenderAll();
verifySortingByColumns("numberOfKids");
+ }
+ public void testSortModeSingleFullPageRefresh() {
+ attributes.setSortMode(SortMode.single);
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("numberOfKids");
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title");
+
fullPageRefresh();
- verifySortingByColumns("numberOfKids");
+ verifySortingByColumns("title");
}
- @Test
public void testSortModeMulti() {
- attributes.setSortMode(SortMode.single);
+ attributes.setSortMode(SortMode.multi);
sortByColumn(COLUMN_TITLE);
verifySortingByColumns("title");
@@ -79,50 +132,102 @@
sortByColumn(COLUMN_NAME);
verifySortingByColumns("title", "sex", "numberOfKids", "name");
+ }
+ public void testSortModeMultiReverse() {
+ attributes.setSortMode(SortMode.multi);
+
+ sortByColumn(COLUMN_TITLE);
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title-");
+
+ sortByColumn(COLUMN_SEX);
+ sortByColumn(COLUMN_SEX);
+ verifySortingByColumns("title-", "sex-");
+
sortByColumn(COLUMN_NUMBER_OF_KIDS1);
- verifySortingByColumns("title", "sex", "name", "numberOfKids");
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title-", "sex-", "numberOfKids-");
+ sortByColumn(COLUMN_NAME);
+ sortByColumn(COLUMN_NAME);
+ verifySortingByColumns("title-", "sex-", "numberOfKids-", "name-");
+ }
+
+ public void testSortModeMultiReplacingOldOccurences() {
+ attributes.setSortMode(SortMode.multi);
+
sortByColumn(COLUMN_TITLE);
- verifySortingByColumns("sex", "name", "numberOfKids", "title");
+ verifySortingByColumns("title");
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title", "numberOfKids-");
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("numberOfKids-", "title-");
+ }
+
+ public void testSortModeMultiRerenderAll() {
+ attributes.setSortMode(SortMode.multi);
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title", "numberOfKids-");
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("numberOfKids-", "title-");
+
rerenderAll();
- verifySortingByColumns("sex", "name", "numberOfKids", "title");
+ verifySortingByColumns("numberOfKids-", "title-");
+ }
+ public void testSortModeMultiFullPageRefresh() {
+ attributes.setSortMode(SortMode.multi);
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("title");
+
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ sortByColumn(COLUMN_NUMBER_OF_KIDS1);
+ verifySortingByColumns("title", "numberOfKids-");
+
+ sortByColumn(COLUMN_TITLE);
+ verifySortingByColumns("numberOfKids-", "title-");
+
fullPageRefresh();
- verifySortingByColumns("sex", "name", "numberOfKids", "title");
+ verifySortingByColumns("numberOfKids-", "title-");
}
- int rowIndex;
- int modelIndex;
- List<Employee> sortedEmployees;
-
public void sortByColumn(int column) {
- selenium.click(model.getColumnHeader(column).getDescendant(jq("a")));
+ guardXhr(selenium).click(model.getColumnHeader(column).getDescendant(jq("a")));
}
public void verifySortingByColumns(String... columns) {
Comparator<Employee> employeeComparator = getPropertyComparator(Employee.class, columns);
sortedEmployees = new ArrayList<Employee>(EMPLOYEES);
Collections.sort(sortedEmployees, employeeComparator);
-
+
+ dataScroller2.gotoFirstPage();
+
int firstPageRows = model.getRows();
- dataScroller1.gotoFirstPage();
-
for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
modelIndex = rowIndex;
verifyRow(rowIndex, modelIndex);
}
- dataScroller1.gotoPage(2);
+ dataScroller2.gotoPage(2);
for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
modelIndex = firstPageRows + rowIndex;
verifyRow(rowIndex, modelIndex);
}
- dataScroller1.gotoLastPage();
+ dataScroller2.gotoLastPage();
for (rowIndex = 0; rowIndex < model.getRows(); rowIndex++) {
modelIndex = EMPLOYEES.size() - model.getRows() + rowIndex;
@@ -131,10 +236,21 @@
}
public void verifyRow(int rowIndex, int modelIndex) {
- assertEquals(employees.getSex(rowIndex), sortedEmployees.get(modelIndex).getSex());
- assertEquals(employees.getName(rowIndex), sortedEmployees.get(modelIndex));
- assertEquals(employees.getTitle(rowIndex), sortedEmployees.get(modelIndex).getTitle());
- assertEquals(employees.getNumberOfKids(rowIndex), sortedEmployees.get(modelIndex).getNumberOfKids());
+ Employee employee = sortedEmployees.get(modelIndex);
+
+ Sex sex = employees.getSex(rowIndex + 1);
+ String name = employees.getName(rowIndex + 1);
+ String title = employees.getTitle(rowIndex + 1);
+ int numberOfKids = employees.getNumberOfKids(rowIndex + 1);
+
+ String message = format(
+ "model: {0}; row: {1}; employee: {2}; found: sex '{3}', name '{4}', title '{5}', numberOfKids '{6}'",
+ modelIndex, rowIndex, employee, sex, name, title, numberOfKids);
+
+ assertEquals(sex, employee.getSex(), message);
+ assertEquals(name, employee.getName(), message);
+ assertEquals(title, employee.getTitle(), message);
+ assertEquals(numberOfKids, employee.getNumberOfKids(), message);
}
public <T> Comparator<T> getPropertyComparator(final Class<T> classT, final String... properties) {
@@ -143,16 +259,33 @@
@Override
public int compare(T o1, T o2) {
for (String property : properties) {
- String getterName = "get" + StringUtils.capitalize(property);
+ boolean reverse = property.endsWith("-");
+ String getterName = "get" + StringUtils.capitalize(property.replace("-", ""));
try {
+ Method getter = classT.getMethod(getterName);
- Method getter = classT.getClass().getMethod(getterName);
Object got1 = getter.invoke(o1);
Object got2 = getter.invoke(o2);
- Method compareTo = got1.getClass().getMethod("compareTo", got2.getClass());
- int result = (Integer) compareTo.invoke(got1, got2);
+ int result;
+
+ if (String.class.equals(getter.getReturnType())) {
+ Method comparecompareToIgnoreCase = got1.getClass().getMethod("compareToIgnoreCase",
+ got2.getClass());
+ result = (Integer) comparecompareToIgnoreCase.invoke(got1, got2);
+ } else if (got1 instanceof Comparable<?> && got1 instanceof Comparable<?>) {
+ result = ((Comparable) got1).compareTo(got2);
+ // Method compareTo = got1.getClass().getMethod("compareTo", got2.getClass());
+ // result = (Integer) compareTo.invoke(got1, got2);
+ } else {
+ throw new IllegalStateException("Cannot compare values");
+ }
+
if (result != 0) {
- return result;
+ if (reverse) {
+ return -result;
+ } else {
+ return result;
+ }
}
} catch (Exception e) {
throw new IllegalArgumentException("Cannot obtain property '" + property + "'", e);
@@ -160,7 +293,6 @@
}
return 0;
}
-
};
}
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-12-06 17:55:58 UTC (rev 20415)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataScroller.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -192,6 +192,9 @@
if (!hasPages()) {
return 1;
}
+ if (isLastPage()) {
+ return getCurrentPage();
+ }
int startPage = getCurrentPage();
clickLastPageButton();
int lastPage = getCurrentPage();
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/model/DataTable.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.model;
+
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.jboss.test.selenium.locator.reference.ReferencedLocator.ref;
+
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.JQueryLocator;
+import org.jboss.test.selenium.locator.reference.ReferencedLocator;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class DataTable extends AbstractModel<JQueryLocator> implements
+ org.richfaces.tests.metamer.ftest.abstractions.DataTable {
+
+ AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ ReferencedLocator<JQueryLocator> tbody = ref(root, "> tbody.rf-dt");
+ ReferencedLocator<JQueryLocator> firstColumnRows = ref(tbody, "> tr > td.rf-dt-c:nth-child(1)");
+ ReferencedLocator<JQueryLocator> firstRowColumns = ref(tbody, "> tr:eq(0) > td.rf-dt-c");
+ ReferencedLocator<JQueryLocator> noData = ref(tbody, "> tr > td.rf-dt-ndt");
+ ReferencedLocator<JQueryLocator> columns = ref(tbody, "> tr");
+ JQueryLocator columnToElement = jq("td.rf-dt-c");
+
+ ReferencedLocator<JQueryLocator> thead = ref(root, "> thead.rf-dt-thead");
+ ReferencedLocator<JQueryLocator> tableHeader = ref(thead, "> tr.rf-dt-hdr > th.rf-dt-hdr-c");
+ ReferencedLocator<JQueryLocator> columnHeader = ref(thead, "> tr.rf-dt-shdr > th.rf-dt-shdr-c");
+
+ ReferencedLocator<JQueryLocator> columnFooter = ref(root, "> tfoot.rd-dt-tfoot > tr.rf-dt-sftr > td.rf-dt-sftr-c");
+
+ public DataTable(JQueryLocator root) {
+ super(root);
+ }
+
+ public DataTable(String name, JQueryLocator root) {
+ super(name, root);
+ }
+
+ @Override
+ public int getRows() {
+ return selenium.getCount(firstColumnRows);
+ }
+
+ @Override
+ public int getColumns() {
+ return selenium.getCount(firstRowColumns);
+ }
+
+ @Override
+ public boolean isVisible() {
+ return selenium.isElementPresent(root.getLocator()) && selenium.isVisible(root.getLocator());
+ }
+
+ @Override
+ public boolean isNoData() {
+ return selenium.isElementPresent(noData) && selenium.isVisible(noData);
+ }
+
+ @Override
+ public JQueryLocator getNoData() {
+ return noData.getReferenced();
+ }
+
+ @Override
+ public JQueryLocator getElement(int column, int row) {
+ return columns.getNthOccurence(row).getChild(columnToElement).getNthChildElement(column);
+ }
+
+ @Override
+ public JQueryLocator getColumnHeader(int column) {
+ return columnHeader.getNthOccurence(column);
+ }
+
+ @Override
+ public JQueryLocator getColumnFooter(int column) {
+ return columnFooter.getNthOccurence(column);
+ }
+
+ @Override
+ public JQueryLocator getHeader() {
+ return tableHeader.getReferenced();
+ }
+
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFacets.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFacets.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFacets.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFacetsTest;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableFacets extends DataTableFacetsTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/facets.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ public void testNoDataInstantChange() {
+ super.testNoDataInstantChange();
+ }
+
+ @Test
+ public void testNoDataEmpty() {
+ super.testNoDataEmpty();
+ }
+
+ @Test
+ public void testNoDataLabelWithEmptyNoDataFacet() {
+ super.testNoDataLabelWithEmptyNoDataFacet();
+ }
+
+ @Test
+ public void testHeaderInstantChange() {
+ super.testHeaderInstantChange();
+ }
+
+ @Test
+ public void testHeaderEmpty() {
+ super.testHeaderEmpty();
+ }
+
+ @Test
+ public void testStateHeaderInstantChange() {
+ super.testStateHeaderInstantChange();
+ }
+
+ @Test
+ public void testStateHeaderEmpty() {
+ super.testStateHeaderEmpty();
+ }
+
+ @Test
+ public void testStateFooterInstantChange() {
+ super.testStateFooterInstantChange();
+ }
+
+ @Test
+ public void testStateFooterEmpty() {
+ super.testStateFooterEmpty();
+ }
+
+ @Test
+ public void testCapitalHeaderInstantChange() {
+ super.testCapitalHeaderInstantChange();
+ }
+
+ @Test
+ public void testCapitalHeaderEmpty() {
+ super.testCapitalHeaderEmpty();
+ }
+
+ @Test
+ public void testCapitalFooterInstantChange() {
+ super.testCapitalFooterInstantChange();
+ }
+
+ @Test
+ public void testCapitalFooterEmpty() {
+ super.testCapitalFooterEmpty();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFiltering.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFiltering.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableFiltering.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableFilteringTest;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableFiltering extends DataTableFilteringTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/filtering.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ @Override
+ public void testFilterSex() {
+ super.testFilterSex();
+ }
+
+ @Test
+ @Override
+ public void testFilterName() {
+ super.testFilterName();
+ }
+
+ @Test
+ @Override
+ public void testFilterTitle() {
+ super.testFilterTitle();
+ }
+
+ @Test
+ @Override
+ public void testFilterNumberOfKids1() {
+ super.testFilterNumberOfKids1();
+ }
+
+ @Test
+ @Override
+ public void testFilterCombinations() {
+ super.testFilterCombinations();
+ }
+
+ @Test
+ @Override
+ public void testRerenderAll() {
+ super.testRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testFullPageRefresh() {
+ super.testFullPageRefresh();
+ }
+}
Copied: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableScroller.java (from rev 20415, modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java)
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableScroller.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableScroller.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableScrollerTest;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableScroller extends DataTableScrollerTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/scroller.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ @Override
+ public void testRowCountFooterScroller() {
+ super.testRowCountFooterScroller();
+ }
+
+ @Test
+ @Override
+ public void testRowCountOutsideTable() {
+ super.testRowCountOutsideTable();
+ }
+}
Copied: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSimple.java (from rev 20415, modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/abstractions/DataTableFacets.java)
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSimple.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSimple.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSimpleTest;
+import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableSimple extends DataTableSimpleTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/simple.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ public void testRendered() {
+ super.testRendered();
+ }
+
+ @Test
+ public void testNoDataLabel() {
+ super.testNoDataLabel();
+ }
+
+ @Test
+ @Use(field = "first", value = "COUNTS")
+ public void testFirst() {
+ super.testFirst();
+ }
+
+ @Test
+ @Use(field = "rows", value = "COUNTS")
+ public void testRows() {
+ super.testRows();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingColumn.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingColumn.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingColumn.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSortingTest;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableSortingUsingColumn extends DataTableSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/sorting-using-column.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingle() {
+ super.testSortModeSingle();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleReverse() {
+ super.testSortModeSingleReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleDoesntRememberOrder() {
+ super.testSortModeSingleDoesntRememberOrder();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleRerenderAll() {
+ super.testSortModeSingleRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleFullPageRefresh() {
+ super.testSortModeSingleFullPageRefresh();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMulti() {
+ super.testSortModeMulti();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReverse() {
+ super.testSortModeMultiReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReplacingOldOccurences() {
+ super.testSortModeMultiReplacingOldOccurences();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiRerenderAll() {
+ super.testSortModeMultiRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiFullPageRefresh() {
+ super.testSortModeMultiFullPageRefresh();
+ }
+}
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingComponentControl.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingComponentControl.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataTable/TestDataTableSortingUsingComponentControl.java 2010-12-06 17:57:57 UTC (rev 20416)
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.richDataTable;
+
+import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
+
+import java.net.URL;
+
+import org.richfaces.tests.metamer.ftest.abstractions.DataTableSortingTest;
+import org.richfaces.tests.metamer.ftest.model.DataTable;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class TestDataTableSortingUsingComponentControl extends DataTableSortingTest {
+
+ @Override
+ public URL getTestUrl() {
+ return buildUrl(contextPath, "faces/components/richDataTable/sorting-using-component-control.xhtml");
+ }
+
+ @BeforeClass
+ public void setupModel() {
+ model = new DataTable(pjq("table.rf-dt[id$=richDataTable]"));
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingle() {
+ super.testSortModeSingle();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleReverse() {
+ super.testSortModeSingleReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleDoesntRememberOrder() {
+ super.testSortModeSingleDoesntRememberOrder();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleRerenderAll() {
+ super.testSortModeSingleRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeSingleFullPageRefresh() {
+ super.testSortModeSingleFullPageRefresh();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMulti() {
+ super.testSortModeMulti();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReverse() {
+ super.testSortModeMultiReverse();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiReplacingOldOccurences() {
+ super.testSortModeMultiReplacingOldOccurences();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiRerenderAll() {
+ super.testSortModeMultiRerenderAll();
+ }
+
+ @Test
+ @Override
+ public void testSortModeMultiFullPageRefresh() {
+ super.testSortModeMultiFullPageRefresh();
+ }
+}
14 years, 1 month
JBoss Rich Faces SVN: r20415 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-12-06 12:55:58 -0500 (Mon, 06 Dec 2010)
New Revision: 20415
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
Log:
added factory method ReferencedLocator.ref(..) for referencing using ReferencedLocator as reference
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-12-06 17:55:11 UTC (rev 20414)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/test/selenium/locator/reference/ReferencedLocator.java 2010-12-06 17:55:58 UTC (rev 20415)
@@ -57,6 +57,11 @@
result.reference = reference;
return result;
}
+
+ public static <N extends ExtendedLocator<N>> ReferencedLocator<N> ref(ReferencedLocator<N> referencedLocator, String locator) {
+ LocatorReference<ExtendedLocator<N>> reference = new LocatorReference<ExtendedLocator<N>>(referencedLocator);
+ return referenceInferred(reference, locator);
+ }
public T getReferenced() {
ExtendedLocator<T> referencedLocator = reference.getLocator();
14 years, 1 month