JBoss Rich Faces SVN: r21145 - modules/tests/metamer/trunk/application.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-01-21 08:01:19 -0500 (Fri, 21 Jan 2011)
New Revision: 21145
Modified:
modules/tests/metamer/trunk/application/pom.xml
Log:
added validation-api and hibernate-validator as temporary workaround for RF-10271
Modified: modules/tests/metamer/trunk/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2011-01-21 13:00:57 UTC (rev 21144)
+++ modules/tests/metamer/trunk/application/pom.xml 2011-01-21 13:01:19 UTC (rev 21145)
@@ -67,6 +67,11 @@
<groupId>org.richfaces.cdk</groupId>
<artifactId>annotations</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </dependency>
<dependency>
<groupId>javax.servlet</groupId>
@@ -117,10 +122,11 @@
<version>3.12.1.GA</version>
</dependency>
- <!--
- <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId>
- <version>4.0.2.GA</version> <scope>provided</scope> </dependency>
- -->
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.1.0.Final</version>
+ </dependency>
</dependencies>
<build>
@@ -299,7 +305,7 @@
<artifactId>maven-war-plugin</artifactId>
<configuration>
<classifier>jee6</classifier>
- <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*,WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*</packagingExcludes>
+ <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*,WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*,WEB-INF/lib/validation-api-*,WEB-INF/lib/hibernate-validator-*</packagingExcludes>
</configuration>
<executions>
<execution>
@@ -330,7 +336,7 @@
</goals>
<configuration>
<classifier>jee6-bundled-mojarra</classifier>
- <packagingExcludes>WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*</packagingExcludes>
+ <packagingExcludes>WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*,WEB-INF/lib/validation-api-*,WEB-INF/lib/hibernate-validator-*</packagingExcludes>
</configuration>
</execution>
</executions>
@@ -354,7 +360,7 @@
</goals>
<configuration>
<classifier>jee6-bundled-myfaces</classifier>
- <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*</packagingExcludes>
+ <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*,WEB-INF/lib/validation-api-*,WEB-INF/lib/hibernate-validator-*</packagingExcludes>
</configuration>
</execution>
</executions>
@@ -551,6 +557,17 @@
<artifactId>jsf-impl</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.1.0.Final</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</profile>
</profiles>
13 years, 11 months
JBoss Rich Faces SVN: r21144 - modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2011-01-21 08:00:57 -0500 (Fri, 21 Jan 2011)
New Revision: 21144
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
Log:
PhaseInfo - the phases cache needs to be cleared once the request time changes
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-21 12:48:28 UTC (rev 21143)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-21 13:00:57 UTC (rev 21144)
@@ -83,6 +83,7 @@
private void initialize() {
if (retrieveRequestTime.isValueChanged()) {
+ map.clear();
retrieveRequestTime.initializeValue();
int count = selenium.getCount(phasesItems);
13 years, 11 months
JBoss Rich Faces SVN: r21143 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2011-01-21 07:48:28 -0500 (Fri, 21 Jan 2011)
New Revision: 21143
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
Log:
http://jira.jboss.com/jira/browse/RF-10117
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2011-01-21 12:08:56 UTC (rev 21142)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2011-01-21 12:48:28 UTC (rev 21143)
@@ -280,10 +280,10 @@
}
scrollToSelectedItem.call(this);
if (event &&
- event.which != rf.KEYS.BACKSPACE &&
- event.which != rf.KEYS.DEL &&
- event.which != rf.KEYS.LEFT &&
- event.which != rf.KEYS.RIGHT) {
+ event.keyCode != rf.KEYS.BACKSPACE &&
+ event.keyCode != rf.KEYS.DEL &&
+ event.keyCode != rf.KEYS.LEFT &&
+ event.keyCode != rf.KEYS.RIGHT) {
autoFill.call(this, this.value, getSelectedItemValue.call(this));
}
};
@@ -317,13 +317,13 @@
if (this.items.length!=0 && callback) {
callback.call(this, event);
}
- if (event.which == rf.KEYS.RETURN || event.type == "click") {
+ if (event.keyCode == rf.KEYS.RETURN || event.type == "click") {
this.__setInputValue(subValue);
} else if (this.options.selectFirst) {
selectItem.call(this, event, 0);
}
} else {
- if (event.which == rf.KEYS.RETURN || event.type == "click") {
+ if (event.keyCode == rf.KEYS.RETURN || event.type == "click") {
this.__setInputValue(subValue);
}
if (subValue.length>=this.options.minChars) {
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2011-01-21 12:08:56 UTC (rev 21142)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2011-01-21 12:48:28 UTC (rev 21143)
@@ -40,7 +40,7 @@
inputEventHandlers["focus"+this.namespace] = onFocus;
inputEventHandlers["blur"+this.namespace] = onBlur;
inputEventHandlers["click"+this.namespace] = onClick;
- inputEventHandlers[($.browser.opera ? "keypress" : "keydown")+this.namespace] = onKeyDown;
+ inputEventHandlers[($.browser.opera || $.browser.mozilla ? "keypress" : "keydown")+this.namespace] = onKeyDown;
inputEventHandlers["change"+this.namespace] = function (event) {if (this.focused) {event.stopPropagation()}};
rf.Event.bindById(this.fieldId, inputEventHandlers, this);
@@ -111,7 +111,7 @@
var flag = value != this.currentValue;
//TODO: is it needed to chesk keys?
//TODO: we need to set value when autoFill used when LEFT or RIGHT was pressed
- if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
+ if (event.keyCode == rf.KEYS.LEFT || event.keyCode == rf.KEYS.RIGHT || flag) {
if (flag) {
this.currentValue = this.getValue();
this.__onChangeValue(event, undefined, (!this.isVisible ? this.show : undefined));
@@ -131,7 +131,7 @@
};
var onKeyDown = function (event) {
- switch(event.which) {
+ switch(event.keyCode) {
case rf.KEYS.UP:
event.preventDefault();
if (this.isVisible) {
13 years, 11 months
JBoss Rich Faces SVN: r21142 - trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2011-01-21 07:08:56 -0500 (Fri, 21 Jan 2011)
New Revision: 21142
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
Log:
RF-9976: itemStyle and itemClass attributes were fixed
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java 2011-01-21 11:37:44 UTC (rev 21141)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/ToolbarGroupRenderer.java 2011-01-21 12:08:56 UTC (rev 21142)
@@ -72,26 +72,45 @@
writer.endElement(HtmlConstants.TD_ELEM);
}
+ /**
+ * If toolBarGroup has "style" defined than parent toolBar attribute "style" will be ignored.
+ * Otherwise toolBarGroup will inherit the value of the parent toolBar "style" attribute.
+ * @param toolbarGroup ToolBar Group to render
+ * @param writer just writer
+ * @throws IOException if something goes wrong with attribute writing
+ */
private void writeStyleValue(AbstractToolbarGroup toolbarGroup, ResponseWriter writer) throws IOException {
+ String value;
String style = getStringAttribute(toolbarGroup, HtmlConstants.STYLE_ATTRIBUTE);
- String itemStyle = getStringAttribute(getParentToolBar(toolbarGroup), "itemStyle");
- String value = concatStyles(itemStyle, style);
+ String toolbarStyle = getStringAttribute(getParentToolBar(toolbarGroup), "itemStyle");
+ String tooolbarGroupStyle = getStringAttribute(toolbarGroup, "itemStyle");
+ if (tooolbarGroupStyle != null && !tooolbarGroupStyle.equals("")) {
+ value = concatStyles(tooolbarGroupStyle, style);
+ } else {
+ value = concatStyles(toolbarStyle, style);
+ }
+
if (isPropertyRendered(value)) {
writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, value, null);
}
}
+ /**
+ * If toolBarGroup has "class" defined than parent toolBar attribute "class" will be ignored.
+ * Otherwise toolBarGroup will inherit the value of the parent toolBar "class" attribute.
+ * @param toolbarGroup ToolBar Group to render
+ * @param writer just writer
+ * @throws IOException if something goes wrong with attribute writing
+ */
private void writeClassValue(AbstractToolbarGroup toolbarGroup, ResponseWriter writer) throws IOException {
String styleClass = getStringAttribute(toolbarGroup, HtmlConstants.STYLE_CLASS_ATTR);
- AbstractToolbar toolbar = getParentToolBar(toolbarGroup);
- String itemClass = null;
-
- if(toolbar != null) {
- itemClass = getStringAttribute(toolbar, "itemClass");
- }
-
+
+ String toolbarClass = getStringAttribute(getParentToolBar(toolbarGroup), "itemClass");
+ String toolbarGroupClass = getStringAttribute(toolbarGroup, "itemClass");
+
+ String itemClass = (toolbarGroupClass != null && !toolbarGroupClass.equals("")) ? toolbarGroupClass : toolbarClass;
writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses("rf-tb-itm", itemClass, styleClass), null);
}
13 years, 11 months
JBoss Rich Faces SVN: r21141 - in modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest: a4jAjax and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2011-01-21 06:37:44 -0500 (Fri, 21 Jan 2011)
New Revision: 21141
Modified:
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAjax/TestHCommandButton.java
Log:
* fixed testImmediate and testBypassUpdates
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-21 10:23:44 UTC (rev 21140)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/PhaseInfo.java 2011-01-21 11:37:44 UTC (rev 21141)
@@ -1,6 +1,6 @@
/*******************************************************************************
* JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
+ * Copyright 2010-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.
*
@@ -46,10 +46,8 @@
public class PhaseInfo {
private AjaxSelenium selenium = AjaxSeleniumProxy.getInstance();
-
private TextRetriever retrieveRequestTime = RetrieverFactory.RETRIEVE_TEXT.locator(jq("span[id$=requestTime]"));
private JQueryLocator phasesItems = jq("div#phasesPanel li");
-
private Map<PhaseId, Set<String>> map = new LinkedHashMap<PhaseId, Set<String>>();
/**
@@ -90,7 +88,7 @@
int count = selenium.getCount(phasesItems);
Set<String> set;
- for (int i = 0; i < count; i++) {
+ for (int i = 1; i <= count; i++) {
String description = selenium.getText(phasesItems.getNthChildElement(i));
set = new LinkedHashSet<String>();
@@ -111,5 +109,4 @@
}
throw new IllegalStateException("no such phase '" + phaseIdentifier + "'");
}
-
}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAjax/TestHCommandButton.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAjax/TestHCommandButton.java 2011-01-21 10:23:44 UTC (rev 21140)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jAjax/TestHCommandButton.java 2011-01-21 11:37:44 UTC (rev 21141)
@@ -1,6 +1,6 @@
/*******************************************************************************
* JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc. and individual contributors
+ * Copyright 2010-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.
*
13 years, 11 months
JBoss Rich Faces SVN: r21140 - trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2011-01-21 05:23:44 -0500 (Fri, 21 Jan 2011)
New Revision: 21140
Modified:
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DropDownMenuRendererTest.java
trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
Log:
Activate ajaxClick test for MenuItem
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DropDownMenuRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DropDownMenuRendererTest.java 2011-01-21 10:07:25 UTC (rev 21139)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/DropDownMenuRendererTest.java 2011-01-21 10:23:44 UTC (rev 21140)
@@ -69,7 +69,7 @@
assertNotNull(item);
assertEquals("action", DropDownMenuBean.getCurrent());
}
- @Ignore
+
@Test
public void testAjaxClick() throws IOException, SAXException {
HtmlPage page = environment.getPage("/dropDownMenu_ajaxMode.jsf");
Modified: trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-21 10:07:25 UTC (rev 21139)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/renderkit/html/MenuItemRendererTest.java 2011-01-21 10:23:44 UTC (rev 21140)
@@ -71,7 +71,7 @@
doTest("menuItem_ajaxMode", "form:menuItem");
}
- @Ignore
+
@Test
public void testAjaxClick() throws IOException, SAXException {
HtmlPage page = environment.getPage("/menuItem_ajaxMode.jsf");
13 years, 11 months
JBoss Rich Faces SVN: r21139 - trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2011-01-21 05:07:25 -0500 (Fri, 21 Jan 2011)
New Revision: 21139
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
Log:
RF-9945 Taglib: toggleControl has no attributes
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2011-01-21 06:17:17 UTC (rev 21138)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2011-01-21 10:07:25 UTC (rev 21139)
@@ -29,10 +29,7 @@
import javax.faces.context.FacesContext;
import org.ajax4jsf.component.behavior.ClientBehavior;
-import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.JsfBehaviorRenderer;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
+import org.richfaces.cdk.annotations.*;
import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.renderkit.util.RendererUtils;
@@ -59,6 +56,7 @@
disableDefault
}
+ @Attribute
public String getEvent() {
return (String) getStateHelper().eval(PropertyKeys.event);
}
@@ -67,6 +65,7 @@
getStateHelper().eval(PropertyKeys.event, eventName);
}
+ @Attribute
public String getTargetItem() {
return (String) getStateHelper().eval(PropertyKeys.targetItem, AbstractTogglePanel.META_NAME_NEXT);
}
@@ -75,6 +74,7 @@
getStateHelper().put(PropertyKeys.targetItem, target);
}
+ @Attribute
public String getTargetPanel() {
return (String) getStateHelper().eval(PropertyKeys.targetPanel);
}
@@ -83,6 +83,7 @@
getStateHelper().put(PropertyKeys.targetPanel, selector);
}
+ @Attribute
public void setDisableDefault(Boolean disableDefault) {
getStateHelper().put(PropertyKeys.disableDefault, disableDefault);
}
13 years, 11 months
JBoss Rich Faces SVN: r21138 - modules/docs/trunk/Component_Reference/src/main/docbook/en-US.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2011-01-21 01:17:17 -0500 (Fri, 21 Jan 2011)
New Revision: 21138
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml
Log:
Fixed build errors
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2011-01-21 01:48:37 UTC (rev 21137)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2011-01-21 06:17:17 UTC (rev 21138)
@@ -140,7 +140,7 @@
</para>
</listitem>
</varlistentry>
- </variablelistentry>
+ </variablelist>
<para>
Use the <varname>mode</varname> attribute to determine how the menu requests are submitted:
</para>
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-21 01:48:37 UTC (rev 21137)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Tables_and_grids.xml 2011-01-21 06:17:17 UTC (rev 21138)
@@ -626,7 +626,7 @@
</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>
+ <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>
13 years, 11 months
JBoss Rich Faces SVN: r21137 - 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 20:48:37 -0500 (Thu, 20 Jan 2011)
New Revision: 21137
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenu-richpanelMenu.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuGroup-Using_custom_icons.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuItem-Using_custom_icons.xml_sample
Log:
Revised panelmenu based on review
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2011-01-21 00:29:53 UTC (rev 21136)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Menus_and_toolbars.xml 2011-01-21 01:48:37 UTC (rev 21137)
@@ -454,38 +454,100 @@
<section id="sect-Component_Reference-richpanelMenu-Interactivity_options">
<title>Interactivity options</title>
<para>
- The <varname>selectedChild</varname> attribute is used to point to the name of the currently selected menu item.
+ The <varname>activeItem</varname> attribute is used to point to the name of the currently selected menu item.
</para>
<para>
- By default, the event to expand the menu is a mouse click. Set the <varname>event</varname> attribute to specify a different event for expanding menus. Multiple levels of sub-menus can be expanded in one action. Set <code>expandSingle="true"</code> to only expand one sub-menu at a time.
+ By default, the event to expand the menu is a mouse click. Set the <varname>expandEvent</varname> attribute to specify a different event to expand menus. Multiple levels of sub-menus can be expanded in one action. Set <code>expandSingle="true"</code> to only expand one sub-menu at a time.
</para>
+ <para>
+ Similarly, the default event to collapse the menu is a mouse click. Set the <varname>collapseEvent</varname> attribute to specify a different event to collapse menus.
+ </para>
+ <para>
+ As with other control components, set <code>disabled="true"</code> to disable the <sgmltag><rich:panelMenu></sgmltag> comonent. Child menu components can be disabled in the same way.
+ </para>
</section>
<section id="sect-Component_Reference-richpanelMenu-Appearance">
<title>Appearance</title>
<para>
- Icons for the panel menu can be chosen from a set of standard icons. There are several attributes that relate to the different menu states that the icon represents for different menu levels:
+ Icons for the panel menu can be chosen from a set of standard icons. Icons can be set for the top panel menu, child panel menus, and child item. There are three different menu states that the icon represents, as well as icons for both the left and right side of the item title:
</para>
<variablelist>
- <varlistentry>
- <term><varname>iconExpandedTopGroup</varname>, <varname>iconCollapsedTopGroup</varname>, and <varname>iconDisabledTopGroup</varname></term>
- <listitem>
- <para>
- These attributes determine the icons for the top level menu. They relate to an expanded menu group, a collapsed menu group, and a disabled menu item respectively.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><varname>iconExpandedGroup</varname>, <varname>iconCollapsedGroup</varname>, and <varname>iconDisabledGroup</varname></term>
- <listitem>
- <para>
- These attributes determine the icons for sub-menus that are not the top-level menu. They relate to an expanded menu group, a collapsed menu group, and a disabled menu item respectively.
- </para>
- </listitem>
- </varlistentry>
+ <varlistentry>
+ <term><varname>topExpandedIconLeft</varname></term>
+ <term><varname>topExpandedIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for the top level menu when it is expanded.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>topCollapsedIconLeft</varname></term>
+ <term><varname>topCollapsedIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for the top level menu when it is collapsed.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>topDisabledIconLeft</varname></term>
+ <term><varname>topDisabledIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for the top level menu when it is disabled.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>groupExpandedIconLeft</varname></term>
+ <term><varname>groupExpandedIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for sub-menus that are not the top-level menu when they are expanded.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>groupCollapsedIconLeft</varname></term>
+ <term><varname>groupCollapsedIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for sub-menus that are not the top-level menu when they are collapsed.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>groupDisabledIconLeft</varname></term>
+ <term><varname>groupDisabledIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for sub-menus that are not the top-level menu when they are disabled.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>itemIconLeft</varname></term>
+ <term><varname>itemIconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for items in the menus.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>itemIconDisabledLeft</varname></term>
+ <term><varname>itemIconDisabledRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for items in the menus when they are disabled.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
<para>
- <xref linkend="exam-Component_Reference-richpanelMenu-richpanelMenu" /> demonstrates the use of icon declaration at the panel menu level. The standard icons are shown in <xref linkend="figu-Component_Reference-richpanelMenu-Standard_icons" />.
+ <xref linkend="exam-Component_Reference-richpanelMenu-richpanelMenu" /> demonstrates the use of icon declaration at the panel menu level. The standard icons are shown in <xref linkend="figu-Component_Reference-richpanelMenu-Standard_icons" />.
</para>
<figure id="figu-Component_Reference-richpanelMenu-Standard_icons">
<title><sgmltag><Standard icons></sgmltag></title>
@@ -499,14 +561,14 @@
Alternatively, point the icon attributes to the paths of image files. The image files are then used as icons.
</para>
<para>
- Any icons specified by child <sgmltag><rich:panelMenuGroup></sgmltag> and <sgmltag><rich:panelMenuItem></sgmltag> components overwrite the icons declared with the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ Any icons specified by child <sgmltag><rich:panelMenuGroup></sgmltag> and <sgmltag><rich:panelMenuItem></sgmltag> components overwrite the relevant icons declared with the parent <sgmltag><rich:panelMenu></sgmltag> component.
</para>
</section>
<section id="sect-Component_Reference-richpanelMenu-Submission_modes">
<title>Submission modes</title>
<para>
- The <varname>mode</varname> attribute defines the submission mode for normal menu items that link to content, and the <varname>expandMode</varname> attribute defines the submission mode for menu items that expand and collapse. The settings for these attributes apply to the entire menu unless a menu item defines its own individual <varname>mode</varname> or <varname>expandMode</varname>. The possible values for <varname>mode</varname> and <varname>expandMode</varname> are as follows:
+ The <varname>itemMode</varname> attribute defines the submission mode for normal menu items that link to content, and the <varname>groupMode</varname> attribute defines the submission mode for menu items that expand and collapse. The settings for these attributes apply to the entire menu unless a menu item defines its own individual <varname>itemMode</varname> or <varname>groupMode</varname>. The possible values for <varname>itemMode</varname> and <varname>groupMode</varname> are as follows:
</para>
<itemizedlist>
<listitem>
@@ -566,17 +628,49 @@
</para>
<section id="sect-Component_Reference-richpanelMenuGroup-Basic_usage">
- <title>Basic usage</title>
- <para>
- The <sgmltag><rich:panelMenuGroup></sgmltag> component needs the <varname>label</varname> attribute declared, which specifies the text to show for the menu entry. Additionally, the <sgmltag><rich:panelMenuGroup></sgmltag> component at least one <sgmltag><rich:panelMenuGroup></sgmltag> or <sgmltag><rich:panelMenuItem></sgmltag> components as child elements.
- </para>
+ <title>Basic usage</title>
+ <para>
+ The <sgmltag><rich:panelMenuGroup></sgmltag> component needs the <varname>label</varname> attribute declared, which specifies the text to show for the menu entry. Additionally, the <sgmltag><rich:panelMenuGroup></sgmltag> component at least one <sgmltag><rich:panelMenuGroup></sgmltag> or <sgmltag><rich:panelMenuItem></sgmltag> components as child elements.
+ </para>
</section>
<section id="sect-Component_Reference-richpanelMenuGroup-Appearance">
<title>Appearance</title>
<para>
- Icons for the menu group can be chosen from a set of standard icons. There are three attributes that relate to the different menu states that the icon represents: <varname>iconExpanded</varname>, <varname>iconCollapsed</varname>, and <varname>iconDisabled</varname>. The standard icons are shown in <xref linkend="figu-Component_Reference-richpanelMenuGroup-Standard_icons" />.
+ Icons for the menu group can be chosen from a set of standard icons. There are three different menu states that the icon represents, as well as icons for both the left and right side of the item title:
</para>
+ <variablelist>
+ <varlistentry>
+ <term><varname>iconLeftExpanded</varname></term>
+ <term><varname>iconRightExpanded</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for a menu group when it is expanded. If unspecified, the menu group uses the <varname>groupExpandedIconLeft</varname> and <varname>groupExpandedIconRight</varname> parameters defined in the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>iconLeftCollapsed</varname></term>
+ <term><varname>iconRightCollapsed</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for a menu group menu when it is collapsed. If unspecified, the menu group uses the <varname>groupCollapsedIconLeft</varname> and <varname>groupCollapsedIconRight</varname> parameters defined in the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>iconLeftDisabled</varname></term>
+ <term><varname>iconRightDisabled</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for a menu group menu when it is disabled. If unspecified, the menu group uses the <varname>groupDisabledIconLeft</varname> and <varname>groupDisabledIconRight</varname> parameters defined in the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>
+ The standard icons are shown in <xref linkend="figu-Component_Reference-richpanelMenuGroup-Standard_icons" />.
+ </para>
<figure id="figu-Component_Reference-richpanelMenuGroup-Standard_icons">
<title><sgmltag><Standard icons></sgmltag></title>
<mediaobject>
@@ -592,15 +686,12 @@
<title>Using custom icons</title>
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richpanelMenuGroup-Using_custom_icons.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
- <para>
- Any icons specified by child <sgmltag><rich:panelMenuGroup></sgmltag> and <sgmltag><rich:panelMenuItem></sgmltag> components overwrite the icons declared with the parent <sgmltag><rich:panelMenu></sgmltag> component.
- </para>
</section>
<section id="sect-Component_Reference-richpanelMenuGroup-Submission_modes">
<title>Submission modes</title>
<para>
- If the <varname>expandMode</varname> is unspecified, the submission behavior for the group is inherited from the parent <sgmltag><rich:panelMenu></sgmltag>. Otherwise, the <varname>expandMode</varname> setting is used instead of the parent's behavior.
+ If the <varname>mode</varname> attribute is unspecified, the submission behavior for the group is inherited from the parent <sgmltag><rich:panelMenu></sgmltag>. Otherwise, the <varname>mode</varname> setting is used instead of the parent's behavior. Refer to <xref linkend="sect-Component_Reference-richpanelMenu-Submission_modes" /> for submission mode settings.
</para>
</section>
@@ -644,17 +735,39 @@
</para>
<section id="sect-Component_Reference-richpanelMenuItem-Basic_usage">
- <title>Basic usage</title>
- <para>
- The <sgmltag><rich:panelMenuItem></sgmltag> component needs the <varname>label</varname> attribute declared, which specifies the text to show for the menu entry.
- </para>
+ <title>Basic usage</title>
+ <para>
+ The <sgmltag><rich:panelMenuItem></sgmltag> component needs the <varname>label</varname> attribute declared, which specifies the text to show for the menu entry.
+ </para>
</section>
<section id="sect-Component_Reference-richpanelMenuItem-Appearance">
<title>Appearance</title>
<para>
- Icons for menu items can be chosen from a set of standard icons. There are two attributes that relate to the different menu states that the icon represents: <varname>icon</varname> and <varname>iconDisabled</varname>. The standard icons are shown in <xref linkend="figu-Component_Reference-Basic_column_example-Basic_column_example" />.
+ Icons for menu items can be chosen from a set of standard icons. There are two different menu states that the icon represents, as well as icons for both the left and right side of the item title:
</para>
+ <variablelist>
+ <varlistentry>
+ <term><varname>iconLeft</varname></term>
+ <term><varname>iconRight</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for a menu item. If unspecified, the menu group uses the <varname>itemIconLeft</varname> and <varname>itemIconRight</varname> parameters defined in the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>iconLeftDisabled</varname></term>
+ <term><varname>iconRightDisabled</varname></term>
+ <listitem>
+ <para>
+ These attributes determine the icons for a menu item when it is disabled. If unspecified, the menu group uses the <varname>itemIconDisabledLeft</varname> and <varname>itemIconDisabledRight</varname> parameters defined in the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ <para>The standard icons are shown in <xref linkend="figu-Component_Reference-Basic_column_example-Basic_column_example" />.
+ </para>
<figure id="figu-Component_Reference-richpanelMenuItem-Standard_icons">
<title>Standard icons</title>
<mediaobject>
@@ -670,9 +783,9 @@
<title>Using custom icons</title>
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richpanelMenuItem-Using_custom_icons.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
- <para>
- Any icons specified by child <sgmltag><rich:panelMenuGroup></sgmltag> and <sgmltag><rich:panelMenuItem></sgmltag> components overwrite the icons declared with the parent <sgmltag><rich:panelMenu></sgmltag> component.
- </para>
+ <para>
+ Any icons specified by child <sgmltag><rich:panelMenuGroup></sgmltag> and <sgmltag><rich:panelMenuItem></sgmltag> components overwrite the icons declared with the parent <sgmltag><rich:panelMenu></sgmltag> component.
+ </para>
</section>
<section id="sect-Component_Reference-richpanelMenuItem-Submission_modes">
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenu-richpanelMenu.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenu-richpanelMenu.xml_sample 2011-01-21 00:29:53 UTC (rev 21136)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenu-richpanelMenu.xml_sample 2011-01-21 01:48:37 UTC (rev 21137)
@@ -1,8 +1,8 @@
-<rich:panelMenu mode="ajax" iconGroupTopPosition="right"
- iconExpandedTopGroup="chevronUp"
- iconCollapsedTopGroup="chevronDown"
- iconExpandedGroup="disc"
- iconCollapsedGroup="disc">
+<rich:panelMenu mode="ajax"
+ topExpandedIconRight="chevronUp"
+ topCollapsedIconRight="chevronDown"
+ groupExpandedIconLeft="disc"
+ groupCollapsedIconLeft="disc">
<rich:panelMenuGroup label="Group 1">
<rich:panelMenuItem label="Item 1.1"/>
<rich:panelMenuItem label="Item 1.2"/>
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuGroup-Using_custom_icons.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuGroup-Using_custom_icons.xml_sample 2011-01-21 00:29:53 UTC (rev 21136)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuGroup-Using_custom_icons.xml_sample 2011-01-21 01:48:37 UTC (rev 21137)
@@ -1,5 +1,5 @@
<rich:panelMenu>
- <rich:PanelMenuGroup label="Group 1" iconExpanded="\images\img1.png" iconCollapsed="\images\img2.png">
+ <rich:PanelMenuGroup label="Group 1" iconLeftExpanded="\images\img1.png" iconLeftCollapsed="\images\img2.png">
<!-- Nested menu components -->
</rich:panelMenuGroup>
</rich:panelMenu>
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuItem-Using_custom_icons.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuItem-Using_custom_icons.xml_sample 2011-01-21 00:29:53 UTC (rev 21136)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richpanelMenuItem-Using_custom_icons.xml_sample 2011-01-21 01:48:37 UTC (rev 21137)
@@ -1,5 +1,5 @@
<rich:panelMenu>
...
- <rich:panelMenuItem value="Item 1.1" icon="\images\img1.png" iconDisabled="\images\img2.png" />
+ <rich:panelMenuItem value="Item 1.1" iconLeft="\images\img1.png" iconLeftDisabled="\images\img2.png" />
...
</rich:panelMenu>
13 years, 11 months
JBoss Rich Faces SVN: r21136 - in trunk: core/api/src/main/java/org/ajax4jsf/javascript and 11 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2011-01-20 19:29:53 -0500 (Thu, 20 Jan 2011)
New Revision: 21136
Added:
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-message.js
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java
Modified:
trunk/
trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
trunk/examples/validator-demo/pom.xml
trunk/ui/validator/api/src/main/java/org/richfaces/javascript/Message.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml
trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties
trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/message.library.properties
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
Log:
Merged revisions 20994,21013,21036,21041,21067,21102,21134 via svnmerge from
https://svn.jboss.org/repos/richfaces/branches/RF-9797
.......
r20994 | pyaschenko | 2011-01-13 07:49:52 -0800 (Thu, 13 Jan 2011) | 1 line
RF-9797
.......
r21013 | alexsmirnov | 2011-01-13 17:03:54 -0800 (Thu, 13 Jan 2011) | 2 lines
CODING IN PROGRESS - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
.......
r21036 | pyaschenko | 2011-01-14 09:23:26 -0800 (Fri, 14 Jan 2011) | 5 lines
RF-9797
validators and converter hash script rendering were added
validators and converters were moved to RichFaces.csv container
bugfix
.......
r21041 | alexsmirnov | 2011-01-14 16:56:14 -0800 (Fri, 14 Jan 2011) | 2 lines
CODING IN PROGRESS - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
.......
r21067 | alexsmirnov | 2011-01-18 23:55:42 -0800 (Tue, 18 Jan 2011) | 3 lines
CODING IN PROGRESS - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
Length validator working.
.......
r21102 | alexsmirnov | 2011-01-19 15:20:06 -0800 (Wed, 19 Jan 2011) | 2 lines
CODING IN PROGRESS - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
.......
r21134 | alexsmirnov | 2011-01-20 15:41:01 -0800 (Thu, 20 Jan 2011) | 2 lines
RESOLVED - issue RF-9797: CSV: make client code compatible with the current wiki document
https://issues.jboss.org/browse/RF-9797
.......
Property changes on: trunk
___________________________________________________________________
Name: svnmerge-integrated
- /branches/RF-7817:1-19154 /branches/RF-8742:1-19867 /branches/RF-9309:1-19112,19378 /branches/RF-9323:1-20621 /branches/RF-9797:1-20979
+ /branches/RF-7817:1-19154 /branches/RF-8742:1-19867 /branches/RF-9309:1-19112,19378 /branches/RF-9323:1-20621 /branches/RF-9797:1-21135
Modified: trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/core/api/src/main/java/org/ajax4jsf/javascript/JSFunctionDefinition.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -79,9 +79,14 @@
first = false;
}
- target.append("){").append(body).append("}");
+ target.append("){");appendBody(target);
+ target.append("}");
}
+ protected void appendBody(Appendable target) throws IOException {
+ target.append(body);
+ }
+
/**
* @return the name
*/
Modified: trunk/examples/validator-demo/pom.xml
===================================================================
--- trunk/examples/validator-demo/pom.xml 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/examples/validator-demo/pom.xml 2011-01-21 00:29:53 UTC (rev 21136)
@@ -60,5 +60,20 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ <version>4.0.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.5.11</version>
+ </dependency>
</dependencies>
</project>
Modified: trunk/ui/validator/api/src/main/java/org/richfaces/javascript/Message.java
===================================================================
--- trunk/ui/validator/api/src/main/java/org/richfaces/javascript/Message.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/api/src/main/java/org/richfaces/javascript/Message.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -43,5 +43,51 @@
public String getSummary() {
return summary;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((this.detail == null) ? 0 : this.detail.hashCode());
+ result = prime * result + this.severity;
+ result = prime * result + ((this.summary == null) ? 0 : this.summary.hashCode());
+ return result;
+ }
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Message other = (Message) obj;
+ if (this.detail == null) {
+ if (other.detail != null) {
+ return false;
+ }
+ } else if (!this.detail.equals(other.detail)) {
+ return false;
+ }
+ if (this.severity != other.severity) {
+ return false;
+ }
+ if (this.summary == null) {
+ if (other.summary != null) {
+ return false;
+ }
+ } else if (!this.summary.equals(other.summary)) {
+ return false;
+ }
+ return true;
+ }
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/AjaxOnlyScript.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1,32 +1,30 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
import java.util.Collections;
import org.richfaces.resource.ResourceKey;
public class AjaxOnlyScript extends ValidatorScriptBase {
+ public static final Iterable<ResourceKey> AJAX_LIBRARIES = Collections.singleton(ResourceKey.create("ajax.reslib",
+ "org.richfaces"));
- public static final Iterable<ResourceKey> AJAX_LIBRARIES=Collections.singleton(ResourceKey.create("ajax.reslib", "org.richfaces"));
-
private final String ajaxScript;
public AjaxOnlyScript(String ajaxScript) {
super();
this.ajaxScript = ajaxScript;
-
+
}
public Iterable<ResourceKey> getResources() {
return AJAX_LIBRARIES;
}
- @Override
- protected Object buildBody() {
- return ajaxScript;
- }
-
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
@Override
@@ -37,7 +35,9 @@
return result;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -61,5 +61,12 @@
}
return true;
}
-
+
+ @Override
+ protected void appendBody(Appendable target) throws IOException {
+ target.append("if(!").append(DISABLE_AJAX).append("){(");
+ appendAjaxFunction(target, ajaxScript);
+ target.append(").call(").append(ELEMENT).append(",").append(EVENT).append(",").append(CLIENT_ID).append(");");
+ target.append(("}"));
+ }
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientAndAjaxScript.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1,8 +1,8 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
import java.util.Collection;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.resource.ResourceKey;
import com.google.common.collect.Iterables;
@@ -12,26 +12,27 @@
- final String ajaxScript;
+ private final String ajaxScript;
+ private final Iterable<ResourceKey> resources;
- public ClientAndAjaxScript(ScriptWithDependencies clientSideConverterScript,
- Collection<? extends ScriptWithDependencies> validatorScripts, String ajaxScript) {
+ public ClientAndAjaxScript(LibraryScriptFunction clientSideConverterScript,
+ Collection<? extends LibraryScriptFunction> validatorScripts, String ajaxScript) {
super(clientSideConverterScript,validatorScripts);
this.ajaxScript = ajaxScript;
+ resources = Iterables.concat(AjaxOnlyScript.AJAX_LIBRARIES,super.getResources());
}
@Override
public Iterable<ResourceKey> getResources() {
- return Iterables.concat(AjaxOnlyScript.AJAX_LIBRARIES,super.getResources());
+ return resources;
}
- protected void finishValidation(StringBuilder body) {
- // AJAX callback
- body.append("if(!").append(DISABLE_AJAX).append("){\n");
- body.append(ajaxScript).append(EOL).append("}\n");
+
+ @Override
+ protected void appendAjaxParameter(Appendable target) throws IOException {
+ appendAjaxParameter(target, ajaxScript);
}
-
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientOnlyScript.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1,76 +1,85 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
import java.util.Collection;
import java.util.LinkedHashSet;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
+import org.ajax4jsf.javascript.ScriptUtils;
import org.richfaces.resource.ResourceKey;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
+import com.google.common.collect.UnmodifiableIterator;
public class ClientOnlyScript extends ValidatorScriptBase {
- protected final ScriptWithDependencies converter;
- protected final Collection<? extends ScriptWithDependencies> validators;
+ private static final ResourceKey CSV_RESOURCE = ResourceKey.create("csv.reslib", "org.richfaces");
+ protected final LibraryScriptFunction converter;
+ protected final ImmutableList<? extends LibraryScriptFunction> validators;
+ private final ImmutableSet<ResourceKey> resources;
- public ClientOnlyScript(ScriptWithDependencies clientSideConverterScript,
- Collection<? extends ScriptWithDependencies> validatorScripts) {
+ public ClientOnlyScript(LibraryScriptFunction clientSideConverterScript,
+ Collection<? extends LibraryScriptFunction> validatorScripts) {
super();
- if(null==clientSideConverterScript){
- this.converter = NULL_CONVERTER_SCRIPT;
- } else {
- this.converter = clientSideConverterScript;
+ this.converter = clientSideConverterScript;
+ this.validators = ImmutableList.copyOf(validatorScripts);
+ LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
+ if (null != converter) {
+ Iterables.addAll(resources, converter.getResources());
}
- this.validators = validatorScripts;
-
+ for (LibraryScriptFunction scriptString : validators) {
+ Iterables.addAll(resources, scriptString.getResources());
+ }
+ resources.add(CSV_RESOURCE);
+ this.resources = ImmutableSet.copyOf(resources);
}
public Iterable<ResourceKey> getResources() {
- // TODO - make immutable.
- LinkedHashSet<ResourceKey> resources = Sets.newLinkedHashSet();
- Iterables.addAll(resources,converter.getResources());
- for (ScriptWithDependencies scriptString : validators) {
- Iterables.addAll(resources,scriptString.getResources());
- }
return resources;
}
@Override
- protected Object buildBody() {
- StringBuilder body = new StringBuilder();
- // Get component value by clientId.
- body.append("var ").append(ClientValidatorRenderer.VALUE_VAR).append("=");
- GET_VALUE_FUNCTION.appendScriptToStringBuilder(body);
- body.append(EOL);
- // Try client-side validation
- body.append("try {\n");
- // convert value
- body.append("var ").append(ClientValidatorRenderer.CONVERTED_VALUE_VAR).append("=");
- converter.appendScriptToStringBuilder(body);
- body.append(EOL);
- // call validators
- for (ScriptWithDependencies validatorScript : validators) {
- validatorScript.appendScriptToStringBuilder(body);
- body.append(EOL);
+ protected void appendParameters(Appendable target) throws IOException {
+ if (null != converter) {
+ target.append(CONVERTER).append(":");
+ appendConverter(target, converter);
+ target.append(",");
}
- finishValidation(body);
- body.append("return true;\n");
- // Catch errors
- body.append("} catch(e) {\n");
- SEND_ERROR_FUNCTION.appendScriptToStringBuilder(body);body.append(EOL);
- body.append("return false;\n}");
- return body;
+ target.append(VALIDATORS).append(":[");
+
+ UnmodifiableIterator<? extends LibraryScriptFunction> iterator = validators.iterator();
+ while (iterator.hasNext()) {
+ LibraryScriptFunction validatorScript = (LibraryScriptFunction) iterator.next();
+ appendValidator(target, validatorScript);
+ if (iterator.hasNext()) {
+ target.append(",");
+ }
+ }
+ target.append("]");
+ appendAjaxParameter(target);
}
- protected void finishValidation(StringBuilder body) {
- // clear messages after successful validation
- body.append("if(!").append(DISABLE_AJAX).append("){\n");
- CLEAR_ERROR_FUNCTION.appendScriptToStringBuilder(body);
- body.append(EOL).append("}\n");
+ protected void appendValidator(Appendable target, LibraryScriptFunction validatorScript) throws IOException {
+ appendConverter(target, validatorScript);
}
- /* (non-Javadoc)
+ protected void appendConverter(Appendable target, LibraryScriptFunction converter) throws IOException {
+ target.append('{').append("f").append(':').append(converter.getName()).append(',');
+ target.append(PARAMS).append(':');ScriptUtils.appendScript(target, converter.getParameters());
+ target.append(',');
+ target.append(MESSAGE).append(':');ScriptUtils.appendScript(target, converter.getMessage());
+ target.append('}');
+ }
+
+ protected void appendAjaxParameter(Appendable target) throws IOException {
+ // This is client-only validation script.
+ }
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
@Override
@@ -82,7 +91,9 @@
return result;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
@@ -114,5 +125,4 @@
return true;
}
-
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -19,7 +19,6 @@
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptUtils;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.richfaces.application.ServiceTracker;
import org.richfaces.component.behavior.ClientValidatorBehavior;
import org.richfaces.component.behavior.ConverterNotFoundException;
@@ -38,7 +37,6 @@
*/
public class ClientValidatorRenderer extends ClientBehaviorRenderer {
-
public static final String RENDERER_TYPE = "org.richfaces.ClientValidatorRenderer";
public static final String VALUE_VAR = "value";
@@ -80,48 +78,46 @@
throw new IllegalArgumentException(
"Instance of org.ruchvaces.component.behaviot.ClientValidatorBehavior required: " + behavior);
}
- ClientValidatorBehavior ajaxBehavior = (ClientValidatorBehavior)behavior;
+ ClientValidatorBehavior ajaxBehavior = (ClientValidatorBehavior) behavior;
// First things first - if AjaxBehavior is disabled, we are done.
if (!ajaxBehavior.isDisabled()) {
component.queueEvent(createEvent(component, ajaxBehavior));
- }
+ }
}
// Creates an AjaxBehaviorEvent for the specified component/behavior
- private static AjaxBehaviorEvent createEvent(UIComponent component,
- ClientValidatorBehavior ajaxBehavior) {
+ private static AjaxBehaviorEvent createEvent(UIComponent component, ClientValidatorBehavior ajaxBehavior) {
AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
- PhaseId phaseId = isImmediate(component, ajaxBehavior) ?
- PhaseId.APPLY_REQUEST_VALUES :
- PhaseId.PROCESS_VALIDATIONS;
+ PhaseId phaseId =
+ isImmediate(component, ajaxBehavior) ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.PROCESS_VALIDATIONS;
event.setPhaseId(phaseId);
return event;
}
-
- // Tests whether we should perform immediate processing. Note
+ // Tests whether we should perform immediate processing. Note
// that we "inherit" immediate from the parent if not specified
// on the behavior.
- private static boolean isImmediate(UIComponent component,
- ClientValidatorBehavior ajaxBehavior) {
+ private static boolean isImmediate(UIComponent component, ClientValidatorBehavior ajaxBehavior) {
boolean immediate = false;
if (ajaxBehavior.isImmediateSet()) {
immediate = ajaxBehavior.isImmediate();
} else if (component instanceof EditableValueHolder) {
- immediate = ((EditableValueHolder)component).isImmediate();
+ immediate = ((EditableValueHolder) component).isImmediate();
} else if (component instanceof ActionSource) {
- immediate = ((ActionSource)component).isImmediate();
+ immediate = ((ActionSource) component).isImmediate();
}
return immediate;
- } /**
+ }
+
+ /**
* <p class="changed_added_4_0">
* This method builds client-side validation script and stores it in View resource component
* </p>
@@ -136,14 +132,13 @@
FacesContext facesContext = behaviorContext.getFacesContext();
JavaScriptService javaScriptService = ServiceTracker.getService(JavaScriptService.class);
validatorScript = javaScriptService.addScript(facesContext, validatorScript);
- return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext),behaviorContext.getSourceId());
+ return validatorScript.createCallScript(behaviorContext.getComponent().getClientId(facesContext),
+ behaviorContext.getSourceId());
} else {
return null;
}
}
-
-
ComponentValidatorScript createValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior) {
ValidatorScriptBase validatorScript;
@@ -153,9 +148,10 @@
ConverterDescriptor converter = behavior.getConverter(behaviorContext);
if (null != converter) {
try {
- ScriptWithDependencies clientSideConverterScript =
+ LibraryScriptFunction clientSideConverterScript =
getClientSideConverterScript(behaviorContext.getFacesContext(), converter);
- validatorScript = createValidatorScript(behaviorContext, behavior, validators, clientSideConverterScript);
+ validatorScript =
+ createValidatorScript(behaviorContext, behavior, validators, clientSideConverterScript);
} catch (ScriptNotFoundException e) {
// ajax-only validation
validatorScript = new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
@@ -167,7 +163,7 @@
throw new FacesException(e);
}
String clientId = getComponentClientId(behaviorContext);
- String name = ScriptUtils.getValidJavascriptName(clientId+":v");
+ String name = ScriptUtils.getValidJavascriptName(clientId + ":v");
validatorScript.setName(name);
return validatorScript;
} else {
@@ -182,13 +178,14 @@
private ValidatorScriptBase createValidatorScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior, Collection<ValidatorDescriptor> validators,
- ScriptWithDependencies clientSideConverterScript) {
- Collection<? extends ScriptWithDependencies> validatorScripts = getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
+ LibraryScriptFunction clientSideConverterScript) {
+ Collection<? extends LibraryScriptFunction> validatorScripts =
+ getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
if (validatorScripts.isEmpty()) {
return new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
} else if (validatorScripts.size() < validators.size()) {
- return new ClientAndAjaxScript(clientSideConverterScript, validatorScripts,
- createAjaxScript(behaviorContext, behavior));
+ return new ClientAndAjaxScript(clientSideConverterScript, validatorScripts, createAjaxScript(
+ behaviorContext, behavior));
} else {
return new ClientOnlyScript(clientSideConverterScript, validatorScripts);
}
@@ -196,19 +193,19 @@
private String createAjaxScript(ClientBehaviorContext behaviorContext, ClientValidatorBehavior behavior) {
String ajaxScript = behavior.getAjaxScript(behaviorContext);
- ajaxScript=ajaxScript.replace("this", ValidatorScriptBase.ELEMENT);
String clientId = getComponentClientId(behaviorContext);
ajaxScript = replaceTextToVariable(ajaxScript, clientId, ValidatorScriptBase.CLIENT_ID);
String sourceId = behaviorContext.getSourceId();
- if(null != sourceId){
+ if (null != sourceId) {
+ // TODO - send sourceId as separate parameter.
ajaxScript = replaceTextToVariable(ajaxScript, sourceId, ValidatorScriptBase.ELEMENT);
}
return ajaxScript;
}
private String replaceTextToVariable(String ajaxScript, String clientId, String variableName) {
- ajaxScript=ajaxScript.replace("'"+clientId+"'",variableName);
- ajaxScript=ajaxScript.replace("\""+clientId+"\"",variableName);
+ ajaxScript = ajaxScript.replace("'" + clientId + "'", variableName);
+ ajaxScript = ajaxScript.replace("\"" + clientId + "\"", variableName);
return ajaxScript;
}
@@ -231,17 +228,16 @@
* @return
* @throws ScriptNotFoundException
*/
- ScriptWithDependencies getClientSideConverterScript(FacesContext facesContext,
- ConverterDescriptor converter) throws ScriptNotFoundException {
- ClientScriptService clientScriptService =
- ServiceTracker.getService(facesContext, ClientScriptService.class);
- return createClientFunction(facesContext, converter, VALUE_LITERAL, clientScriptService);
+ LibraryScriptFunction getClientSideConverterScript(FacesContext facesContext, ConverterDescriptor converter)
+ throws ScriptNotFoundException {
+ ClientScriptService clientScriptService = ServiceTracker.getService(facesContext, ClientScriptService.class);
+ return createClientFunction(facesContext, converter, clientScriptService);
}
- private ScriptWithDependencies createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
- JSReference variable, ClientScriptService clientScriptService) throws ScriptNotFoundException {
+ private LibraryScriptFunction createClientFunction(FacesContext facesContext, FacesObjectDescriptor descriptor,
+ ClientScriptService clientScriptService) throws ScriptNotFoundException {
LibraryFunction script = clientScriptService.getScript(facesContext, descriptor.getImplementationClass());
- return new LibraryScriptFunction(script, variable, descriptor.getMessage(), descriptor.getAdditionalParameters());
+ return new LibraryScriptFunction(script, descriptor.getMessage(), descriptor.getAdditionalParameters());
}
/**
@@ -254,14 +250,14 @@
* @return
* @throws ScriptNotFoundException
*/
- Collection<? extends ScriptWithDependencies> getClientSideValidatorScript(FacesContext facesContext,
+ Collection<? extends LibraryScriptFunction> getClientSideValidatorScript(FacesContext facesContext,
Collection<ValidatorDescriptor> validators) {
- ClientScriptService clientScriptService =
- ServiceTracker.getService(facesContext, ClientScriptService.class);
- List<ScriptWithDependencies> scripts = Lists.newArrayList();
+ ClientScriptService clientScriptService = ServiceTracker.getService(facesContext, ClientScriptService.class);
+ List<LibraryScriptFunction> scripts = Lists.newArrayList();
for (FacesObjectDescriptor validator : validators) {
try {
- scripts.add(createClientFunction(facesContext, validator, CONVERTED_VALUE_LITERAL, clientScriptService));
+ scripts
+ .add(createClientFunction(facesContext, validator, clientScriptService));
} catch (ScriptNotFoundException e) {
// Skip this validator for AJAX call.
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/LibraryScriptFunction.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -23,11 +23,15 @@
package org.richfaces.renderkit.html;
-import org.ajax4jsf.javascript.JSFunction;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
+import java.util.Map;
+
import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.Message;
import org.richfaces.resource.ResourceKey;
+import org.richfaces.resource.ResourceLibrary;
+import com.google.common.collect.ImmutableSet;
+
/**
* <p class="changed_added_4_0">
* This class represents call to function in external library.
@@ -36,14 +40,17 @@
* @author asmirnov(a)exadel.com
*
*/
-public class LibraryScriptFunction extends JSFunction implements ScriptWithDependencies {
+public class LibraryScriptFunction implements ResourceLibrary {
- private final Iterable<ResourceKey> resources;
+ private final ImmutableSet<ResourceKey> resources;
private final String name;
+ private final Message message;
+ private final Map<String, ? extends Object> parameters;
- public LibraryScriptFunction(LibraryFunction libraryScript, Object... parameters) {
- super(libraryScript.getName(), parameters);
- this.resources = libraryScript.getResources();
+ public LibraryScriptFunction(LibraryFunction libraryScript, Message message, Map<String, ? extends Object> parameters) {
+ this.message = message;
+ this.parameters = parameters;
+ this.resources = ImmutableSet.copyOf(libraryScript.getResources());
this.name = libraryScript.getName();
}
@@ -60,6 +67,26 @@
return resources;
}
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the message
+ */
+ public Message getMessage() {
+ return this.message;
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @return the parameters
+ */
+ public Map<String, ? extends Object> getParameters() {
+ return this.parameters;
+ }
+
/*
* (non-Javadoc)
*
@@ -69,9 +96,10 @@
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((resources == null) ? 0 : resources.hashCode());
- result = prime * result + getParameters().hashCode();
+ result = prime * result + ((this.message == null) ? 0 : this.message.hashCode());
+ result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
+ result = prime * result + ((this.parameters == null) ? 0 : this.parameters.hashCode());
+ result = prime * result + ((this.resources == null) ? 0 : this.resources.hashCode());
return result;
}
@@ -92,29 +120,35 @@
return false;
}
LibraryScriptFunction other = (LibraryScriptFunction) obj;
- if (name == null) {
+ if (this.message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!this.message.equals(other.message)) {
+ return false;
+ }
+ if (this.name == null) {
if (other.name != null) {
return false;
}
- } else if (!name.equals(other.name)) {
+ } else if (!this.name.equals(other.name)) {
return false;
}
- if (resources == null) {
+ if (this.parameters == null) {
+ if (other.parameters != null) {
+ return false;
+ }
+ } else if (!this.parameters.equals(other.parameters)) {
+ return false;
+ }
+ if (this.resources == null) {
if (other.resources != null) {
return false;
}
- } else if (!resources.equals(other.resources)) {
+ } else if (!this.resources.equals(other.resources)) {
return false;
- } else if (!getParameters().equals(other.getParameters())) {
- return false;
}
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
-
}
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ValidatorScriptBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -6,46 +6,80 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
-public abstract class ValidatorScriptBase extends JSFunctionDefinition implements ComponentValidatorScript {
+public abstract class ValidatorScriptBase extends JSFunctionDefinition implements ComponentValidatorScript {
- public static final String ELEMENT = "element";
- public static final JSReference ELEMENT_LITERAL = new JSReference(ELEMENT);
+ public static final String ELEMENT = "e";
+ public static final JSReference ELEMENT_REF = new JSReference(ELEMENT);
public static final String EVENT = "event";
- public static final JSReference EVENT_LITERAL = new JSReference(EVENT);
- public static final String DISABLE_AJAX = "disableAjax";
+ public static final JSReference EVENT_REF = new JSReference(EVENT);
+ public static final String DISABLE_AJAX = "da";
+ public static final JSReference DISABLE_AJAX_REF = new JSReference(DISABLE_AJAX);
public static final String EOL = ";\n";
- public static final String CLIENT_ID = "clientId";
- public static final JSReference CLIENT_ID_LITERAL = new JSReference(CLIENT_ID);
- public static final String SOURCE_ID = "sourceId";
- public static final JSReference SOURCE_ID_LITERAL = new JSReference(SOURCE_ID);
+ public static final String CLIENT_ID = "id";
+ public static final JSReference CLIENT_ID_REF = new JSReference(CLIENT_ID);
+ public static final String SOURCE_ID = "sid";
+ public static final JSReference SOURCE_ID_REF = new JSReference(SOURCE_ID);
+ public static final String CONVERTER = "c";
+ public static final JSReference CONVERTER_REF = new JSReference(CONVERTER);
+ public static final String VALIDATORS = "v";
+ public static final JSReference VALIDATORS_REF = new JSReference(VALIDATORS);
+ public static final String AJAX = "a";
+ public static final JSReference AJAX_REF = new JSReference(AJAX);
+ public static final String PARAMS = "p";
+ public static final JSReference PARAMS_REF = new JSReference(PARAMS);
+ public static final String MESSAGE = "m";
+ public static final JSReference MESSAGE_REF = new JSReference(MESSAGE);
+
public static final NullConverterScript NULL_CONVERTER_SCRIPT = new NullConverterScript();
public static final String CSV_NAMESPACE = "RichFaces.csv.";
- public static final String VALUE_FUNCTION_NAME = CSV_NAMESPACE+"getValue";
- public static final JSFunction GET_VALUE_FUNCTION = new JSFunction(VALUE_FUNCTION_NAME,CLIENT_ID_LITERAL,ELEMENT_LITERAL);
- public static final JSFunction SEND_ERROR_FUNCTION = new JSFunction(CSV_NAMESPACE+"sendMessage",CLIENT_ID_LITERAL,new JSReference("e"));
- public static final JSFunction CLEAR_ERROR_FUNCTION = new JSFunction(CSV_NAMESPACE+"clearMessage",CLIENT_ID_LITERAL);
-
- private boolean bodyProcessed = false;
+ public static final String VALUE_FUNCTION_NAME = CSV_NAMESPACE + "getValue";
+ public static final JSFunction GET_VALUE_FUNCTION = new JSFunction(VALUE_FUNCTION_NAME, CLIENT_ID_REF, ELEMENT_REF);
+ public static final String VALIDATE_FUNCTION_NAME = CSV_NAMESPACE + "validate";
+ public static final JSFunction VALIDATE_FUNCTION = new JSFunction(VALIDATE_FUNCTION_NAME, CLIENT_ID_REF,
+ ELEMENT_REF);
public ValidatorScriptBase() {
- super(CLIENT_ID,ELEMENT,EVENT,DISABLE_AJAX);
+ super(EVENT, CLIENT_ID, ELEMENT, DISABLE_AJAX);
}
- public void appendScript(Appendable target) throws IOException {
- if(!bodyProcessed){
- // pending RF-9565
- addToBody(buildBody());
- bodyProcessed = true;
- }
- super.appendScript(target);
+ public String createCallScript(String clientId, String sourceId) {
+ JSFunction callFunction =
+ new JSFunction(getName(), EVENT_REF, clientId, null != sourceId ? sourceId : JSReference.THIS);
+ return callFunction.toScript();
}
- protected abstract Object buildBody();
+ protected void appendParameters(Appendable target) throws IOException {
+ }
- public String createCallScript(String clientId,String sourceId) {
- JSFunction callFunction = new JSFunction(getName(),clientId,null!=sourceId?sourceId:JSReference.THIS,EVENT_LITERAL);
- return callFunction.toScript();
+ @Override
+ protected void appendBody(Appendable target) throws IOException {
+ appendParametersDefinition(target);
+ appendValidatorCall(target);
}
+ private void appendParametersDefinition(Appendable target) throws IOException {
+ target.append("var ").append(PARAMS).append("={");
+ target.append(DISABLE_AJAX).append(':').append(DISABLE_AJAX).append(',');
+ appendParameters(target);
+ target.append("}").append(EOL);
+ }
+ protected void appendValidatorCall(Appendable target) throws IOException {
+ JSFunction callValidator =
+ new JSFunction(VALIDATE_FUNCTION_NAME, EVENT_REF, CLIENT_ID_REF, ELEMENT_REF, PARAMS_REF);
+ callValidator.appendScript(target);
+ target.append(EOL);
+ }
+
+ protected void appendAjaxParameter(Appendable target, String ajaxScript) throws IOException {
+ target.append(AJAX).append(':');
+ appendAjaxFunction(target, ajaxScript);
+ }
+
+ protected void appendAjaxFunction(Appendable target, String ajaxScript) throws IOException {
+ JSFunctionDefinition ajaxFunction = new JSFunctionDefinition(EVENT, CLIENT_ID);
+ ajaxFunction.addToBody(ajaxScript);
+ ajaxFunction.appendScript(target);
+ }
+
}
\ No newline at end of file
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesServiceBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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: trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/validator/FacesValidatorServiceImpl.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -35,13 +35,47 @@
@Override
protected String getMessageId(Validator component) {
+ // 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() > Double.MIN_VALUE){
+ if(validator.getMinimum()> Double.MIN_VALUE){
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else {
+ messageId = DoubleRangeValidator.MAXIMUM_MESSAGE_ID;
+ }
+ } else if( validator.getMinimum()>Double.MIN_VALUE){
+ 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) {
- messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ LengthValidator validator = (LengthValidator) component;
+ if(validator.getMaximum() >0){
+ if(validator.getMinimum()>0){
+ messageId = DoubleRangeValidator.NOT_IN_RANGE_MESSAGE_ID;
+ } else {
+ messageId = LengthValidator.MAXIMUM_MESSAGE_ID;
+ }
+ } else if( validator.getMinimum()>0){
+ messageId = LengthValidator.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 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: trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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: trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-01-21 00:29:53 UTC (rev 21136)
@@ -6,8 +6,45 @@
var _validators = {};
var _converters = {};
- var RE_MESSAGE_PATTERN = /\{(\d+)\}/g;
+ var RE_MESSAGE_PATTERN = /\'?\{(\d+)\}\'?/g;
+ var __interpolateMessage = function (message, values) {
+ if (message) {
+ var msgObject = message.replace(RE_MESSAGE_PATTERN,"\n$1\n").split("\n");
+ var value;
+ for (var i=1; i<msgObject.length; i+=2) {
+ value = values[msgObject[i]];
+ msgObject[i] = typeof value == "undefined" ? "" : value;
+ }
+ return msgObject.join('');
+ } else {
+ return "";
+ }
+ }
+
+ var _interpolateFacesMessage = function(msg,id,value){
+ var d = msg.detail?_substitute(msg.detail,id,value):"";
+ var s = msg.summary?_substitute(msg.summary,id,value):"";
+ return {detail:d,summary:s};
+ }
+
+ var _substitute = function(msg,id,value){
+ return msg.replace("{id}",id).replace("{value}",value);
+ }
+
+ var __getValue = function(id) {
+ var value;
+ var element = rf.getDomElement(id);
+ if (element.value) {
+ value = element.value;
+ } else {
+ var component = rf.$(element);
+ // TODO: add getValue to baseComponent and change jsdocs
+ value = component && typeof component["getValue"] == "function" ? component.getValue() : "";
+ }
+ return value;
+ }
+
$.extend(rf.csv, {
RE_DIGITS: /^-?\d+$/,
RE_FLOAT: /^(-?\d+)?(\.(\d+)?(e[+-]?\d+)?)?$/,
@@ -16,73 +53,200 @@
$.extend(_messages, messagesObject);
},
getMessage: function(customMessage, messageId, values) {
- var message = customMessage || _messages[messageId] || "";
- if (message) {
- var msgObject = message.replace(RE_MESSAGE_PATTERN,"\n$1\n").split("\n");
- var value;
- for (var i=1; i<msgObject.length; i+=2) {
- value = values[msgObject[i]];
- msgObject[i] = typeof value == "undefined" ? "" : value;
- }
- message = msgObject.join('');
- }
- return {message:message};
+ var message = customMessage ? customMessage : _messages[messageId] || {detail:"",summary:""};
+ return {detail:__interpolateMessage(message.detail,values),summary:__interpolateMessage(message.summary,values)};
},
+ interpolateMessage: function(message,values){
+ return {detail:__interpolateMessage(message.detail,values),summary:__interpolateMessage(message.summary,values)};
+ },
sendMessage: function (componentId, message) {
rf.Event.fire(window.document, rf.Event.MESSAGE_EVENT_TYPE, {'sourceId':componentId, 'message':message});
},
- // Converters API
- addConverter: function (converterFunctions) {
- $.extend(_converters, converterFunctions);
- },
- getConverter: function (name) {
- return _converters[name];
- },
- // Validators API
- addValidator: function (validatorFunctions) {
- $.extend(_validators, validatorFunctions);
- },
- getValidator: function (name) {
- return _validators[name];
- },
- validate: function (event, id, converter, validators) {
- var value;
- var element = rf.getDomElement(id);
- if (element.value) {
- value = element.value;
- } else {
- var component = rf.$(element);
- // TODO: add getValue to baseComponent and change jsdocs
- value = component && typeof component["getValue"] == "function" ? component.getValue() : "";
- }
+ validate: function (event, id, element, params) {
+ var value = __getValue(element || id);
+ var convertedValue;
+ var converter = params.c;
if (converter) {
try {
- converter.options.componentId = id;
- value = getConverter([converter.name])(value, converter.options);
+ if (converter.f)
+ convertedValue = converter.f(value,id,converter.p,converter.m);
} catch (e){
- sendMessage(id, e.message);
+ rf.csv.sendMessage(id, e);
return false;
}
+ } else {
+ convertedValue = value;
}
+ var validators = params.v;
if (validators) {
var validatorFunction;
try {
for (i=0;i<validators.length;i++) {
- validatorFunction = getValidator(validators[i].type);
+ validatorFunction = validators[i].f;
if (validatorFunction) {
- validatorFunction(id, value, validators[i]);
+ validatorFunction(convertedValue,id, validators[i].p,validators[i].m);
}
}
} catch (e) {
- sendMessage(id, result);
+ rf.csv.sendMessage(id, e);
return false;
}
}
+ if(!params.da && params.a){
+ params.a.call(element,event,id);
+ } else {
+ rf.csv.sendMessage(id, "");
+ }
return true;
},
- addFormValidators: function (formId, callValidatorFunctions) {
+ /*
+ function form_3Atext_3Av(clientId,element,event,disableAjax){var value=RichFaces.csv.getValue(clientId,element);
+ try {
+ var convertedValue=value;
+ RichFaces.csv.validateLength(convertedValue,{"detail":"{2}: Validation Error: Specified attribute is not between the expected values of {0} and {1}.","severity":0,"summary":"{2}: Validation Error: Specified attribute is not between the expected values of {0} and {1}."} ,{"minimum":1,"maximum":3} );
+ if(!disableAjax){
+ RichFaces.csv.clearMessage(clientId);
+ }
+ return true;
+ } catch(e) {
+ RichFaces.csv.sendMessage(clientId,e);
+ return false;
+ }}
+ */
+ /*
+ * c: {name:, params:}
+ v: [{f:, customMessage:, [validator params]}]
+ function form_3Atext_3Av(id, el, e, c, v, p) {
+ RichFaces.csv.validate(e, id, el, c, v, p);
+ }
+ */
+ });
+
+ /*
+ * Converters implementation
+ */
+ $.extend(rf.csv, {
+ "convertBoolean": function (value,label,params,msg) {
+ var result; value = $.trim(value).toLowerCase();
+ result = value=='true' ? true : value.length<1 ? null : false;
+ return result;
+ },
+ "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.interpolateMessage(msg, [value, 254, label]);
+ }
+ return result;
+ },
+ "convertNumber": function (value,label,params,msg) {
+ var result; value=$.trim(value);
+ result = parseFloat(value);
+ if (isNaN(result)) {
+ throw rf.csv.interpolateMessage(msg, [value, 99, label]);
+ }
+ return result;
+ },
+ "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.interpolateMessage(msg, [value, 32456, 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
+ */
+ $.extend(rf.csv, {
+ "validateLongRange": function (value,label,params,msg) {
+ var type = typeof value;
+ if (type != "number") {
+ if (type != "string") {
+ throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_TYPE', [componentId, ""]);
+ } else {
+ value = $.trim(value);
+ if (!rf.csv.RE_DIGITS.test(value) || (value = parseInt(value, 10))==NaN) {
+ throw rf.csv.getMessage(msg, 'LONG_RANGE_VALIDATOR_TYPE', [componentId, ""]);
+ }
+ }
+ }
+
+ validateRange(value,label,params,msg);
+ },
+ "validateDoubleRange": function (value,label,params,msg) {
+ var type = typeof value;
+ if (type != "number") {
+ if (type != "string") {
+ throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_TYPE', [componentId, ""]);
+ } else {
+ value = $.trim(value);
+ if (!rf.csv.RE_FLOAT.test(value) || (value = parseFloat(value))==NaN) {
+ throw rf.csv.getMessage(msg, 'DOUBLE_RANGE_VALIDATOR_TYPE', [componentId, ""]);
+ }
+ }
+ }
+
+ validateRange(value,label,params,msg);
+ },
+ "validateLength": function (value,label,params,msg) {
+ 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) {
+ 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 ) {
+ 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;
+ }
+ }
+ });
+
})(jQuery, window.RichFaces || (window.RichFaces={}));
\ No newline at end of file
Copied: trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-message.js (from rev 20994, branches/RF-9797/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-message.js)
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-message.js (rev 0)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-message.js 2011-01-21 00:29:53 UTC (rev 21136)
@@ -0,0 +1,77 @@
+(function($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ // Constructor definition
+ rf.ui.Base = function(componentId, options, defaultOptions) {
+ this.namespace = "."+rf.Event.createNamespace(this.name, componentId);
+ // call constructor of parent class
+ $super.constructor.call(this, componentId);
+ this.options = $.extend(this.options, defaultOptions, options);
+ this.attachToDom();
+ this.__bindEventHandlers();
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.BaseComponent.extend(rf.ui.Base);
+
+ // define super class link
+ var $super = rf.ui.Base.$super;
+
+ $.extend(rf.ui.Base.prototype, {
+ __bindEventHandlers: function () {
+ },
+ destroy: function () {
+ rf.Event.unbindById(this.id, this.namespace);
+ $super.destroy.call(this);
+ }
+ });
+
+})(jQuery, window.RichFaces || (window.RichFaces={}));
+
+(function($, rf) {
+
+ // Constructor definition
+ rf.ui.Message = function(componentId, options) {
+ // call constructor of parent class
+ $super.constructor.call(this, componentId, options, defaultOptions);
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.ui.Base.extend(rf.ui.Message);
+
+ // define super class link
+ var $super = rf.ui.Message.$super;
+
+ var defaultOptions = {
+
+ };
+
+ var componentHash = {};
+ var componentIndex = 0;
+
+ var onMessage = function (event, element, data) {
+ if (!this.options.forComponentId) {
+ var index = componentHash[data.sourceId];
+ if (typeof index != undefined) {
+ $(rf.getDomElement(this.id+index)).remove();
+ }
+ var content = content = $(rf.getDomElement(this.id));
+
+ componentIndex ++;
+ if (data.message) content.append('<li id="'+this.id+componentIndex+'">'+data.message.summary+'</li>');
+ componentHash[data.sourceId] = componentIndex;
+
+ } else if (this.options.forComponentId==data.sourceId) {
+ rf.getDomElement(this.id).innerHTML = data.message ? '<li>'+data.message.summary+'</li>' : '';
+ }
+ }
+
+ $.extend(rf.ui.Message.prototype, {
+ name: "Message",
+ __bindEventHandlers: function () {
+ rf.Event.bind(window.document, rf.Event.MESSAGE_EVENT_TYPE+this.namespace, onMessage, this);
+ }
+ });
+
+})(jQuery, window.RichFaces || (window.RichFaces={}));
\ No newline at end of file
Modified: trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/csv.library.properties 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1 +1 @@
-resources=jquery.js, richfaces.js, richfaces-event.js, org.richfaces:csv.js
\ No newline at end of file
+resources=jquery.js, richfaces.js, richfaces-event.js, org.richfaces:richfaces-csv.js
\ No newline at end of file
Modified: trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/message.library.properties
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/message.library.properties 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/richfaces/org.richfaces/message.library.properties 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1 +1 @@
-resources=jquery.js, richfaces.js, richfaces-event.js, richfaces-base-component.js, org.richfaces:message.js
\ No newline at end of file
+resources=jquery.js, richfaces.js, richfaces-event.js, richfaces-base-component.js, org.richfaces:richfaces-message.js
\ No newline at end of file
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -1,9 +1,14 @@
package org.richfaces.javascript.client;
+import static org.easymock.EasyMock.*;
+
+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) {
@@ -87,12 +102,17 @@
}
protected static RunParameters pass(Object value, String option1, Object value1, String option2, Object value2) {
- RunParameters testCriteria = pass(value);
+ RunParameters testCriteria = pass(value,option1, value1);
Map<String, Object> options = testCriteria.getOptions();
- options.put(option1, value1);
options.put(option2, value2);
return testCriteria;
}
+ protected static RunParameters pass(Object value, String option1, Object value1, String option2, Object value2,String option3, Object value3) {
+ RunParameters testCriteria = pass(value,option1, value1,option2, value2);
+ Map<String, Object> options = testCriteria.getOptions();
+ options.put(option3, value3);
+ return testCriteria;
+ }
private static RunParameters[] optionsArray(RunParameters testCriteria) {
return new RunParameters[] { testCriteria };
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ByteConverterTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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"));
+ }
+}
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ConverterTestBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/NumberConverterTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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"));
+ }
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/converter/ShortConverterTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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"));
+ }
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/BeanValidatorTestBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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();
+ }
+
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/DoubleRangeValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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,IGNORE_MESSAGE,true),pass(2.0D,MINIMUM,2.0D),pass(3.0D,MINIMUM,2.0D),pass(-3.0D,MINIMUM,2.0D,IGNORE_MESSAGE,true),
+ pass(0.0D,MAXIMUM,2.0D),pass(2.0D,MAXIMUM,2.0D),pass(3.0D,MAXIMUM,2.0D,IGNORE_MESSAGE,true),pass(-3.0D,MAXIMUM,2.0D),
+ pass(0.0D,MINIMUM,3.0D,MAXIMUM,5.0D,IGNORE_MESSAGE,true),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,IGNORE_MESSAGE,true));
+ }
+}
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LengthValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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));
}
@@ -56,6 +56,6 @@
return options(pass(""),pass("aaa"),pass("123"),
pass("",MINIMUM,2),pass("vv",MINIMUM,2),pass("vvv",MINIMUM,2),
pass("",MAXIMUM,2),pass("vv",MAXIMUM,2),pass("123",MAXIMUM,2),
- pass("",MINIMUM,3,MAXIMUM,5),pass("ddd",MINIMUM,3,MAXIMUM,5),pass("dddd",MINIMUM,3,MAXIMUM,5),pass("abcdefg",MINIMUM,3,MAXIMUM,5));
+ pass("",MINIMUM,3,MAXIMUM,5,IGNORE_MESSAGE,true),pass("ddd",MINIMUM,3,MAXIMUM,5),pass("dddd",MINIMUM,3,MAXIMUM,5),pass("abcdefg",MINIMUM,3,MAXIMUM,5,IGNORE_MESSAGE,true));
}
}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/LongRangeValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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));
+ }
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/MaxValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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;
+ }
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RegexValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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+")
+ );
+ }
+}
Copied: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java (from rev 21134, branches/RF-9797/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java)
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java (rev 0)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/RequiredValidatorTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -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)
+ );
+ }
+}
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/client/validator/ValidatorTestBase.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -3,8 +3,7 @@
import static org.easymock.EasyMock.*;
import static org.junit.Assert.*;
-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,13 +16,20 @@
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 {
+ /**
+ * <p class="changed_added_4_0">TODO remove to check all messages.</p>
+ * @deprecated Remove this option then all messages will be passed properly.
+ */
+ public static final String IGNORE_MESSAGE = "ignoreMessage";
private static final Converter NUMBER_CONVERTER = new Converter() {
public String getAsString(FacesContext context, UIComponent component, Object value) {
@@ -35,7 +41,6 @@
return Double.valueOf(value);
}
};
-
public ValidatorTestBase(RunParameters criteria) {
super(criteria);
}
@@ -45,38 +50,45 @@
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"));
+ if (!getOptions().containsKey(IGNORE_MESSAGE)) {
+ NativeObject value = (NativeObject) ((JavaScriptException) cause).getValue();
+ 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);
}
-}
+}
\ No newline at end of file
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetClientSideScriptTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -10,7 +10,6 @@
import javax.faces.convert.NumberConverter;
import javax.faces.validator.RegexValidator;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.jboss.test.faces.mock.Mock;
import org.jboss.test.faces.mock.MockTestRunner;
import org.junit.After;
@@ -62,7 +61,7 @@
expect(scriptService.getScript(environment.getFacesContext(), RegexValidator.class)).andThrow(new ScriptNotFoundException());
controller.replay();
- Collection<? extends ScriptWithDependencies> clientSideValidatorScript = renderer.getClientSideValidatorScript(
+ Collection<? extends LibraryScriptFunction> clientSideValidatorScript = renderer.getClientSideValidatorScript(
environment.getFacesContext(), descriptors);
assertTrue(clientSideValidatorScript.isEmpty());
controller.verify();
@@ -87,11 +86,10 @@
expect(script.getName()).andReturn(REGEX_VALIDATOR).atLeastOnce();
expect(script.getResources()).andReturn(CLIENT_VALIDATOR_LIBRARY);
controller.replay();
- Collection<? extends ScriptWithDependencies> clientSideScripts = renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
+ Collection<? extends LibraryScriptFunction> clientSideScripts = renderer.getClientSideValidatorScript(environment.getFacesContext(), descriptors);
LibraryScriptFunction clientSideScript = (LibraryScriptFunction) Iterables.getOnlyElement(clientSideScripts);
- assertEquals(ClientValidatorRenderer.CONVERTED_VALUE_LITERAL, clientSideScript.getParameters().get(0));
- assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
- assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
+ assertEquals(VALIDATOR_MESSAGE, clientSideScript.getMessage());
+ assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters());
assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
@@ -108,9 +106,8 @@
controller.replay();
LibraryScriptFunction clientSideScript =
(LibraryScriptFunction) renderer.getClientSideConverterScript(environment.getFacesContext(), converterDescriptor);
- assertEquals(ClientValidatorRenderer.VALUE_LITERAL, clientSideScript.getParameters().get(0));
- assertEquals(VALIDATOR_MESSAGE, clientSideScript.getParameters().get(1));
- assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters().get(2));
+ assertEquals(VALIDATOR_MESSAGE, clientSideScript.getMessage());
+ assertEquals(VALIDATOR_PARAMS, clientSideScript.getParameters());
assertEquals(CLIENT_VALIDATOR_LIBRARY, clientSideScript.getResources());
controller.verify();
}
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2011-01-20 23:59:35 UTC (rev 21135)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/renderkit/html/RendererGetComponentScriptTest.java 2011-01-21 00:29:53 UTC (rev 21136)
@@ -9,15 +9,12 @@
import java.util.Collection;
import java.util.Map;
-import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.NumberConverter;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptWithDependencies;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -26,6 +23,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.richfaces.javascript.LibraryFunction;
+import org.richfaces.javascript.Message;
import org.richfaces.javascript.ScriptNotFoundException;
import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.ConverterDescriptor;
@@ -200,14 +198,15 @@
}
private LibraryScriptFunction createValidatorFunction() {
- return createFunction(REGEX_VALIDATOR, ClientValidatorRenderer.CONVERTED_VALUE_VAR, FACES_VALIDATOR_MESSAGE);
+ return createFunction(REGEX_VALIDATOR, VALIDATOR_MESSAGE);
}
private LibraryScriptFunction createConverterFunction() {
- return createFunction(NUMBER_CONVERTER, ClientValidatorRenderer.VALUE_VAR, FACES_VALIDATOR_MESSAGE);
+ return createFunction(NUMBER_CONVERTER, VALIDATOR_MESSAGE);
}
- private LibraryScriptFunction createFunction(final String name, String var, FacesMessage validatorMessage) {
+
+ private LibraryScriptFunction createFunction(final String name, Message validatorMessage) {
LibraryFunction libraryScript = new LibraryFunction() {
@@ -220,7 +219,7 @@
return CLIENT_VALIDATOR_LIBRARY;
}
};
- return new LibraryScriptFunction(libraryScript, new JSReference(var), validatorMessage, VALIDATOR_PARAMS);
+ return new LibraryScriptFunction(libraryScript, validatorMessage, VALIDATOR_PARAMS);
}
private ClientValidatorRenderer createStubRenderer(final LibraryScriptFunction converterFunction,
@@ -238,7 +237,7 @@
}
@Override
- Collection<? extends ScriptWithDependencies> getClientSideValidatorScript(FacesContext facesContext,
+ Collection<? extends LibraryScriptFunction> getClientSideValidatorScript(FacesContext facesContext,
Collection<ValidatorDescriptor> validators) {
return Lists.newArrayList(validatorFunctions);
}
13 years, 11 months