JBoss Rich Faces SVN: r21105 - trunk/core/api/src/main/java/org/ajax4jsf/javascript.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-01-20 04:01:13 -0500 (Thu, 20 Jan 2011)
New Revision: 21105
Modified:
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java
Log:
Fixed checkstyle violation in JSChainJSFFunction
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java 2011-01-20 07:00:42 UTC (rev 21104)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java 2011-01-20 09:01:13 UTC (rev 21105)
@@ -28,6 +28,10 @@
*/
public class JSChainJSFFunction extends JSFunction {
+ public JSChainJSFFunction(Object... parameters) {
+ super("jsf.util.chain", (Object[]) createFunctionArgs(parameters));
+ }
+
private static Object[] createFunctionArgs(Object[] sourceParams) {
Object[] result = new Object[sourceParams.length + 2];
@@ -40,8 +44,4 @@
return result;
}
- public JSChainJSFFunction(Object... parameters) {
- super("jsf.util.chain", (Object[]) createFunctionArgs(parameters));
- }
-
}
13 years, 11 months
JBoss Rich Faces SVN: r21104 - modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2011-01-20 02:00:42 -0500 (Thu, 20 Jan 2011)
New Revision: 21104
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-Basic_usage.xml_sample
Removed:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample
Log:
Renamed example
Copied: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-Basic_usage.xml_sample (from rev 21103, modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample)
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-Basic_usage.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-Basic_usage.xml_sample 2011-01-20 07:00:42 UTC (rev 21104)
@@ -0,0 +1,12 @@
+<rich:dataTable id="table" value="#{capitalsBean.capitals}" var="cap" rows="5">
+ <!-- table content -->
+ ...
+</rich:dataTable>
+<rich:datascroller for="table" maxPages="5">
+ <f:facet name="first">
+ <h:outputText value="First" />
+ </f:facet>
+ <f:facet name="last">
+ <h:outputText value="Last" />
+ </f:facet>
+</rich:datascroller>
Deleted: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample 2011-01-20 06:59:28 UTC (rev 21103)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample 2011-01-20 07:00:42 UTC (rev 21104)
@@ -1,12 +0,0 @@
-<rich:dataTable id="table" value="#{capitalsBean.capitals}" var="cap" rows="5">
- <!-- table content -->
- ...
-</rich:dataTable>
-<rich:datascroller for="table" maxPages="5">
- <f:facet name="first">
- <h:outputText value="First" />
- </f:facet>
- <f:facet name="last">
- <h:outputText value="Last" />
- </f:facet>
-</rich:datascroller>
13 years, 11 months
JBoss Rich Faces SVN: r21103 - in modules/docs/trunk/Component_Reference/src/main/docbook/en-US: extras and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2011-01-20 01:59:28 -0500 (Thu, 20 Jan 2011)
New Revision: 21103
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-pages_facet.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
Log:
rich:dataScroller docs
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2011-01-19 23:20:06 UTC (rev 21102)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2011-01-20 06:59:28 UTC (rev 21103)
@@ -621,13 +621,54 @@
<para>
The bound table or grid should also have the <varname>rows</varname> attribute defined to limit the number of rows per page.
</para>
+ <para>
+ The <sgmltag><rich:dataScroller></sgmltag> component must be re-rendered whenever a filter changes on the bound table, so that the scroller matches the current model for the table.
+ </para>
+ <example id="exam-Component_Reference-richdataScroller-Basic_usage">
+ <title>Basic usage</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richdataScroller-Basic_usage.xml_Sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
</section>
- <section id="sect-Component_Reference-richdataScroller-Appearance">
- <title>Appearance</title>
+ <section id="sect-Component_Reference-richdataScroller-Appearance_and_interactivity">
+ <title>Appearance and interactivity</title>
<para>
- The <sgmltag><rich:dataScroller></sgmltag> must be placed in the footer of the table or grid it needs to control. Alternatively, use the <varname>for</varname> attribute to bind the parent table or grid to the scroller.
+ The <varname>page</varname> attribute is a value-binding attribute used to define and save the current page number.
</para>
+ <para>
+ The <sgmltag><rich:dataScroller></sgmltag> component provides a range of controllers for scrolling through tables and grids:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term>Controls for scrolling by a specific amount</term>
+ <listitem>
+ <para>
+ The component includes controls for switching to the first page, the last page, the next page, and the previous page, as well as controls for fast-forwarding or rewinding by a set amount. Use the <varname>fastStep</varname> attribute to set the number of pages to skip when fast-forwarding or rewinding.
+ </para>
+ <para>
+ The appearance of these controls can be customized using the following facets: <literal>first</literal>, <literal>last</literal>, <literal>next</literal>, <literal>previous</literal>, <literal>fastforward</literal>, and <literal>rewind</literal>. Additionally, there are facets for the controls' disabled states: <literal>first_disabled</literal>, <literal>last_disabled</literal>, <literal>next_disabled</literal>, <literal>previous_disabled</literal>, <literal>fastforward_disabled</literal>, and <literal>rewind_disabled</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>Page controls</term>
+ <listitem>
+ <para>
+ The component also features a series of numbered controls to jump to a specific page. Use the <varname>maxPages</varname> attribute to limit the number of page controls that appear. The current page control is highlighted.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ The <varname>pageIndexVar</varname> and <varname>pagesVar</varname> attributes are request-scope variables for the current page and the total number of pages. Use these attributes with the <literal>pages</literal> facet to provide information about the pages of the table, as shown in <xref linkend="exam-Component_Reference-richdataScroller-pages_facet" />.
+ </para>
+ <example id="exam-Component_Reference-richdataScroller-pages_facet">
+ <title><literal>pages</literal> facet</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richdataScroller-pages_facet.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
+ <para>
+ To add optional separators between controls, define the separators with the <literal>controlsSeparator</literal> facet.
+ </para>
</section>
<section id="sect-Component_Reference-richdataScroller-Reference_data">
@@ -1042,20 +1083,20 @@
<section id="sect-Component_Reference-Tables_and_grids-richlist">
<title><sgmltag><rich:list></sgmltag></title>
<para>
- The <sgmltag><rich:list></sgmltag> component renders a list of items. The list can be an numerically ordered list, an unordered bullet-point list, or a data definition list. The component uses a data model for managing the list items, which can be updated dynamically.
+ The <sgmltag><rich:list></sgmltag> component renders a list of items. The list can be an numerically ordered list, an un-ordered bullet-point list, or a data definition list. The component uses a data model for managing the list items, which can be updated dynamically.
</para>
<section id="sect-Component_Reference-richlist-Basic_usage">
<title>Basic usage</title>
<para>
- The <varname>var</varname> attribute names a variable for iterating through the items in the data model. The items to iterate through are determined with the <varname>value</varname> attribute by using EL (Expression Lanugage).
+ The <varname>var</varname> attribute names a variable for iterating through the items in the data model. The items to iterate through are determined with the <varname>value</varname> attribute by using EL (Expression Language).
</para>
</section>
<section id="sect-Component_Reference-richlist-Type_of_list">
<title>Type of list</title>
<para>
- By default, the list is displayed as an unordered bullet-point list. The <varname>type</varname> attribute is used to specify different list types:
+ By default, the list is displayed as an un-ordered bullet-point list. The <varname>type</varname> attribute is used to specify different list types:
</para>
<variablelist>
<varlistentry>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-pages_facet.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-pages_facet.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-pages_facet.xml_sample 2011-01-20 06:59:28 UTC (rev 21103)
@@ -0,0 +1,11 @@
+<rich:dataTable value="#{capitalsBean.capitals}" var="cap" rows="5">
+ <!-- table content -->
+ ...
+ <f:facet name="footer">
+ <rich:datascroller pageIndexVar="pageIndex" pagesVar="pages">
+ <f:facet name="pages">
+ <h:outputText value="#{pageIndex} / #{pages}" />
+ </f:facet>
+ </rich:datascroller>
+ </f:facet>
+</rich:dataTable>
Added: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richdataScroller-richataScroller_example.xml_sample 2011-01-20 06:59:28 UTC (rev 21103)
@@ -0,0 +1,12 @@
+<rich:dataTable id="table" value="#{capitalsBean.capitals}" var="cap" rows="5">
+ <!-- table content -->
+ ...
+</rich:dataTable>
+<rich:datascroller for="table" maxPages="5">
+ <f:facet name="first">
+ <h:outputText value="First" />
+ </f:facet>
+ <f:facet name="last">
+ <h:outputText value="Last" />
+ </f:facet>
+</rich:datascroller>
13 years, 11 months
JBoss Rich Faces SVN: r21102 - in branches/RF-9797/ui/validator/ui/src: main/resources/META-INF and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2011-01-19 18:20:06 -0500 (Wed, 19 Jan 2011)
New Revision: 21102
Added:
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java
Modified:
branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/csv.xml
branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
Log:
CODING IN PROGRESS - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
Modified: branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -52,7 +52,7 @@
* @param component
* @return
*/
- protected FacesMessage getMessage(FacesContext context, T component) {
+ public FacesMessage getMessage(FacesContext context, T component) {
String messageId = getMessageId(component);
return MessageFactory.createMessage(context, messageId);
}
Modified: branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -38,7 +38,18 @@
// TODO: all messages should be passed to client side using js function RichFaces.csv.addMessage
String messageId;
if (component instanceof DoubleRangeValidator) {
- messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ DoubleRangeValidator validator = (DoubleRangeValidator) component;
+ if(validator.getMaximum() >0){
+ if(validator.getMinimum()>0){
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else {
+ messageId = DoubleRangeValidator.MAXIMUM_MESSAGE_ID;
+ }
+ } else if( validator.getMinimum()>0){
+ messageId = DoubleRangeValidator.MINIMUM_MESSAGE_ID;
+ } else {
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set, validator always pass ).
+ }
} else if (component instanceof LengthValidator) {
LengthValidator validator = (LengthValidator) component;
if(validator.getMaximum() >0){
@@ -53,7 +64,18 @@
messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set, validator always pass ).
}
} else if (component instanceof LongRangeValidator) {
- messageId = LongRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ LongRangeValidator validator = (LongRangeValidator) component;
+ if(validator.getMaximum() >0){
+ if(validator.getMinimum()>0){
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else {
+ messageId = LongRangeValidator.MAXIMUM_MESSAGE_ID;
+ }
+ } else if( validator.getMinimum()>0){
+ messageId = LongRangeValidator.MINIMUM_MESSAGE_ID;
+ } else {
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;// What to use for that case ( no min/max set, validator always pass ).
+ }
} else if (component instanceof RegexValidator) {
messageId = RegexValidator.NOT_MATCHED_MESSAGE_ID;
} else if (component instanceof RequiredValidator) {
Modified: branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/csv.xml
===================================================================
--- branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-01-19 23:20:06 UTC (rev 21102)
@@ -9,6 +9,30 @@
<function>RichFaces.csv.convertNumber</function>
</component>
<component>
+ <type>javax.faces.convert.BooleanConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertBoolean</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.ByteConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertByte</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.ShortConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertShort</function>
+ </component>
+ <component>
<type>javax.faces.validator.LengthValidator</type>
<resource>
<name>csv.reslib</name>
@@ -16,4 +40,76 @@
</resource>
<function>RichFaces.csv.validateLength</function>
</component>
+ <component>
+ <type>javax.faces.validator.LongRangeValidator</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateLongRange</function>
+ </component>
+ <component>
+ <type>javax.faces.validator.DoubleRangeValidator</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateDoubleRange</function>
+ </component>
+ <component>
+ <type>javax.faces.validator.RegexValidator</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateRegex</function>
+ </component>
+ <component>
+ <type>javax.faces.validator.RequiredValidator</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateRequired</function>
+ </component>
+ <component>
+ <type>javax.validation.constraints.NotNull</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateRequired</function>
+ </component>
+ <component>
+ <type>javax.validation.constraints.Size</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateSize</function>
+ </component>
+ <component>
+ <type>javax.validation.constraints.Pattern</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validatePattern</function>
+ </component>
+ <component>
+ <type>javax.validation.constraints.Min</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateMin</function>
+ </component>
+ <component>
+ <type>javax.validation.constraints.Max</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.validateMax</function>
+ </component>
</scripts>
\ No newline at end of file
Modified: branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
===================================================================
--- branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-01-19 23:20:06 UTC (rev 21102)
@@ -6,7 +6,7 @@
var _validators = {};
var _converters = {};
- var RE_MESSAGE_PATTERN = /\{(\d+)\}/g;
+ var RE_MESSAGE_PATTERN = /\'?\{(\d+)\}\'?/g;
var __interpolateMessage = function (message, values) {
if (message) {
@@ -135,14 +135,14 @@
"convertByte": function (value,label,params,msg) {
var result; value = $.trim(value);
if (!rf.csv.RE_DIGITS.test(value) || (result=parseInt(value,10))<-128 || result>127) {
- throw rf.csv.getMessage(msg, 'BYTE_CONVERTER_BYTE', [value, 0, params.componentId]);
+ throw rf.csv.interpolateMessage(msg, [value, 254, label]);
}
return result;
},
"convertNumber": function (value,label,params,msg) {
var result; value=$.trim(value);
if (isNaN(value)) {
- throw rf.csv.getMessage(msg, 'NUMBER_CONVERTER_NUMBER', [value, 0, params.componentId]);
+ throw rf.csv.interpolateMessage(msg, [value, 0, label]);
} else {
result = parseInt(value, 10);
}
@@ -151,12 +151,40 @@
"convertShort": function (value,label,params,msg) {
var result; value = $.trim(value);
if (!rf.csv.RE_DIGITS.test(value) || (result=parseInt(value,10))<-32768 || result>32767) {
- throw rf.csv.getMessage(msg, 'SHORT_CONVERTER_SHORT', [value, 0, params.componentId]);
+ throw rf.csv.interpolateMessage(msg, [value, 0, label]);
}
return result;
}
});
+ var validateRange = function(value,label,params,msg) {
+ var isMinSet = typeof params.minimum == "number" ;//&& params.minimum >0;
+ var isMaxSet = typeof params.maximum == "number" ;//&& params.maximum >0;
+
+ if (isMaxSet && value > params.maximum) {
+ throw rf.csv.interpolateMessage(msg,isMinSet?[params.minimum,params.maximum,label]:[params.maximum,label]);
+ }
+ if (isMinSet && value < params.minimum) {
+ throw rf.csv.interpolateMessage(msg,isMaxSet?[params.minimum,params.maximum,label]:[params.minimum,label]);
+ }
+ };
+
+ var validateRegex = function(value,label,pattern,msg) {
+ if (typeof pattern != "string" || pattern.length == 0) {
+ throw rf.csv.getMessage(msg, 'REGEX_VALIDATOR_PATTERN_NOT_SET', []);
+ }
+
+ var re;
+ try {
+ re = new RegExp(pattern);
+ } catch (e) {
+ throw rf.csv.getMessage(msg, 'REGEX_VALIDATOR_MATCH_EXCEPTION', []);
+ }
+ if (!re.test(value)){
+ throw rf.csv.interpolateMessage(msg, [pattern,label]);
+ }
+
+ }
/*
* Validators implementation
*/
@@ -174,23 +202,7 @@
}
}
- var isMinSet = typeof params.minimum == "number";
- var isMaxSet = typeof params.maximum == "number";
-
- if (isMaxSet && value > params.maximum) {
- if (isMinSet) {
- throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_NOT_IN_RANGE', [params.minimum, params.maximum, componentId]);
- } else {
- throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_MAXIMUM', [params.maximum, componentId]);
- }
- }
- if (isMinSet && value < params.minimum) {
- if (isMaxSet) {
- throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_NOT_IN_RANGE', [params.minimum, params.maximum, componentId]);
- } else {
- throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_MINIMUM', [params.minimum, componentId]);
- }
- }
+ validateRange(value,label,params,msg);
},
"validateDoubleRange": function (value,label,params,msg) {
var type = typeof value;
@@ -205,54 +217,36 @@
}
}
- var isMinSet = typeof params.minimum == "number";
- var isMaxSet = typeof params.maximum == "number";
-
- if (isMaxSet && value > params.maximum) {
- if (isMinSet) {
- throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_NOT_IN_RANGE', [params.minimum, params.maximum, componentId]);
- } else {
- throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_MAXIMUM', [params.maximum, componentId]);
- }
- }
- if (isMinSet && value < params.minimum) {
- if (isMaxSet) {
- throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_NOT_IN_RANGE', [params.minimum, params.maximum, componentId]);
- } else {
- throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_MINIMUM', [params.minimum, componentId]);
- }
- }
+ validateRange(value,label,params,msg);
},
"validateLength": function (value,label,params,msg) {
- var isMinSet = typeof params.minimum == "number" && params.minimum >0;
- var isMaxSet = typeof params.maximum == "number" && params.maximum >0;
-
- if (isMaxSet && value.length > params.maximum) {
- throw rf.csv.interpolateMessage(msg,isMinSet?[params.minimum,params.maximum,label]:[params.maximum,label]);
- }
- if (isMinSet && value.length < params.minimum) {
- throw rf.csv.interpolateMessage(msg,isMaxSet?[params.minimum,params.maximum,label]:[params.minimum,label]);
- }
+ var length = value?value.length:0;
+ validateRange(length,label,params,msg);
},
+ "validateSize": function (value,label,params,msg) {
+ var length = value?value.length:0;
+ validateRange(length,label,{maximum:params.max,minimum:params.min},msg);
+ },
"validateRegex": function (value,label,params,msg) {
- if (typeof params.pattern != "string" || params.pattern.length == 0) {
- throw rf.csv.getMessage(msg, 'REGEX_VALIDATOR_PATTERN_NOT_SET', []);
- }
-
- var re;
- try {
- re = new RegExp(params.pattern);
- } catch (e) {
- throw rf.csv.getMessage(msg, 'REGEX_VALIDATOR_MATCH_EXCEPTION', []);
- }
- if (!re.test(value)){
- throw rf.csv.getMessage(msg, 'REGEX_VALIDATOR_NOT_MATCHED', [params.pattern]);
- }
+ validateRegex(value,label,params.pattern,msg);
},
+ "validatePattern": function (value,label,params,msg) {
+ validateRegex(value,label,params.regexp,msg);
+ },
"validateRequired": function (value,label,params,msg) {
- if (value.length==0) {
- throw rf.csv.getMessage(msg, 'UIINPUT_REQUIRED', [componentId]);
+ if (!value ) {
+ throw rf.csv.interpolateMessage(msg, [label]);
}
+ },
+ "validateMax": function (value,label,params,msg) {
+ if (value > params.value ) {
+ throw msg;
+ }
+ },
+ "validateMin": function (value,label,params,msg) {
+ if (value < params.value ) {
+ throw msg;
+ }
}
});
Modified: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -1,9 +1,14 @@
package org.richfaces.javascript.client;
+import static org.easymock.EasyMock.expect;
+
+import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import org.jboss.test.faces.mock.MockFacesEnvironment;
import org.jboss.test.qunit.Qunit;
@@ -20,6 +25,8 @@
@RunWith(Parameterized.class)
public abstract class MockTestBase {
+ protected static final String TEST_COMPONENT_ID = "testComponent";
+
@Rule
public final Qunit qunit;
@@ -41,8 +48,11 @@
}
protected void recordMocks() {
- // template method to record mock objects
-
+ UIViewRoot viewRoot = facesEnvironment.createMock(UIViewRoot.class);
+ expect(viewRoot.getLocale()).andStubReturn(Locale.ENGLISH);
+ expect(facesEnvironment.getFacesContext().getViewRoot()).andStubReturn(viewRoot);
+ expect(component.getAttributes()).andStubReturn(Collections.EMPTY_MAP);
+ expect(component.getClientId(facesEnvironment.getFacesContext())).andStubReturn(TEST_COMPONENT_ID);
}
@After
@@ -62,11 +72,16 @@
protected org.jboss.test.qunit.Qunit.Builder createQunitPage() {
return Qunit.builder().loadJsfResource("jquery.js").loadJsfResource("richfaces.js")
- .loadJsfResource("richfaces-event.js").loadJsfResource("csv.js", "org.richfaces");
+ .loadJsfResource("richfaces-event.js").loadJsfResource("richfaces-csv.js", "org.richfaces");
}
protected abstract String getJavaScriptFunctionName();
+ protected Map<String, Object> getOptions() {
+ Map<String, Object> options = criteria.getOptions();
+ return options;
+ }
+
protected static List<RunParameters[]> options(RunParameters ...criterias){
Builder<RunParameters[]> builder = ImmutableList.builder();
for (RunParameters testCriteria : criterias) {
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,45 @@
+package org.richfaces.javascript.client.converter;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.ByteConverter;
+import javax.faces.convert.Converter;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+public class ByteConverterTest extends ConverterTestBase {
+
+ public ByteConverterTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ @Override
+ protected Converter createConverter() {
+ ByteConverter byteConverter = new ByteConverter();
+ return byteConverter;
+ }
+
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "convertByte";
+ }
+
+ @Override
+ protected void compareResult(Object convertedValue, Object jsConvertedValue) {
+ assertTrue(jsConvertedValue instanceof Double);
+ assertTrue(convertedValue instanceof Byte);
+ Double jsDouble = (Double) jsConvertedValue;
+ Double jsfDouble = new Double((Byte)convertedValue);
+ assertEquals(jsfDouble, jsDouble,0.0000001);
+ }
+
+ @Parameters
+ public static List<RunParameters[]> getRunParameterss() {
+ return options(pass("true"), pass("ok"), pass("123"),pass("0"),pass("1"),pass("255"),pass("-128"),pass("-129"),pass("256"),pass("-0"),pass("0.05"));
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -1,16 +1,27 @@
package org.richfaces.javascript.client.converter;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.*;
+import javax.faces.application.FacesMessage;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
+import javax.faces.validator.Validator;
+import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
+import net.sourceforge.htmlunit.corejs.javascript.NativeObject;
+
import org.ajax4jsf.javascript.JSFunction;
import org.junit.Test;
+import org.richfaces.javascript.Message;
import org.richfaces.javascript.client.MockTestBase;
import org.richfaces.javascript.client.RunParameters;
+import org.richfaces.validator.ConverterServiceImpl;
+import com.gargoylesoftware.htmlunit.ScriptException;
+
public abstract class ConverterTestBase extends MockTestBase {
public ConverterTestBase(RunParameters criteria) {
@@ -24,24 +35,49 @@
Object convertedValue =
converter.getAsObject(facesEnvironment.getFacesContext(), component, criteria.getValue().toString());
Object jsConvertedValue =
- convertOnClient();
- assertEquals(convertedValue, jsConvertedValue);
+ convertOnClient(converter);
+ if(null != convertedValue || null != jsConvertedValue){
+ compareResult(convertedValue, jsConvertedValue);
+ }
} catch (ConverterException e) {
// JSF conversion error - JavaScript should throw exception too.
try {
- convertOnClient();
+ convertOnClient(converter);
assertFalse("Client-side converted didn't throw exception for value:"+criteria.getValue(), true);
- } catch (Exception jsException){
+ } catch (ScriptException jsException){
// Test passed
+ Throwable cause = jsException.getCause();
+ assertTrue(cause instanceof JavaScriptException);
+ NativeObject value = (NativeObject) ((JavaScriptException) cause).getValue();
+ assertEquals(e.getFacesMessage().getDetail(), value.get("detail"));
+ assertEquals(e.getFacesMessage().getSummary(), value.get("summary"));
}
}
}
- protected Object convertOnClient() throws ConverterException {
- JSFunction clientSideFunction = new JSFunction("RichFaces.csv." + getJavaScriptFunctionName(),criteria.getValue(),getErrorMessage(),getJavaScriptOptions());
+ protected void compareResult(Object convertedValue, Object jsConvertedValue) {
+ assertEquals(convertedValue, jsConvertedValue);
+ }
+
+ protected Object convertOnClient(Converter converter) throws ConverterException {
+ JSFunction clientSideFunction = new JSFunction("RichFaces.csv." + getJavaScriptFunctionName(),criteria.getValue(),TEST_COMPONENT_ID,getJavaScriptOptions(), getErrorMessage(converter));
return qunit.runScript(clientSideFunction.toScript());
}
+ private Object getErrorMessage(Converter converter) {
+ ConverterServiceImpl converterService = new ConverterServiceImpl();
+ FacesMessage message = converterService.getMessage(facesEnvironment.getFacesContext(), converter);
+ return new Message(message);
+ }
+
protected abstract Converter createConverter();
+ protected void compareNumbers(Object convertedValue, Object jsConvertedValue) {
+ assertTrue(jsConvertedValue instanceof Double);
+ assertTrue(convertedValue instanceof Number);
+ Double jsDouble = (Double) jsConvertedValue;
+ Double jsfDouble = Double.valueOf(((Number)convertedValue).doubleValue());
+ assertEquals(jsfDouble, jsDouble,0.0000001);
+ }
+
}
\ No newline at end of file
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,46 @@
+package org.richfaces.javascript.client.converter;
+
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.NumberConverter;
+import javax.faces.convert.Converter;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+public class NumberConverterTest extends ConverterTestBase {
+
+ private static final String TYPE = "type";
+
+ public NumberConverterTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ @Override
+ protected Converter createConverter() {
+ NumberConverter converter = new NumberConverter();
+ Map<String, Object> options = getOptions();
+ if(options.containsKey(TYPE)){
+ converter.setType((String) options.get(TYPE));
+ }
+ return converter;
+ }
+
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "convertNumber";
+ }
+
+ @Override
+ protected void compareResult(Object convertedValue, Object jsConvertedValue) {
+ compareNumbers(convertedValue, jsConvertedValue);
+ }
+
+ @Parameters
+ public static List<RunParameters[]> getRunParameterss() {
+ return options(pass("true"), pass("123"),pass("0"),pass("1"),pass("255"),pass("-128"),pass("-129"),pass("256"),pass("-0"),pass("0.05"));
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,41 @@
+package org.richfaces.javascript.client.converter;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertTrue;
+
+import java.util.List;
+
+import javax.faces.convert.BooleanConverter;
+import javax.faces.convert.ShortConverter;
+import javax.faces.convert.Converter;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+public class ShortConverterTest extends ConverterTestBase {
+
+ public ShortConverterTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ @Override
+ protected Converter createConverter() {
+ ShortConverter byteConverter = new ShortConverter();
+ return byteConverter;
+ }
+
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "convertShort";
+ }
+
+ @Override
+ protected void compareResult(Object convertedValue, Object jsConvertedValue) {
+ compareNumbers(convertedValue, jsConvertedValue);
+ }
+
+ @Parameters
+ public static List<RunParameters[]> getRunParameterss() {
+ return options(pass("true"), pass("123"),pass("0"),pass("1"),pass(Long.toString(Long.MAX_VALUE)),pass(Short.toString(Short.MIN_VALUE)),pass(Short.toString(Short.MAX_VALUE)),pass("-129"),pass("256"),pass("-0"),pass("0.05"));
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,56 @@
+package org.richfaces.javascript.client.validator;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Set;
+
+import javax.validation.Validation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+
+import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.junit.Test;
+import org.richfaces.javascript.client.MockTestBase;
+import org.richfaces.javascript.client.RunParameters;
+
+import com.gargoylesoftware.htmlunit.ScriptException;
+
+public abstract class BeanValidatorTestBase extends MockTestBase {
+
+ protected static final String PROP = "property";
+
+ public BeanValidatorTestBase(RunParameters criteria) {
+ super(criteria);
+ }
+
+ @Test
+ public void testValidator() throws Exception {
+ Validator validator = createValidator();
+ Set<?> constrains = validator.validateValue(getBeanType(), (String) getOptions()
+ .get(PROP), criteria.getValue());
+ try {
+ validateOnClient(validator);
+ assertTrue("Bean validator found error for value: " + criteria.getValue() + ", validator options: "
+ + getOptions(), constrains.isEmpty());
+ } catch (ScriptException e2) {
+ // both methods throws exceptions - it's ok.
+ Throwable cause = e2.getCause();
+ assertTrue(cause instanceof JavaScriptException);
+ }
+ }
+
+ protected abstract Class<?> getBeanType();
+
+ protected Object validateOnClient(Validator validator) throws ValidationException {
+ JSFunction clientSideFunction = new JSFunction("RichFaces.csv." + getJavaScriptFunctionName(),
+ criteria.getValue(), TEST_COMPONENT_ID, getJavaScriptOptions(), getErrorMessage());
+ return qunit.runScript(clientSideFunction.toScript());
+ }
+
+ protected Validator createValidator() {
+ return Validation.buildDefaultValidatorFactory().usingContext().getValidator();
+ }
+
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.richfaces.javascript.client.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.validator.DoubleRangeValidator;
+import javax.faces.validator.Validator;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class DoubleRangeValidatorTest extends ValidatorTestBase {
+
+ private static final String MINIMUM = "minimum";
+ private static final String MAXIMUM = "maximum";
+ /**
+ * @param criteria
+ */
+ public DoubleRangeValidatorTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.validator.ValidatorTestBase#createValidator()
+ */
+ @Override
+ protected Validator createValidator() {
+ DoubleRangeValidator validator = new DoubleRangeValidator();
+ Map<String, Object> options = getOptions();
+ if(options.containsKey(MINIMUM)){
+ validator.setMinimum((Double) options.get(MINIMUM));
+ }
+ if(options.containsKey(MAXIMUM)){
+ validator.setMaximum((Double) options.get(MAXIMUM));
+ }
+ return validator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.MockTestBase#getJavaScriptFunctionName()
+ */
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "validateDoubleRange";
+ }
+
+ @Parameters
+ public static List<RunParameters[]> parameters() {
+ return options(pass(0L),pass(3L),pass(Double.MAX_VALUE),
+ pass(0.0D,MINIMUM,2.0D),pass(2.0D,MINIMUM,2.0D),pass(3.0D,MINIMUM,2.0D),pass(-3.0D,MINIMUM,2.0D),
+ pass(0.0D,MAXIMUM,2.0D),pass(2.0D,MAXIMUM,2.0D),pass(3.0D,MAXIMUM,2.0D),pass(-3.0D,MAXIMUM,2.0D),
+ pass(0.0D,MINIMUM,3.0D,MAXIMUM,5.0D),pass(3.0D,MINIMUM,3.0D,MAXIMUM,5.0D),pass(4.0D,MINIMUM,3.0D,MAXIMUM,5.0D),pass(7.0D,MINIMUM,3.0D,MAXIMUM,5.0D));
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -33,7 +33,7 @@
@Override
protected Validator createValidator() {
LengthValidator validator = new LengthValidator();
- Map<String, Object> options = criteria.getOptions();
+ Map<String, Object> options = getOptions();
if(options.containsKey(MINIMUM)){
validator.setMinimum((Integer) options.get(MINIMUM));
}
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package org.richfaces.javascript.client.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.validator.LongRangeValidator;
+import javax.faces.validator.Validator;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class LongRangeValidatorTest extends ValidatorTestBase {
+
+ private static final String MINIMUM = "minimum";
+ private static final String MAXIMUM = "maximum";
+ /**
+ * @param criteria
+ */
+ public LongRangeValidatorTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.validator.ValidatorTestBase#createValidator()
+ */
+ @Override
+ protected Validator createValidator() {
+ LongRangeValidator validator = new LongRangeValidator();
+ Map<String, Object> options = getOptions();
+ if(options.containsKey(MINIMUM)){
+ validator.setMinimum((Long) options.get(MINIMUM));
+ }
+ if(options.containsKey(MAXIMUM)){
+ validator.setMaximum((Long) options.get(MAXIMUM));
+ }
+ return validator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.MockTestBase#getJavaScriptFunctionName()
+ */
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "validateLongRange";
+ }
+
+ @Parameters
+ public static List<RunParameters[]> parameters() {
+ return options(pass(0L),pass(3L),pass(Long.MAX_VALUE),
+ pass(0L,MINIMUM,2L),pass(2L,MINIMUM,2L),pass(3L,MINIMUM,2L),pass(-3L,MINIMUM,2L),
+ pass(0L,MAXIMUM,2L),pass(2L,MAXIMUM,2L),pass(3L,MAXIMUM,2L),pass(-3L,MAXIMUM,2L),
+ pass(0L,MINIMUM,3L,MAXIMUM,5L),pass(3L,MINIMUM,3L,MAXIMUM,5L),pass(4L,MINIMUM,3L,MAXIMUM,5L),pass(7L,MINIMUM,3L,MAXIMUM,5L));
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,59 @@
+/**
+ *
+ */
+package org.richfaces.javascript.client.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.validator.LengthValidator;
+import javax.faces.validator.Validator;
+import javax.validation.constraints.Max;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class MaxValidatorTest extends BeanValidatorTestBase {
+
+ private static final String MAXIMUM = "value";
+ /**
+ * @param criteria
+ */
+ public MaxValidatorTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.MockTestBase#getJavaScriptFunctionName()
+ */
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "validateMax";
+ }
+
+ @Parameters
+ public static List<RunParameters[]> parameters() {
+ return options(
+ pass(0,PROP,"number",MAXIMUM,2),pass(2,PROP,"number",MAXIMUM,2),pass(123,PROP,"number",MAXIMUM,2)
+ );
+ }
+
+ public static final class Bean {
+
+ @Max(2)
+ public int getNumber() {
+ return 0;
+ }
+
+ }
+
+ @Override
+ protected Class<?> getBeanType() {
+ return Bean.class;
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,56 @@
+/**
+ *
+ */
+package org.richfaces.javascript.client.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.validator.RegexValidator;
+import javax.faces.validator.Validator;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class RegexValidatorTest extends ValidatorTestBase {
+
+ private static final String PATTERN = "pattern";
+ /**
+ * @param criteria
+ */
+ public RegexValidatorTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.validator.ValidatorTestBase#createValidator()
+ */
+ @Override
+ protected Validator createValidator() {
+ RegexValidator validator = new RegexValidator();
+ Map<String, Object> options = getOptions();
+ if(options.containsKey(PATTERN)){
+ validator.setPattern((String) options.get(PATTERN));
+ }
+ return validator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.MockTestBase#getJavaScriptFunctionName()
+ */
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "validateRegex";
+ }
+
+ @Parameters
+ public static List<RunParameters[]> parameters() {
+ return options(pass(""),pass("aaa"),pass("123"),
+ pass("",PATTERN,".*"),pass("vv",PATTERN,"\\S*"),pass("123",PATTERN,"\\d+")
+ );
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java (rev 0)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -0,0 +1,52 @@
+/**
+ *
+ */
+package org.richfaces.javascript.client.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.validator.RequiredValidator;
+import javax.faces.validator.Validator;
+
+import org.junit.runners.Parameterized.Parameters;
+import org.richfaces.javascript.client.RunParameters;
+
+/**
+ * @author asmirnov
+ *
+ */
+public class RequiredValidatorTest extends ValidatorTestBase {
+
+ /**
+ * @param criteria
+ */
+ public RequiredValidatorTest(RunParameters criteria) {
+ super(criteria);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.validator.ValidatorTestBase#createValidator()
+ */
+ @Override
+ protected Validator createValidator() {
+ RequiredValidator validator = new RequiredValidator();
+ Map<String, Object> options = getOptions();
+ return validator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.javascript.client.MockTestBase#getJavaScriptFunctionName()
+ */
+ @Override
+ protected String getJavaScriptFunctionName() {
+ return "validateRequired";
+ }
+
+ @Parameters
+ public static List<RunParameters[]> parameters() {
+ return options(pass(""),pass("aaa"),pass("123"),
+ pass(null)
+ );
+ }
+}
Property changes on: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
===================================================================
--- branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-01-19 19:46:27 UTC (rev 21101)
+++ branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-01-19 23:20:06 UTC (rev 21102)
@@ -5,6 +5,7 @@
import java.util.Collections;
+import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
@@ -17,12 +18,15 @@
import org.ajax4jsf.javascript.JSFunction;
import org.junit.Test;
+import org.richfaces.javascript.Message;
import org.richfaces.javascript.client.MockTestBase;
import org.richfaces.javascript.client.RunParameters;
+import org.richfaces.validator.FacesValidatorServiceImpl;
import com.gargoylesoftware.htmlunit.ScriptException;
public abstract class ValidatorTestBase extends MockTestBase {
+
private static final Converter NUMBER_CONVERTER = new Converter() {
@@ -45,38 +49,42 @@
Validator validator = createValidator();
try {
validator.validate(facesEnvironment.getFacesContext(), component, criteria.getValue());
- validateOnClient();
+ validateOnClient(validator);
} catch (ValidatorException e) {
// client-side script has to throw exception too.
try {
- validateOnClient();
- assertFalse("JSF validator throws exception for value: " + criteria.getValue(), true);
+ validateOnClient(validator);
+ assertFalse("JSF validator throws exception for value: " + criteria.getValue()+ ", validator options: "+getOptions(), true);
} catch (ScriptException e2) {
// both methods throws exceptions - it's ok.
- e2.printStackTrace();
Throwable cause = e2.getCause();
assertTrue(cause instanceof JavaScriptException);
NativeObject value = (NativeObject) ((JavaScriptException) cause).getValue();
- assertEquals(getErrorMessage().getDetail(), value.get("detail"));
+ assertEquals(e.getFacesMessage().getDetail(), value.get("detail"));
+ assertEquals(e.getFacesMessage().getSummary(), value.get("summary"));
}
}
}
- protected Object validateOnClient() throws ValidationException {
+ protected Object validateOnClient(Validator validator) throws ValidationException {
JSFunction clientSideFunction =
- new JSFunction("RichFaces.csv." + getJavaScriptFunctionName(), criteria.getValue(), getErrorMessage(),
- getJavaScriptOptions());
+ new JSFunction("RichFaces.csv." + getJavaScriptFunctionName(), criteria.getValue(), TEST_COMPONENT_ID,
+ getJavaScriptOptions(),getErrorMessage(validator));
return qunit.runScript(clientSideFunction.toScript());
}
+ private Object getErrorMessage(Validator validator) {
+ FacesValidatorServiceImpl validatorService = new FacesValidatorServiceImpl();
+ FacesMessage message = validatorService.getMessage(facesEnvironment.getFacesContext(), validator);
+ return new Message(message);
+ }
+
protected abstract Validator createValidator();
@Override
protected void recordMocks() {
super.recordMocks();
- expect(component.getAttributes()).andStubReturn(Collections.EMPTY_MAP);
- expect(component.getClientId(facesEnvironment.getFacesContext())).andStubReturn("testComponent");
expect(facesEnvironment.getApplication().createConverter("javax.faces.Number")).andStubReturn(NUMBER_CONVERTER);
}
}
13 years, 11 months
JBoss Rich Faces SVN: r21101 - in trunk: core/api/src/main/java/org/ajax4jsf/javascript and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-01-19 14:46:27 -0500 (Wed, 19 Jan 2011)
New Revision: 21101
Added:
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java
Modified:
trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java
trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
trunk/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
Log:
https://issues.jboss.org/browse/RF-7781
Modified: trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2011-01-19 18:42:01 UTC (rev 21100)
+++ trunk/core/api/src/main/java/org/ajax4jsf/component/AjaxClientBehavior.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -51,6 +51,10 @@
public void setOnbeforedomupdate(String onbeforedomupdate);
+ public String getOnbeforesubmit();
+
+ public void setOnbeforesubmit(String onbeforesubmit);
+
public Object getData();
public void setData(Object data);
Added: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java (rev 0)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSChainJSFFunction.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, 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.ajax4jsf.javascript;
+
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class JSChainJSFFunction extends JSFunction {
+
+ private static Object[] createFunctionArgs(Object[] sourceParams) {
+ Object[] result = new Object[sourceParams.length + 2];
+
+ result[0] = JSReference.THIS;
+ result[1] = JSReference.EVENT;
+
+ for (int i = 0; i < sourceParams.length; i++) {
+ result[i + 2] = sourceParams[i];
+ }
+ return result;
+ }
+
+ public JSChainJSFFunction(Object... parameters) {
+ super("jsf.util.chain", (Object[]) createFunctionArgs(parameters));
+ }
+
+}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java 2011-01-19 18:42:01 UTC (rev 21100)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxFunction.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -23,6 +23,7 @@
import java.io.IOException;
+import org.ajax4jsf.javascript.JSChainJSFFunction;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptStringBase;
import org.ajax4jsf.javascript.ScriptUtils;
@@ -71,7 +72,7 @@
this.options = eventOptions;
}
- public void appendScript(Appendable target) throws IOException {
+ private void appendAjaxFunctionCall(Appendable target) throws IOException {
target.append(FUNCTION_NAME);
target.append('(');
@@ -86,6 +87,17 @@
target.append(")");
}
+
+ public void appendScript(Appendable target) throws IOException {
+ if (options.getBeforesubmitHandler() == null) {
+ appendAjaxFunctionCall(target);
+ } else {
+ StringBuilder ajaxCall = new StringBuilder();
+ appendAjaxFunctionCall(ajaxCall);
+
+ ScriptUtils.appendScript(target, new JSChainJSFFunction(options.getBeforesubmitHandler(), ajaxCall.toString()));
+ }
+ }
}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java 2011-01-19 18:42:01 UTC (rev 21100)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/AjaxOptions.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -41,6 +41,8 @@
private Map<String, Object> options = new HashMap<String, Object>();
+ private Object beforesubmitHandler;
+
public void appendScript(Appendable target) throws IOException {
ScriptUtils.appendScript(target, options);
}
@@ -125,4 +127,12 @@
public void setAjaxComponent(Object ajaxComponent) {
getParameters().put(AjaxConstants.AJAX_COMPONENT_ID_PARAMETER, ajaxComponent);
}
+
+ public Object getBeforesubmitHandler() {
+ return beforesubmitHandler;
+ }
+
+ public void setBeforesubmitHandler(Object beforesubmitHandler) {
+ this.beforesubmitHandler = beforesubmitHandler;
+ }
}
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2011-01-19 18:42:01 UTC (rev 21100)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -43,6 +43,7 @@
*/
public final class AjaxRendererUtils {
+ public static final String BEGIN_EVENT_NAME = "begin";
public static final String AJAX_ABORT_ATTR = "ignoreDupResponses";
public static final String AJAX_AREAS_RENDERED = "org.ajax4jsf.areas.rendered";
public static final String AJAX_DELAY_ATTR = "requestDelay";
@@ -231,6 +232,7 @@
private static void appenAjaxBehaviorOptions(ClientBehaviorContext behaviorContext, AjaxClientBehavior behavior, AjaxOptions ajaxOptions) {
ajaxOptions.setParameter(AjaxConstants.BEHAVIOR_EVENT_PARAMETER, behaviorContext.getEventName());
+ ajaxOptions.setBeforesubmitHandler(behavior.getOnbeforesubmit());
for (BehaviorOptionsData optionsData : BehaviorOptionsData.values()) {
String optionValue = optionsData.getAttributeValue(behavior);
@@ -240,20 +242,22 @@
}
}
}
-
- private static void appendComponentOptions(FacesContext facesContext, UIComponent component,
- AjaxOptions ajaxOptions) {
- String behaviorName = "begin";
+
+ private static String getHandlerScript(FacesContext facesContext, UIComponent component, String attributeName, String eventName) {
HandlersChain handlersChain = new HandlersChain(facesContext, component);
- String inlineHandler = getAjaxOnBegin(component);
+ String inlineHandler = (String) component.getAttributes().get(attributeName);
handlersChain.addInlineHandlerAsValue(inlineHandler);
- handlersChain.addBehaviors(behaviorName);
+ handlersChain.addBehaviors(eventName);
- String handlerScript = handlersChain.toScript();
+ return handlersChain.toScript();
+ }
+ private static void appendComponentOptions(FacesContext facesContext, UIComponent component,
+ AjaxOptions ajaxOptions) {
+ String handlerScript = getHandlerScript(facesContext, component, ONBEGIN_ATTR_NAME, BEGIN_EVENT_NAME);
if (isNotEmpty(handlerScript)) {
- ajaxOptions.set(behaviorName, handlerScript);
+ ajaxOptions.set(BEGIN_EVENT_NAME, handlerScript);
}
String queueId = getQueueId(component);
@@ -585,9 +589,4 @@
return function;
}
- //TODO nick - refactor - remove this method?
- public static String getAjaxOnBegin(UIComponent component) {
- return (String) component.getAttributes().get(ONBEGIN_ATTR_NAME);
- }
-
}
Modified: trunk/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
--- trunk/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2011-01-19 18:42:01 UTC (rev 21100)
+++ trunk/ui/core/ui/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2011-01-19 19:46:27 UTC (rev 21101)
@@ -22,12 +22,6 @@
package org.ajax4jsf.component.behavior;
-import static org.richfaces.renderkit.AjaxConstants.ALL;
-import static org.richfaces.renderkit.AjaxConstants.FORM;
-import static org.richfaces.renderkit.AjaxConstants.NONE;
-import static org.richfaces.renderkit.AjaxConstants.REGION;
-import static org.richfaces.renderkit.AjaxConstants.THIS;
-
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
@@ -67,15 +61,9 @@
private static final Set<ClientBehaviorHint> HINTS = Collections.unmodifiableSet(EnumSet
.of(ClientBehaviorHint.SUBMITTING));
- private static final Set<String> ALL_SINGLETON_SET = Collections.singleton(ALL);
- private static final Set<String> FORM_SINGLETON_SET = Collections.singleton(FORM);
- private static final Set<String> THIS_SINGLETON_SET = Collections.singleton(THIS);
- private static final Set<String> REGION_SINGLETON_SET = Collections.singleton(REGION);
- private static final Set<String> NONE_SINGLETON_SET = Collections.singleton(NONE);
-
enum PropertyKeys {
data, execute, onbeforedomupdate, onbegin, oncomplete, onerror, queueId, render,
- status, disabled, limitRender, immediate, bypassUpdates
+ status, disabled, limitRender, immediate, bypassUpdates, onbeforesubmit
}
private Set<String> execute;
@@ -121,6 +109,8 @@
} else if (compare(PropertyKeys.bypassUpdates, name)) {
value = expFactory.coerceToType(value, Boolean.class);
setBypassUpdates((Boolean) value);
+ } else if (compare(PropertyKeys.onbeforesubmit, name)) {
+ setOnbeforesubmit((String) value);
}
}
@@ -139,36 +129,6 @@
return result;
}
- private Set<String> toSingletonSet(String propertyName, String value) {
-
- if(value == null) {
- return null;
- }
-
- if(value.trim().length() == 0) {
- return null;
- }
-
- if(value.charAt(0) == '@') {
- if (ALL.equals(value)) {
- return ALL_SINGLETON_SET;
- } else if (FORM.equals(value)) {
- return FORM_SINGLETON_SET;
- } else if (THIS.equals(value)) {
- return THIS_SINGLETON_SET;
- } else if (REGION.equals(value)) {
- return REGION_SINGLETON_SET;
- } else if (NONE.equals(value)) {
- return NONE_SINGLETON_SET;
- } else {
- throw new FacesException(value + " : Invalid id keyword specified for '"
- + propertyName + "' attribute");
- }
- }
-
- return null;
- }
-
@Attribute
public Object getData() {
return getStateHelper().eval(PropertyKeys.data);
@@ -207,6 +167,15 @@
}
@Attribute
+ public String getOnbeforesubmit() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforesubmit);
+ }
+
+ public void setOnbeforesubmit(String onbeforesubmit) {
+ getStateHelper().put(PropertyKeys.onbeforesubmit, onbeforesubmit);
+ }
+
+ @Attribute
public String getOncomplete() {
return (String) getStateHelper().eval(PropertyKeys.oncomplete);
}
13 years, 11 months
JBoss Rich Faces SVN: r21100 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org: richfaces/tests/metamer/ftest/richJQuery and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-01-19 13:42:01 -0500 (Wed, 19 Jan 2011)
New Revision: 21100
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ColorRetriever.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java
Log:
fixed the jquery tests by introducing color conversion mechanism
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ColorRetriever.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ColorRetriever.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/jboss/cheiron/retriever/ColorRetriever.java 2011-01-19 18:42:01 UTC (rev 21100)
@@ -0,0 +1,109 @@
+/*
+ * 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.jboss.cheiron.retriever;
+
+import java.awt.Color;
+
+import org.apache.commons.lang.Validate;
+import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.test.selenium.encapsulated.JavaScript;
+import org.jboss.test.selenium.framework.AjaxSelenium;
+import org.jboss.test.selenium.framework.AjaxSeleniumProxy;
+import org.jboss.test.selenium.locator.ElementLocator;
+import org.jboss.test.selenium.utils.ColorUtils;
+import org.jboss.test.selenium.waiting.conversion.Convertor;
+import org.jboss.test.selenium.waiting.conversion.PassOnConvertor;
+import org.jboss.test.selenium.waiting.retrievers.AbstractRetriever;
+import org.jboss.test.selenium.waiting.retrievers.Retriever;
+
+import static org.jboss.test.selenium.utils.text.SimplifiedFormat.format;
+import static org.jboss.test.selenium.encapsulated.JavaScript.js;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ColorRetriever extends AbstractRetriever<Color> implements Retriever<Color> {
+
+ private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
+
+ private ElementLocator<?> elementLocator;
+
+ public ColorRetriever() {
+ }
+
+ public Color retrieve() {
+ Validate.notNull(elementLocator);
+
+ String value = selenium.getStyle(elementLocator, CssProperty.COLOR);
+ return ColorUtils.convertToAWTColor(value);
+ }
+
+ public JavaScript getJavaScriptRetrieve() {
+ final String colorPropertyName = CssProperty.COLOR.getPropertyName();
+ return js(format("selenium.getStyle('{0}', '{1}')", elementLocator.getAsString(), colorPropertyName));
+ }
+
+ public static ColorRetriever getInstance() {
+ return new ColorRetriever();
+ }
+
+ public ColorRetriever locator(ElementLocator<?> elementLocator) {
+ Validate.notNull(elementLocator);
+
+ ColorRetriever copy = copy();
+ copy.elementLocator = elementLocator;
+
+ return copy;
+ }
+
+ /**
+ * Returns a copy of this textRetriever with exactly same settings.
+ *
+ * Keeps the immutability of this class.
+ *
+ * @return the exact copy of this textRetriever
+ */
+ private ColorRetriever copy() {
+ ColorRetriever copy = new ColorRetriever();
+ copy.elementLocator = elementLocator;
+ return copy;
+ }
+
+ /**
+ * Uses {@link PassOnConvertor} to pass the JavaScript result to result value.
+ */
+ public Convertor<Color, String> getConvertor() {
+ return new ColorConvertor();
+ }
+
+ public static class ColorConvertor implements Convertor<Color, String> {
+ @Override
+ public String forwardConversion(Color object) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Color backwardConversion(String object) {
+ return ColorUtils.convertToAWTColor(object);
+ }
+ }
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java 2011-01-19 18:32:36 UTC (rev 21099)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richJQuery/TestSimple.java 2011-01-19 18:42:01 UTC (rev 21100)
@@ -26,9 +26,10 @@
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
import static org.testng.Assert.assertEquals;
+import java.awt.Color;
import java.net.URL;
-import org.jboss.test.selenium.css.CssProperty;
+import org.jboss.cheiron.retriever.ColorRetriever;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.testng.annotations.Test;
@@ -46,6 +47,8 @@
RichJQueryAttributes attributes = new RichJQueryAttributes();
+ ColorRetriever buttonColorRetriver = new ColorRetriever().locator(button);
+
@Override
public URL getTestUrl() {
return buildUrl(contextPath, "faces/components/richJQuery/simple.xhtml");
@@ -55,20 +58,21 @@
public void testDefaultTiming() {
setupDomReadyTypeAttributes();
attributes.setTiming(null);
- assertEquals("red", selenium.getStyle(button, CssProperty.COLOR));
+ assertEquals(buttonColorRetriver.retrieve(), Color.RED);
}
@Test
public void testTimingImmediate() {
setupImmediateTypeAttributes();
+ buttonColorRetriver.initializeValue();
selenium.click(button);
- waitGui.until(styleEquals.locator(button).property(CssProperty.COLOR).value("red"));
+ assertEquals(waitModel.waitForChangeAndReturn(buttonColorRetriver), Color.RED);
}
@Test
public void testTimingDomReady() {
setupDomReadyTypeAttributes();
- assertEquals("red", selenium.getStyle(button, CssProperty.COLOR));
+ assertEquals(buttonColorRetriver.retrieve(), Color.RED);
}
@Test
13 years, 11 months
JBoss Rich Faces SVN: r21099 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2011-01-19 13:32:36 -0500 (Wed, 19 Jan 2011)
New Revision: 21099
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
Log:
RF-10167
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2011-01-19 18:17:40 UTC (rev 21098)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputNumberSlider.js 2011-01-19 18:32:36 UTC (rev 21099)
@@ -84,6 +84,10 @@
this.setValue(this.value + this.step, event);
},
+ getValue: function () {
+ return this.value;
+ },
+
setValue: function (value, event) {
if (!this.disabled) {
this.__setValue(value, event);
13 years, 11 months
JBoss Rich Faces SVN: r21098 - in trunk/core/impl/src: test/java/org/richfaces/context and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-01-19 13:17:40 -0500 (Wed, 19 Jan 2011)
New Revision: 21098
Added:
trunk/core/impl/src/main/java/org/richfaces/context/ClientIdFunctionEvaluator.java
Removed:
trunk/core/impl/src/main/java/org/richfaces/context/ClientIdWalker.java
Modified:
trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolverNode.java
trunk/core/impl/src/main/java/org/richfaces/context/RowsFunctionContextCallback.java
trunk/core/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java
Log:
https://issues.jboss.org/browse/RF-10110
Copied: trunk/core/impl/src/main/java/org/richfaces/context/ClientIdFunctionEvaluator.java (from rev 21073, trunk/core/impl/src/main/java/org/richfaces/context/ClientIdWalker.java)
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ClientIdFunctionEvaluator.java (rev 0)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ClientIdFunctionEvaluator.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, 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 static org.richfaces.util.Util.NamingContainerDataHolder.SEPARATOR_CHAR_JOINER;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.context.IdParser.Node;
+
+import com.google.common.collect.Lists;
+
+class ClientIdFunctionEvaluator {
+
+ private FacesContext context;
+
+ private UIComponent functionTarget;
+
+ private Node[] parsedId;
+
+ private Collection<String> resolvedIds = Lists.newArrayListWithCapacity(1);
+
+ public ClientIdFunctionEvaluator(FacesContext context, Node[] parsedId) {
+ super();
+ this.context = context;
+ this.parsedId = parsedId;
+ }
+
+ private void walk(UIComponent component, String baseId, int nodeIdx) {
+
+ boolean isLastNode = (nodeIdx == parsedId.length - 1);
+
+ Node node = parsedId[nodeIdx];
+
+ Collection<String> directSubtreeIds;
+ UIComponent childComponent;
+
+ if (node.getFunction() == null) {
+ directSubtreeIds = Collections.singleton(node.getImage());
+ childComponent = component;
+ } else {
+ directSubtreeIds = evaluateFunction(component, baseId, node);
+ //functionTarget is set inside evaluateFunction(...) call!
+ childComponent = functionTarget;
+ }
+
+ for (String directSubtreeId : directSubtreeIds) {
+ String clientId = SEPARATOR_CHAR_JOINER.join(baseId, directSubtreeId);
+
+ if (isLastNode) {
+ resolvedIds.add(clientId);
+ } else {
+ walk(childComponent, clientId, nodeIdx + 1);
+ }
+ }
+ }
+
+ private Collection<String> evaluateFunction(UIComponent component, String baseId, Node node) {
+ Collection<String> directSubtreeIds;
+ String function = node.getFunction();
+ String image = node.getImage();
+
+ if (!"rows".equals(function)) {
+ throw new IllegalArgumentException(MessageFormat.format("Function {0} is not supported", function));
+ }
+
+ RowsFunctionContextCallback rowsFunctionCallback = new RowsFunctionContextCallback(image);
+
+ if (!component.invokeOnComponent(context, baseId, rowsFunctionCallback)) {
+ throw new IllegalStateException(MessageFormat.format("Failed to visit {0}", baseId));
+ }
+
+ functionTarget = rowsFunctionCallback.getComponent();
+ directSubtreeIds = rowsFunctionCallback.getConvertedKeys();
+ return directSubtreeIds;
+ }
+
+ public Collection<String> evaluate(UIComponent component) {
+ walk(component, null, 0);
+ return resolvedIds;
+ }
+}
\ No newline at end of file
Deleted: trunk/core/impl/src/main/java/org/richfaces/context/ClientIdWalker.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ClientIdWalker.java 2011-01-19 18:17:35 UTC (rev 21097)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ClientIdWalker.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, 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 static org.richfaces.util.Util.NamingContainerDataHolder.SEPARATOR_CHAR_JOINER;
-
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Collections;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.context.IdParser.Node;
-
-import com.google.common.collect.Lists;
-
-class ClientIdWalker {
-
- private Node[] parsedId;
-
- private UIComponent functionTarget;
-
- private Collection<String> resolvedIds = Lists.newArrayList();
-
- public ClientIdWalker(Node[] parsedId) {
- super();
- this.parsedId = parsedId;
- }
-
- private void walk(FacesContext facesContext, UIComponent component, String baseId, int nodeIdx) {
-
- boolean isLastNode = (nodeIdx == parsedId.length - 1);
-
- Node node = parsedId[nodeIdx];
-
- Collection<String> directSubtreeIds;
- UIComponent childComponent;
-
- if (node.getFunction() == null) {
- directSubtreeIds = Collections.singleton(node.getImage());
- childComponent = component;
- } else {
- directSubtreeIds = evaluateFunction(facesContext, component, baseId, node);
- //functionTarget is set inside evaluateFunction(...) call!
- childComponent = functionTarget;
- }
-
- for (String directSubtreeId : directSubtreeIds) {
- String clientId = SEPARATOR_CHAR_JOINER.join(baseId, directSubtreeId);
-
- if (isLastNode) {
- resolvedIds.add(clientId);
- } else {
- walk(facesContext, childComponent, clientId, nodeIdx + 1);
- }
- }
- }
-
- private Collection<String> evaluateFunction(FacesContext facesContext, UIComponent component, String baseId, Node node) {
- Collection<String> directSubtreeIds;
- String function = node.getFunction();
- String image = node.getImage();
-
- if (!"rows".equals(function)) {
- throw new IllegalArgumentException(MessageFormat.format("Function {0} is not supported", function));
- }
-
- RowsFunctionContextCallback rowsFunctionCallback = new RowsFunctionContextCallback(image);
-
- if (!component.invokeOnComponent(facesContext, baseId, rowsFunctionCallback)) {
- throw new IllegalStateException(MessageFormat.format("Failed to visit {0}", baseId));
- }
-
- functionTarget = rowsFunctionCallback.getComponent();
- directSubtreeIds = rowsFunctionCallback.getConvertedKeys();
- return directSubtreeIds;
- }
-
- public void walk(FacesContext facesContext) {
- walk(facesContext, facesContext.getViewRoot(), null, 0);
- }
-
- public Collection<String> getResolvedIds() {
- return resolvedIds;
- }
-}
\ No newline at end of file
Modified: trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2011-01-19 18:17:35 UTC (rev 21097)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolver.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -26,6 +26,7 @@
import static org.richfaces.util.Util.NamingContainerDataHolder.SEPARATOR_CHAR_JOINER;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -150,22 +151,41 @@
static void setMetaComponentSubstitutions(Map<String, String> substitutionsMap) {
metaComponentSubstitutions = substitutionsMap;
}
+
+ private boolean hasFunctionNodes(Node[] nodes) {
+ for (Node node : nodes) {
+ if (node.getFunction() != null) {
+ return true;
+ }
+ }
+
+ return false;
+ }
- private String computeClientId(FacesContext context,
+ private Collection<String> computeClientIds(FacesContext context,
UIComponent topMatchComponent, String id) {
- UIComponent container = findContainer(topMatchComponent.getParent());
-
- String containerClientId = null;
-
- if (container instanceof NamingContainer) {
- containerClientId = container.getContainerClientId(context);
+ String clientId;
+
+ int idx = id.indexOf(SEPARATOR_CHAR);
+ if (idx < 0) {
+ int metaSepIdx = id.indexOf(META_COMPONENT_SEPARATOR_CHAR);
+ if (metaSepIdx > 0) {
+ clientId = topMatchComponent.getClientId(facesContext) + id.substring(metaSepIdx);
+ } else {
+ clientId = topMatchComponent.getClientId(facesContext);
+ }
+ } else {
+ clientId = SEPARATOR_CHAR_JOINER.join(topMatchComponent.getClientId(facesContext), id.substring(idx + 1));
}
-
- if (containerClientId != null && containerClientId.length() != 0) {
- return SEPARATOR_CHAR_JOINER.join(containerClientId, id);
+
+ Node[] nodes = IdParser.parse(clientId);
+ if (hasFunctionNodes(nodes)) {
+ ClientIdFunctionEvaluator evaluator = new ClientIdFunctionEvaluator(context, nodes);
+
+ return evaluator.evaluate(topMatchComponent);
} else {
- return id;
+ return Collections.singleton(clientId);
}
}
@@ -335,8 +355,7 @@
}
resolvedIds.add(resolvedId);
} else {
- String computedId = computeClientId(facesContext, topMatch, fullId);
- resolvedIds.add(computedId);
+ resolvedIds.addAll(computeClientIds(facesContext, topMatch, fullId));
}
}
}
Modified: trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolverNode.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolverNode.java 2011-01-19 18:17:35 UTC (rev 21097)
+++ trunk/core/impl/src/main/java/org/richfaces/context/ComponentIdResolverNode.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -82,7 +82,7 @@
public void addFullId(String fullId) {
if (fullIds == null) {
- fullIds = new HashSet<String>();
+ fullIds = new HashSet<String>(2);
}
fullIds.add(fullId);
Modified: trunk/core/impl/src/main/java/org/richfaces/context/RowsFunctionContextCallback.java
===================================================================
--- trunk/core/impl/src/main/java/org/richfaces/context/RowsFunctionContextCallback.java 2011-01-19 18:17:35 UTC (rev 21097)
+++ trunk/core/impl/src/main/java/org/richfaces/context/RowsFunctionContextCallback.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -49,6 +49,10 @@
Collection<?> keys = (Collection<?>) context.getApplication().evaluateExpressionGet(context, "#{" + image + "}", Object.class);
+ if (keys == null) {
+ return;
+ }
+
for (Object key : keys) {
String convertedKey;
Modified: trunk/core/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java
===================================================================
--- trunk/core/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java 2011-01-19 18:17:35 UTC (rev 21097)
+++ trunk/core/impl/src/test/java/org/richfaces/context/ComponentIdResolverTest.java 2011-01-19 18:17:40 UTC (rev 21098)
@@ -23,6 +23,7 @@
import static org.junit.Assert.assertEquals;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -82,6 +83,8 @@
facesContext = FacesContext.getCurrentInstance();
viewRoot = facesContext.getViewRoot();
+ facesContext.getExternalContext().getRequestMap().put("one", Arrays.asList(1));
+
ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(facesContext, viewRoot.getViewId());
vdl.buildView(facesContext, viewRoot);
@@ -144,38 +147,38 @@
}
@Test
- public void testFindByWildcardId() throws Exception {
+ public void testFindByRowsId() throws Exception {
ComponentIdResolver resolver = createComponentIdResolver();
- resolver.addId("table:@rows(inputKeys):input");
+ resolver.addId("table:@rows(one):input");
resolver.resolve(evaluateComponentExpression("#{testBean.table}"));
Set<String> resolvedIds = resolver.getResolvedIds();
- assertEquals(asSet("form:table:@rows(inputKeys):input"), resolvedIds);
+ assertEquals(asSet("form:table:1:input"), resolvedIds);
}
@Test
public void testFindByMetaComponentId() throws Exception {
ComponentIdResolver resolver = createComponentIdResolver();
resolver.addId("input@text");
- resolver.addId("table:@rows(headerKeys):header@head");
- resolver.addId("table:@rows(footerKeys):header@footer");
+ resolver.addId("table:@rows(one):header@head");
+ resolver.addId("table:@rows(one):header@footer");
resolver.resolve(viewRoot);
Set<String> resolvedIds = resolver.getResolvedIds();
- assertEquals(asSet("form:table:@rows(footerKeys):header@footer", "form:table:@rows(headerKeys):header@head", "form:table:input@text"), resolvedIds);
+ assertEquals(asSet("form:table:1:header@footer", "form:table:1:header@head", "form:table:input@text"), resolvedIds);
}
@Test
public void testFindWithNoParentContainer() throws Exception {
ComponentIdResolver resolver = createComponentIdResolver();
- resolver.addId("form:table:[*]:column");
+ resolver.addId("form:table:@rows(one):column");
resolver.resolve(evaluateComponentExpression("#{testBean.table}"));
Set<String> resolvedIds = resolver.getResolvedIds();
- assertEquals(asSet("form:table:[*]:column"), resolvedIds);
+ assertEquals(asSet("form:table:1:column"), resolvedIds);
}
@Test
@@ -231,12 +234,12 @@
ComponentIdResolver resolver = createComponentIdResolver();
resolver.addId(":form:table:input");
resolver.addId(":form:table:column@head");
- resolver.addId(":form:table:[1]:column");
+ resolver.addId(":form:table:@rows(one):column");
resolver.resolve(viewRoot);
Set<String> resolvedIds = resolver.getResolvedIds();
- assertEquals(asSet("form:table:input", "form:table:column@head", "form:table:[1]:column"), resolvedIds);
+ assertEquals(asSet("form:table:input", "form:table:column@head", "form:table:1:column"), resolvedIds);
}
@Test
13 years, 11 months
JBoss Rich Faces SVN: r21097 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-01-19 13:17:35 -0500 (Wed, 19 Jan 2011)
New Revision: 21097
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java
Log:
rich:extendedDataTable - added issue tracking for RF-10256
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java 2011-01-19 17:56:38 UTC (rev 21096)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richExtendedDataTable/TestExtendedDataTableSelection.java 2011-01-19 18:17:35 UTC (rev 21097)
@@ -108,6 +108,7 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10256")
public void testMultiSelectionUsingShiftBetweenPagesInReversedOrder() {
IntRange range = new IntRange(12, 35);
@@ -139,6 +140,7 @@
}
@Test
+ @IssueTracking("https://issues.jboss.org/browse/RF-10256")
public void testMultiSelectionRemovingUsingCtrl() {
IntRange range1 = new IntRange(2, 14);
13 years, 11 months
JBoss Rich Faces SVN: r21096 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-01-19 12:56:38 -0500 (Wed, 19 Jan 2011)
New Revision: 21096
Added:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlAttributes.java
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java
Log:
rich:componentControl - fixed the test after added select for attributes selection
Added: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlAttributes.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlAttributes.java (rev 0)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlAttributes.java 2011-01-19 17:56:38 UTC (rev 21096)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.richComponentControl;
+
+import org.richfaces.tests.metamer.ftest.AbstractComponentAttributes;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class ComponentControlAttributes extends AbstractComponentAttributes {
+ public void setOperation(String operation) {
+ setProperty("operation", operation);
+ }
+
+ public void setSelector(String selector) {
+ setProperty("selector", selector);
+ }
+
+ public void setTarget(String target) {
+ setProperty("target", target);
+ }
+}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java 2011-01-19 17:55:59 UTC (rev 21095)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richComponentControl/ComponentControlDataScroller.java 2011-01-19 17:56:38 UTC (rev 21096)
@@ -21,14 +21,13 @@
*******************************************************************************/
package org.richfaces.tests.metamer.ftest.richComponentControl;
-import org.jboss.test.selenium.dom.Event;
+import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.guardXhr;
+import static org.jboss.test.selenium.locator.LocatorFactory.jq;
+import static org.testng.Assert.assertEquals;
+
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.model.AssertingDataScroller;
-import static org.jboss.test.selenium.locator.LocatorFactory.*;
-import static org.jboss.test.selenium.guard.request.RequestTypeGuardFactory.*;
-import static org.testng.Assert.*;
-
/**
* @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
* @version $Revision$
@@ -36,8 +35,9 @@
public class ComponentControlDataScroller extends AssertingDataScroller {
JQueryLocator button = jq(":submit[id$=button]");
- JQueryLocator selectOperation = jq(":radio[name$=operationInput][value={0}]");
+ ComponentControlAttributes attributes = new ComponentControlAttributes();
+
public ComponentControlDataScroller() {
super(jq("span.rf-ds[id$=scroller]"));
}
@@ -63,11 +63,7 @@
}
private void doOperation(String operation) {
- JQueryLocator locator = selectOperation.format(operation);
- if (!"on".equals(selenium.getValue(locator))) {
- selenium.check(locator);
- guardHttp(selenium).fireEvent(locator, Event.CHANGE);
- }
+ attributes.setOperation(operation);
guardXhr(selenium).click(button);
}
13 years, 11 months