JBoss Rich Faces SVN: r21383 - trunk/ui/output/ui/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2011-02-02 07:22:44 -0500 (Wed, 02 Feb 2011)
New Revision: 21383
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
Log:
RF-9954: attribute "panelToggleListener" is renamed to "toggleListener"
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2011-02-02 11:32:28 UTC (rev 21382)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2011-02-02 12:22:44 UTC (rev 21383)
@@ -104,7 +104,7 @@
public abstract String getHeader();
@Attribute
- public abstract MethodExpression getPanelToggleListener();
+ public abstract MethodExpression getToggleListener();
// ------------------------------------------------ Html Attributes
13 years, 2 months
JBoss Rich Faces SVN: r21382 - in trunk/ui/iteration/ui/src/main: resources/META-INF/resources/org.richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2011-02-02 06:32:28 -0500 (Wed, 02 Feb 2011)
New Revision: 21382
Added:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.ecss
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
Log:
RF-10194 CollapsibleSubTableToggleControl: missing hand cursor decoration
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java
===================================================================
--- trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java 2011-02-02 09:21:41 UTC (rev 21381)
+++ trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/CollapsibleSubTableTogglerRendererBase.java 2011-02-02 11:32:28 UTC (rev 21382)
@@ -50,6 +50,7 @@
{@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "richfaces.js"),
@ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(library="org.richfaces", name = "collapsible-subtable-toggler.ecss"),
@ResourceDependency(library="org.richfaces", name = "collapsible-subtable-toggler.js")
})
public class CollapsibleSubTableTogglerRendererBase extends RendererBase {
@@ -115,7 +116,7 @@
}
writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE, control.getClientId(context) + ":" + state, null);
- writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, styleClass, null);
+ writer.writeAttribute(HtmlConstants.CLASS_ATTRIBUTE, concatClasses(getIconClass(expanded), styleClass), null);
writer.writeAttribute(HtmlConstants.STYLE_ATTRIBUTE, style, null);
UIComponent controlFacet = control.getFacet(state);
@@ -205,4 +206,16 @@
protected String getState(boolean expanded) {
return expanded ? EXPANDED_STATE : COLLAPSED_STATE;
}
+
+ protected String getIconClass(boolean expanded) {
+ return expanded ? getExpandedIconClass() : getCollapsedIconClass();
+ }
+
+ public String getExpandedIconClass() {
+ return "rf-csttg-exp";
+ }
+
+ public String getCollapsedIconClass() {
+ return "rf-csttg-colps";
+ }
}
\ No newline at end of file
Added: trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.ecss
===================================================================
--- trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.ecss (rev 0)
+++ trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/collapsible-subtable-toggler.ecss 2011-02-02 11:32:28 UTC (rev 21382)
@@ -0,0 +1,7 @@
+.rf-csttg-exp {
+ cursor:pointer;
+}
+
+.rf-csttg-colps {
+ cursor:pointer;
+}
\ No newline at end of file
13 years, 2 months
JBoss Rich Faces SVN: r21381 - in modules/tests/metamer/trunk: application/src/main/webapp/components/a4jOutputPanel and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ppitonak(a)redhat.com
Date: 2011-02-02 04:21:41 -0500 (Wed, 02 Feb 2011)
New Revision: 21381
Removed:
modules/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jOutputPanel.css
Modified:
modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JOutputPanelBean.properties
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/list.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/simple.xhtml
modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
Log:
* sample and tests for a4j:outputPanel refactored
Modified: modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JOutputPanelBean.properties
===================================================================
--- modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JOutputPanelBean.properties 2011-02-02 06:19:07 UTC (rev 21380)
+++ modules/tests/metamer/trunk/application/src/main/resources/org/richfaces/tests/metamer/bean/A4JOutputPanelBean.properties 2011-02-02 09:21:41 UTC (rev 21381)
@@ -5,7 +5,3 @@
attr.layout.block=block
attr.layout.inline=inline
attr.layout.none=none
-
-attr.styleClass.blue-background=blue-background
-attr.styleClass.gray-background=gray-background
-attr.styleClass.none=
\ No newline at end of file
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/list.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/list.xhtml 2011-02-02 06:19:07 UTC (rev 21380)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/list.xhtml 2011-02-02 09:21:41 UTC (rev 21381)
@@ -5,7 +5,7 @@
<!--
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.
Modified: modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/simple.xhtml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/simple.xhtml 2011-02-02 06:19:07 UTC (rev 21380)
+++ modules/tests/metamer/trunk/application/src/main/webapp/components/a4jOutputPanel/simple.xhtml 2011-02-02 09:21:41 UTC (rev 21381)
@@ -6,7 +6,7 @@
<!--
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.
@@ -34,7 +34,6 @@
<f:converter converterId="templatesListConverter" />
</f:viewParam>
</f:metadata>
- <h:outputStylesheet library="css" name="a4jOutputPanel.css"/>
</ui:define>
<ui:define name="outOfTemplateBefore">
Deleted: modules/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jOutputPanel.css
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jOutputPanel.css 2011-02-02 06:19:07 UTC (rev 21380)
+++ modules/tests/metamer/trunk/application/src/main/webapp/resources/css/a4jOutputPanel.css 2011-02-02 09:21:41 UTC (rev 21381)
@@ -1,8 +0,0 @@
-.blue-background {
- background-color: #85E9FF;
-}
-
-.gray-background {
- background-color: gray;
- color: white;
-}
Modified: modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java
===================================================================
--- modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2011-02-02 06:19:07 UTC (rev 21380)
+++ modules/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/a4jOutputPanel/TestA4JOutputPanel.java 2011-02-02 09:21:41 UTC (rev 21381)
@@ -32,8 +32,6 @@
import java.net.URL;
import org.jboss.test.selenium.dom.Event;
-import org.jboss.test.selenium.locator.Attribute;
-import org.jboss.test.selenium.locator.AttributeLocator;
import org.jboss.test.selenium.locator.JQueryLocator;
import org.richfaces.tests.metamer.ftest.AbstractMetamerTest;
import org.richfaces.tests.metamer.ftest.annotations.Inject;
@@ -77,19 +75,10 @@
JQueryLocator element = null;
if ("inline".equals(layout)) {
- // for inline layout set background to blue
selenium.click(pjq("input[name$=layoutInput][value=inline]"));
selenium.waitForPageToLoad(TIMEOUT);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
-
element = outputSpan;
} else {
- // for inline layout set background to gray
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
-
element = outputDiv;
}
@@ -185,50 +174,12 @@
@Test
public void testStyle() {
- String style = "background-color: magenta; color: white; font-weight: bold;";
- JQueryLocator styleInput = pjq("input[id$=styleInput]");
- AttributeLocator<?> attributeStyle = outputDiv.getAttribute(Attribute.STYLE);
-
- selenium.typeKeys(styleInput, style);
- selenium.waitForPageToLoad(TIMEOUT);
-
- String attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, style, "Value of attribute style.");
-
- selenium.typeKeys(styleInput, "");
- selenium.waitForPageToLoad(TIMEOUT);
-
- if (selenium.isAttributePresent(attributeStyle)) {
- attributeValue = selenium.getAttribute(attributeStyle);
- assertEquals(attributeValue, "", "Value of attribute style.");
- }
+ testStyle(outputDiv, "style");
}
@Test
public void testStyleClass() {
- JQueryLocator optionNone = pjq("input[name$=styleClassInput][value=]");
- AttributeLocator<?> attributeClass = outputDiv.getAttribute(Attribute.CLASS);
-
- selenium.click(optionBlue);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "blue-background"), "Panel should have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
-
- selenium.click(optionGray);
- selenium.waitForPageToLoad(TIMEOUT);
- assertTrue(selenium.belongsClass(outputDiv, "gray-background"), "Panel should have class gray-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
-
- selenium.click(optionNone);
- selenium.waitForPageToLoad(TIMEOUT);
- if (selenium.isAttributePresent(attributeClass)) {
- assertFalse(selenium.belongsClass(outputDiv, "blue-background"),
- "Panel should not have class blue-background set.");
- assertFalse(selenium.belongsClass(outputDiv, "gray-background"),
- "Panel should not have class gray-background set.");
- }
+ testStyleClass(outputDiv, "styleClass");
}
@Test
13 years, 2 months
JBoss Rich Faces SVN: r21380 - in modules/docs/trunk/Component_Reference/src/main/docbook/en-US: extras and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: SeanRogers
Date: 2011-02-02 01:19:07 -0500 (Wed, 02 Feb 2011)
New Revision: 21380
Added:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtree-nodeType_attribute.png
Removed:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtree-nodeFace_attribute.png
Modified:
modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml
Log:
Updated rich:tree RFPL-984
Modified: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml 2011-02-02 00:08:05 UTC (rev 21379)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/chap-Component_Reference-Trees.xml 2011-02-02 06:19:07 UTC (rev 21380)
@@ -26,7 +26,7 @@
The <sgmltag><rich:tree></sgmltag> component requires the <varname>value</varname> attribute to point to the data model for populating the tree. The data model must be either an <interfacename>org.richfaces.model.TreeNode</interfacename> interface, an <varname>org.richfaces.model.TreeDataModel</varname> interface, or a <interfacename>javax.swing.tree.TreeNode</interfacename> interface. The <varname>var</varname> attribute declares the variable used for iterating through the data model, so that child <sgmltag><rich:treeNode></sgmltag> components can reference each iteration.
</para>
<para>
- For basic usage, the <sgmltag><rich:tree></sgmltag> component needs one or more <sgmltag><rich:treeNode></sgmltag> components to work with the data model.
+ Ideally, the <sgmltag><rich:tree></sgmltag> component needs one or more <sgmltag><rich:treeNode></sgmltag> components to work with the data model. However if no <sgmltag><rich:treeNode></sgmltag> components are provided the tree creates default nodes instead.
</para>
<example id="exam-Component_Reference-richtree-Basic_usage">
<title>Basic usage</title>
@@ -52,40 +52,35 @@
<section id="sect-Component_Reference-richtree-Appearance">
<title>Appearance</title>
<para>
- Different nodes in the tree can have different appearances, such as node icons, depending on the type of data the node contains. Use the <varname>nodeFace</varname> attribute to differentiate the types of nodes; the node is then rendered according to the <sgmltag><rich:treeNode></sgmltag> component with the corresponding <varname>type</varname> attribute. <xref linkend="exam-Component_Reference-richtree-Appearance" /> shows a <sgmltag><rich:tree></sgmltag> component with three different child <sgmltag><rich:treeNode></sgmltag> components defined to represent three different node appearances. Refer to <xref linkend="sect-Component_Reference-richtreeNode-Appearance" /> for details on customizing the appearance of <sgmltag><rich:treeNode></sgmltag> components.
+ Different nodes in the tree can have different appearances, such as node icons, depending on the type of data the node contains. Use the <varname>nodeType</varname> attribute to differentiate the types of nodes; the node is then rendered according to the <sgmltag><rich:treeNode></sgmltag> component with the corresponding <varname>type</varname> attribute. <xref linkend="exam-Component_Reference-richtree-Appearance" /> shows a <sgmltag><rich:tree></sgmltag> component with three different child <sgmltag><rich:treeNode></sgmltag> components defined to represent three different node appearances. Refer to <xref linkend="sect-Component_Reference-richtreeNode-Appearance" /> for details on customizing the appearance of <sgmltag><rich:treeNode></sgmltag> components.
</para>
- <example id="exam-Component_Reference-richtree-nodeFace_attribute">
- <title><varname>nodeFace</varname> attribute</title>
- <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <example id="exam-Component_Reference-richtree-nodeType_attribute">
+ <title><varname>nodeType</varname> attribute</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-nodeType_attribute.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
<mediaobject>
<imageobject>
- <imagedata fileref="images/exam-Component_Reference-richtree-nodeFace_attribute.png" format="PNG" />
+ <imagedata fileref="images/exam-Component_Reference-richtree-nodeType_attribute.png" format="PNG" />
</imageobject>
</mediaobject>
</example>
<para>
- Alternatively, use Expression Language (<acronym>EL</acronym>) with the <varname>nodeFace</varname> attribute, as shown in <xref linkend="exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language" />.
+ Alternatively, use Expression Language (<acronym>EL</acronym>) with the <varname>nodeType</varname> attribute, as shown in <xref linkend="exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language" />.
</para>
- <example id="exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language">
- <title><varname>nodeface</varname> attribute with Expression Language</title>
- <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ <example id="exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language">
+ <title><varname>nodeType</varname> attribute with Expression Language</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
<para>
- If the <varname>nodeFace</varname> attribute returns null, the node is rendered as a "<emphasis>typeless</emphasis>" node. The <emphasis>typeless</emphasis> node is the first child <sgmltag><rich:treeNode></sgmltag> component with a valid <varname>rendered</varname> attribute, but without a defined <varname>type</varname> attribute.
+ If the <varname>nodeType</varname> attribute returns null, the node is rendered as a "<emphasis>typeless</emphasis>" (or default) node. The <emphasis>typeless</emphasis> node is the first child <sgmltag><rich:treeNode></sgmltag> component with a valid <varname>rendered</varname> attribute, but without a defined <varname>type</varname> attribute.
</para>
<para>
+ If the <varname>nodeType</varname> attribute is not included and there are no child <sgmltag><rich:treeNode></sgmltag> components, the tree constructs a default node itself.
+ </para>
+ <para>
Icons for different nodes and node states can be defined for the whole tree using the following attributes:
</para>
<variablelist>
<varlistentry>
- <term><varname>icon</varname></term>
- <listitem>
- <para>
- The <varname>icon</varname> attribute points to the icon to use for any node that contains child nodes.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
<term><varname>iconLeaf</varname></term>
<listitem>
<para>
@@ -102,6 +97,8 @@
</listitem>
</varlistentry>
</variablelist>
+ <!-- TODO not in M6 -->
+ <!--
<para>
Alternatively, use facets with the same names as the attributes to define the icons, as shown in <xref linkend="exam-Component_Reference-richtree-Icon_facets" />. The width of the rendered facet is 16 pixels.
</para>
@@ -109,12 +106,13 @@
<title>Icon facets</title>
<programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-Icon_facets.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
</example>
+ -->
</section>
<section id="sect-Component_Reference-richtree-Expanding_and_collapsing_tree_nodes">
<title>Expanding and collapsing tree nodes</title>
<para>
- The switching mode for performing submissions is determined by the <varname>switchType</varname> attribute, which can have one of the following three values:
+ The mode for performing submissions when nodes are expanded or collapsed is determined by the <varname>toggleType</varname> attribute, which can have one of the following three values:
</para>
<variablelist>
<varlistentry>
@@ -142,55 +140,91 @@
</listitem>
</varlistentry>
</variablelist>
+ <para>
+ By default, the event to expand or collapse a tree node is a mouse click. To specify a different event, use the <varname>toggleNodeEvent</varname> attribute.
+ </para>
+ </section>
- <section id="sect-Component_Reference-richtree-Identifying_nodes">
+ <section id="sect-Component_Reference-richtree-Selecting_tree_nodes">
+ <title>Selecting tree nodes</title>
+ <para>
+ The mode for performing submissions when nodes are selected is determined by the <varname>selectionType</varname> attribute, which can have one of the following three values:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><literal>ajax</literal></term>
+ <listitem>
+ <para>
+ This is the default setting. The <sgmltag><rich:tree></sgmltag> component performs an Ajax form submission, and only the content of the tree is rendered.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><literal>server</literal></term>
+ <listitem>
+ <para>
+ The <sgmltag><rich:tree></sgmltag> component performs a common submission, completely re-rendering the page.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><literal>client</literal></term>
+ <listitem>
+ <para>
+ The <sgmltag><rich:tree></sgmltag> component updates on the client side, re-rendering itself and any additional components listed with the <varname>render</varname> attribute.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+
+ <section id="sect-Component_Reference-richtree-Identifying_nodes">
+ <title>Identifying nodes</title>
+ <para>
+ The <sgmltag><rich:tree></sgmltag> component uses a data model to represent the node structure on the page. To identify a particular node during a client request, the model provides unique keys for tree nodes. The <sgmltag><rich:tree></sgmltag> component can use strings as key values. These strings may contain special characters that are not allowed by browsers, such as the left angle bracket (<) and ampersand (&). To allow these characters in the keys, the following converter is provided:
+ </para>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.richfaces.TreeRowKeyConverter</classname></term>
+ <listitem>
+ <para>
+ The <classname>org.richfaces.TreeRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNode></sgmltag> components. The key should be of the type <type>java.lang.String</type>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <!-- TODO not in M5
+ <varlistentry>
+ <term><classname>org.richfaces.TreeAdaptorRowKeyConverter</classname></term>
+ <listitem>
+ <para>
+ The <classname>org.richfaces.TreeAdaptorRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNodesAdaptor></sgmltag> components. The key should be of the type <type>java.lang.String</type>.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.richfaces.TreeAdaptorIntegerRowKeyConverter</classname></term>
+ <listitem>
+ <para>
+ The <classname>org.richfaces.TreeAdaptorIntegerRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNodesAdaptor></sgmltag> components, but uses a numerical key. The key should be of the type <type>java.lang.Integer</type>.
+ </para>
+ </listitem>
+ </varlistentry>
+ -->
+ </variablelist>
+ <para>
+ To apply a converter to the <sgmltag><rich:tree></sgmltag> component, define it with the <varname>rowKeyConverter</varname> attribute. <xref linkend="exam-Component_Reference-richtree-Identifying_nodes" /> demonstrates the use of a converter to identify tree nodes.
+ </para>
+ <example id="exam-Component_Reference-richtree-Identifying_nodes">
<title>Identifying nodes</title>
+ <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-Identifying_nodes.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
<para>
- The <sgmltag><rich:tree></sgmltag> component uses a data model to represent the node structure on the page. To identify a particular node during a client request, the model provides unique keys for tree nodes. The <sgmltag><rich:tree></sgmltag> component can use strings as key values. These strings may contain special characters that are not allowed by browsers, such as the left angle bracket (<) and ampersand (&). To allow these characters in the keys, the following converter is provided:
+ The tree uses the following data model. The model can contain special characters normally disallowed in web page code.
</para>
- <variablelist>
- <varlistentry>
- <term><classname>org.richfaces.TreeRowKeyConverter</classname></term>
- <listitem>
- <para>
- The <classname>org.richfaces.TreeRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNode></sgmltag> components. The key should be of the type <type>java.lang.String</type>.
- </para>
- </listitem>
- </varlistentry>
- <!-- TODO not in M5
- <varlistentry>
- <term><classname>org.richfaces.TreeAdaptorRowKeyConverter</classname></term>
- <listitem>
- <para>
- The <classname>org.richfaces.TreeAdaptorRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNodesAdaptor></sgmltag> components. The key should be of the type <type>java.lang.String</type>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><classname>org.richfaces.TreeAdaptorIntegerRowKeyConverter</classname></term>
- <listitem>
- <para>
- The <classname>org.richfaces.TreeAdaptorIntegerRowKeyConverter</classname> converter is used for trees constructed using <sgmltag><rich:treeNodesAdaptor></sgmltag> components, but uses a numerical key. The key should be of the type <type>java.lang.Integer</type>.
- </para>
- </listitem>
- </varlistentry>
- -->
- </variablelist>
- <para>
- To apply a converter to the <sgmltag><rich:tree></sgmltag> component, define it with the <varname>rowKeyConverter</varname> attribute. <xref linkend="exam-Component_Reference-richtree-Identifying_nodes" /> demonstrates the use of a converter to identify tree nodes.
- </para>
- <example id="exam-Component_Reference-richtree-Identifying_nodes">
- <title>Identifying nodes</title>
- <programlisting language="XML" role="XML"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-Identifying_nodes.xml_sample" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
- <para>
- The tree uses the following data model. The model can contain special characters normally disallowed in web page code.
- </para>
- <programlisting language="Java" role="JAVA"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-Identifying_nodes.js" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
- </example>
- </section>
+ <programlisting language="Java" role="JAVA"><xi:include parse="text" href="extras/exam-Component_Reference-richtree-Identifying_nodes.js" xmlns:xi="http://www.w3.org/2001/XInclude" /></programlisting>
+ </example>
</section>
- <!-- TODO not in M5 -->
+ <!-- TODO not in M6 -->
<!--
<section id="sect-Component_Reference-richtree-Built-in_drag_and_drop">
<title>Built-in drag and drop</title>
@@ -208,16 +242,27 @@
<itemizedlist>
<listitem>
<para>
- The <varname>onexpand</varname> event is triggered when a node is expanded.
+ The <varname>onnodetoggle</varname> event is triggered when a node is expanded or collapsed.
</para>
</listitem>
<listitem>
<para>
- The <varname>oncollapse</varname> event is triggered when a node is collapsed.
+ The <varname>onbeforenodetoggle</varname> event is triggered before a node is expanded or collapsed.
</para>
</listitem>
<listitem>
<para>
+ The <varname>onselectionchange</varname> event is triggered when a node is selected.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The <varname>onbeforeselectionchange</varname> event is triggered before a node is selected.
+ </para>
+ </listitem>
+ <!--
+ <listitem>
+ <para>
The <varname>ondragstart</varname> event is triggered when an element starts being dragged.
</para>
</listitem>
@@ -236,6 +281,7 @@
The <varname>ondragend</varname> event is triggered when an element is dropped.
</para>
</listitem>
+ -->
</itemizedlist>
<para>
The <sgmltag><rich:tree></sgmltag> component uses the following server-side listeners:
@@ -243,9 +289,10 @@
<itemizedlist>
<listitem>
<para>
- The <varname>changeExpandListener</varname> listener processes expand and collapse events.
+ The <varname>toggleListener</varname> listener processes expand and collapse events.
</para>
</listitem>
+ <!--
<listitem>
<para>
The <varname>dragListener</varname> listener processes drag events.
@@ -256,9 +303,10 @@
The <varname>dropListener</varname> listener processes drop events.
</para>
</listitem>
+ -->
<listitem>
<para>
- The <varname>nodeSelectListener</varname> listener processes the request when a node is selected.
+ The <varname>selectionChangeListener</varname> listener processes the request when a node is selected.
</para>
</listitem>
</itemizedlist>
@@ -304,14 +352,14 @@
<section id="sect-Component_Reference-richtreeNode-Basic_usage">
<title>Basic usage</title>
<para>
- The <sgmltag><rich:treeNode></sgmltag> component must be a child of a <sgmltag><rich:tree></sgmltag> component. It does not need any attributes declared for basic usage, but should contain the content of the nodes. Refer to <xref linkend="exam-Component_Reference-richtree-Basic_usage" /> for an example of basic <sgmltag><rich:treeNode></sgmltag> component usage.
+ The <sgmltag><rich:treeNode></sgmltag> component must be a child of a <sgmltag><rich:tree></sgmltag> component. It does not need any attributes declared for basic usage, but can provide markup templates for tree nodes of particular types. Refer to <xref linkend="exam-Component_Reference-richtree-Basic_usage" /> for an example of basic <sgmltag><rich:treeNode></sgmltag> component usage.
</para>
</section>
<section id="sect-Component_Reference-richtreeNode-Appearance">
<title>Appearance</title>
<para>
- Refer to <xref linkend="sect-Component_Reference-richtree-Appearance" /> for the <sgmltag><rich:tree></sgmltag> component for details and examples on styling nodes and icons. Icon styling for individual <sgmltag><rich:treeNode></sgmltag> components uses the same attributes as the parent <sgmltag><rich:tree></sgmltag> component: <varname>icon</varname>, <varname>iconLeaf</varname>, <varname>iconExpanded</varname>, and <varname>iconCollapsed</varname>. Icon-related attributes specified for child <sgmltag><rich:treeNode></sgmltag> components overwrite any global icon attributes of the parent <sgmltag><rich:tree></sgmltag> component.
+ Refer to <xref linkend="sect-Component_Reference-richtree-Appearance" /> for the <sgmltag><rich:tree></sgmltag> component for details and examples on styling nodes and icons. Icon styling for individual <sgmltag><rich:treeNode></sgmltag> components uses the same attributes as the parent <sgmltag><rich:tree></sgmltag> component: <varname>iconLeaf</varname>, <varname>iconExpanded</varname>, and <varname>iconCollapsed</varname>. Icon-related attributes specified for child <sgmltag><rich:treeNode></sgmltag> components overwrite any global icon attributes of the parent <sgmltag><rich:tree></sgmltag> component.
</para>
<para>
Use the <varname>rendered</varname> attribute to determine whether the node should actually be rendered in the tree or not. Using the <varname>rendered</varname> attribute in combination with the <sgmltag><rich:treeNode></sgmltag> <varname>type</varname> attribute can allow further style differentiation between node content, as shown in <xref linkend="exam-Component_Reference-richtreeNode-rendered_attribute" />.
@@ -333,8 +381,12 @@
<section id="sect-Component_Reference-richtreeNode-Interactivity">
<title>Interactivity</title>
<para>
- All interactivity with individual nodes, such as expanding and collapsing, drag-and-drop, and other events handling, is managed by the parent <sgmltag><rich:tree></sgmltag> component. Refer to <xref linkend="sect-Component_Reference-richtree-Expanding_and_collapsing_tree_nodes" /><!--, <xref linkend="sect-Component_Reference-richtree-Built-in_drag_and_drop" />,--> and <xref linkend="sect-Component_Reference-richtree-Event_handling" /> for further details.
+ Interactivity with individual nodes, such as expanding, collapsing, and other event handling, can be managed by the parent <sgmltag><rich:tree></sgmltag> component. Refer to <xref linkend="sect-Component_Reference-richtree-Expanding_and_collapsing_tree_nodes" /><!--, <xref linkend="sect-Component_Reference-richtree-Built-in_drag_and_drop" />,--> and <xref linkend="sect-Component_Reference-richtree-Event_handling" /> for further details.
</para>
+ <!-- TODO node interactivity re-definitions - not in M6 -->
+ <para>
+ Use the <varname>expanded</varname> attribute to determine whether the node is expanded or collapsed.
+ </para>
</section>
<section id="sect-Component_Reference-richtreeNode-Reference_data">
Deleted: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample 2011-02-02 00:08:05 UTC (rev 21379)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample 2011-02-02 06:19:07 UTC (rev 21380)
@@ -1,11 +0,0 @@
-<rich:tree style="width:300px" value="#{library.data}" var="item" nodeFace="#{item.type}">
- <rich:treeNode type="artist" iconLeaf="/images/tree/singer.png" icon="/images/tree/singer.png">
- <h:outputText value="#{item.name}" />
- </rich:treeNode>
- <rich:treeNode type="album" iconLeaf="/images/tree/disc.png" icon="/images/tree/disc.png">
- <h:outputText value="#{item.title}" />
- </rich:treeNode>
- <rich:treeNode type="song" iconLeaf="/images/tree/song.png" icon="/images/tree/song.png">
- <h:outputText value="#{item.title}" />
- </rich:treeNode>
-</rich:tree>
Deleted: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample 2011-02-02 00:08:05 UTC (rev 21379)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample 2011-02-02 06:19:07 UTC (rev 21380)
@@ -1,2 +0,0 @@
-<rich:tree value="#{library.data}" var="item"
- nodeFace="#{data.name != 'param-value' ? 'artist' : 'album'}">
Copied: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute.xml_sample (from rev 21136, modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute.xml_sample)
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute.xml_sample 2011-02-02 06:19:07 UTC (rev 21380)
@@ -0,0 +1,11 @@
+<rich:tree style="width:300px" value="#{library.data}" var="item" nodeType="#{item.type}">
+ <rich:treeNode type="artist" iconLeaf="/images/tree/singer.png" icon="/images/tree/singer.png">
+ <h:outputText value="#{item.name}" />
+ </rich:treeNode>
+ <rich:treeNode type="album" iconLeaf="/images/tree/disc.png" icon="/images/tree/disc.png">
+ <h:outputText value="#{item.title}" />
+ </rich:treeNode>
+ <rich:treeNode type="song" iconLeaf="/images/tree/song.png" icon="/images/tree/song.png">
+ <h:outputText value="#{item.title}" />
+ </rich:treeNode>
+</rich:tree>
Copied: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language.xml_sample (from rev 21136, modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeFace_attribute_with_Expression_Language.xml_sample)
===================================================================
--- modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language.xml_sample (rev 0)
+++ modules/docs/trunk/Component_Reference/src/main/docbook/en-US/extras/exam-Component_Reference-richtree-nodeType_attribute_with_Expression_Language.xml_sample 2011-02-02 06:19:07 UTC (rev 21380)
@@ -0,0 +1,2 @@
+<rich:tree value="#{library.data}" var="item"
+ nodeType="#{data.name != 'param-value' ? 'artist' : 'album'}">
Deleted: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtree-nodeFace_attribute.png
===================================================================
(Binary files differ)
Copied: modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtree-nodeType_attribute.png (from rev 21136, modules/docs/trunk/Component_Reference/src/main/docbook/en-US/images/exam-Component_Reference-richtree-nodeFace_attribute.png)
===================================================================
(Binary files differ)
13 years, 2 months
JBoss Rich Faces SVN: r21379 - in trunk/ui/validator/ui/src: main/resources/META-INF and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2011-02-01 19:08:05 -0500 (Tue, 01 Feb 2011)
New Revision: 21379
Modified:
trunk/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.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/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
Log:
RESOLVED - issue RF-10309: CSV: not working JSF validators.
https://issues.jboss.org/browse/RF-10309
Modified: trunk/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java
===================================================================
--- trunk/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2011-02-01 19:12:04 UTC (rev 21378)
+++ trunk/ui/validator/ui/src/main/java/org/richfaces/javascript/ClientServiceConfigParser.java 2011-02-02 00:08:05 UTC (rev 21379)
@@ -12,6 +12,8 @@
import javax.faces.FacesException;
import javax.xml.bind.JAXB;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
import org.richfaces.resource.ResourceKey;
import org.richfaces.validator.model.ClientSideScripts;
import org.richfaces.validator.model.Component;
@@ -29,6 +31,8 @@
*/
public final class ClientServiceConfigParser {
+ private static final Logger LOG = RichfacesLogger.CONFIG.getLogger();
+
private ClientServiceConfigParser() {
}
@@ -55,22 +59,26 @@
try {
ClientSideScripts clientSideScripts = JAXB.unmarshal(url, ClientSideScripts.class);
for (Component component : clientSideScripts.getComponent()) {
- Class<?> componentClass = loader.loadClass(component.getType());
- Iterable<ResourceKey> resources = Iterables.transform(component.getResource(), new Function<Resource,ResourceKey>(){
+ try {
+ Class<?> componentClass = loader.loadClass(component.getType());
+ Iterable<ResourceKey> resources =
+ Iterables.transform(component.getResource(), new Function<Resource, ResourceKey>() {
- public ResourceKey apply(Resource from) {
- return ResourceKey.create(from.getName(),from.getLibrary());
- }
-
- });
- LibraryFunctionImplementation function = new LibraryFunctionImplementation(component.getFunction(),
- resources);
- result.put(componentClass, function);
+ public ResourceKey apply(Resource from) {
+ return ResourceKey.create(from.getName(), from.getLibrary());
+ }
+
+ });
+ LibraryFunctionImplementation function =
+ new LibraryFunctionImplementation(component.getFunction(), resources);
+ result.put(componentClass, function);
+ } catch (ClassNotFoundException e) {
+ // throw new FacesException("Class for component not found", e);
+ LOG.warn("Found JavaScript function definition for class "+component.getType()+", but that class is not presented");
+ }
}
- } catch (ClassNotFoundException e) {
- throw new FacesException("Class for component not found",e);
} catch (Exception e) {
- throw new FacesException("Error parsing config file "+url,e);
+ throw new FacesException("Error parsing config file " + url, e);
}
return result;
}
Modified: trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml
===================================================================
--- trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-02-01 19:12:04 UTC (rev 21378)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/csv.xml 2011-02-02 00:08:05 UTC (rev 21379)
@@ -33,6 +33,62 @@
<function>RichFaces.csv.convertShort</function>
</component>
<component>
+ <type>javax.faces.convert.CharacterConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertCharacter</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.IntegerConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertInteger</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.LongConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertLong</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.FloatConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertFloat</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.DoubleConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertDouble</function>
+ </component>
+ <component>
+ <type>javax.faces.convert.DateConverter</type>
+ <resource>
+ <name>csv.reslib</name>
+ <library>org.richfaces</library>
+ </resource>
+ <function>RichFaces.csv.convertDate</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>
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-02-01 19:12:04 UTC (rev 21378)
+++ trunk/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/richfaces-csv.js 2011-02-02 00:08:05 UTC (rev 21379)
@@ -22,15 +22,6 @@
}
}
- 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;
@@ -45,6 +36,7 @@
return value;
}
+
$.extend(rf.csv, {
RE_DIGITS: /^-?\d+$/,
RE_FLOAT: /^(-?\d+)?(\.(\d+)?(e[+-]?\d+)?)?$/,
@@ -103,29 +95,27 @@
}
return true;
},
- /*
- 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);
- }
- */
});
+ /* convert all natural number formats
+ *
+ */
+ var _convertNatural = function(value,label,msg,min,max,sample){
+ var result; value = $.trim(value);
+ if (!rf.csv.RE_DIGITS.test(value) || (result=parseInt(value,10))<min || result>max) {
+ throw rf.csv.interpolateMessage(msg, sample?[value, sample, label]:[value,label]);
+ }
+ return result;
+ }
+
+ var _convertReal = function(value,label,msg,sample){
+ var result; value = $.trim(value);
+ if (!rf.csv.RE_FLOAT.test(value) || isNaN(result=parseFloat(value)) ) {
+ // TODO - check Float limits.
+ throw rf.csv.interpolateMessage(msg, sample?[value, sample, label]:[value,label]);
+ }
+ return result;
+ }
/*
* Converters implementation
*/
@@ -136,13 +126,15 @@
return result;
},
- "convertByte": function (value,label,params,msg) {
+ "convertDate": 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]);
- }
+ // TODO - JSF date converter options.
+ result=Date.parse(value);
return result;
},
+ "convertByte": function (value,label,params,msg) {
+ return _convertNatural(value,label,msg,-128,127,254);
+ },
"convertNumber": function (value,label,params,msg) {
var result; value=$.trim(value);
result = parseFloat(value);
@@ -151,12 +143,23 @@
}
return result;
},
+ "convertFloat": function (value,label,params,msg) {
+ return _convertReal(value,label,msg,2000000000);
+ },
+ "convertDouble": function (value,label,params,msg) {
+ return _convertReal(value,label,msg,1999999);
+ },
"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;
+ return _convertNatural(value,label,msg,-32768,32767,32456);
+ },
+ "convertInteger": function (value,label,params,msg) {
+ return _convertNatural(value,label,msg, -2147483648,2147483648,9346);
+ },
+ "convertCharacter": function (value,label,params,msg) {
+ return _convertNatural(value,label,msg, 0,65535);
+ },
+ "convertLong": function (value,label,params,msg) {
+ return _convertNatural(value,label,msg, -9223372036854775808,9223372036854775807,98765432);
}
});
Modified: trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java
===================================================================
--- trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2011-02-01 19:12:04 UTC (rev 21378)
+++ trunk/ui/validator/ui/src/test/java/org/richfaces/javascript/ServiceConfigParserTest.java 2011-02-02 00:08:05 UTC (rev 21379)
@@ -8,6 +8,7 @@
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.richfaces.resource.ResourceKey;
@@ -36,9 +37,11 @@
}
@Test(expected=FacesException.class)
+ @Ignore("parser log errors instead of exception")
public void testParseBadConfig() {
Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("badcsv.xml");
}
+
@Test()
public void testParseNoConfig() {
Map<Class<?>, LibraryFunction> parseConfig = ClientServiceConfigParser.parseConfig("non-exists-csv.xml");
13 years, 2 months
JBoss Rich Faces SVN: r21378 - trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2011-02-01 14:12:04 -0500 (Tue, 01 Feb 2011)
New Revision: 21378
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
Log:
http://jira.jboss.com/jira/browse/RF-10347
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2011-02-01 19:07:49 UTC (rev 21377)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2011-02-01 19:12:04 UTC (rev 21378)
@@ -40,11 +40,11 @@
name : "inplaceInput",
- geName: function() {
+ getName: function() {
return this.name;
},
- geNamespace: function() {
+ getNamespace: function() {
return this.namespace;
},
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2011-02-01 19:07:49 UTC (rev 21377)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2011-02-01 19:12:04 UTC (rev 21378)
@@ -46,7 +46,7 @@
getName: function() {
return this.name;
},
- geNamespace: function() {
+ getNamespace: function() {
return this.namespace;
},
onshow: function() {
@@ -228,6 +228,7 @@
this.__setValue(item.label);
this.save();
this.popupList.__selectByIndex(i);
+ break;
}
}
}
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
--- trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2011-02-01 19:07:49 UTC (rev 21377)
+++ trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2011-02-01 19:12:04 UTC (rev 21378)
@@ -12,7 +12,7 @@
this.options = mergedOptions;
this.defaultLabel = mergedOptions.defaultLabel;
- var inputLabel = this.getValue() ;
+ var inputLabel = this.__getValue() ;
this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel : "";
this.selValueInput = $(document.getElementById(id+"selValue"));
this.field = $(document.getElementById(id+"Field"));
@@ -86,8 +86,8 @@
__focusHandler: function(e) {
if (!this.focused) {
- if(this.getValue() == this.defaultLabel) {
- this.setValue("");
+ if(this.__getValue() == this.defaultLabel) {
+ this.__setValue("");
}
this.focusValue = this.selValueInput.val();
this.focused = true;
@@ -152,7 +152,7 @@
__onChangeValue: function(e) {
this.popupList.__selectByIndex();
- var newValue = this.getValue();
+ var newValue = this.__getValue();
if(this.cache && this.cache.isCached(newValue)) {
this.__updateItems();
@@ -190,7 +190,7 @@
},
__updateItems: function() {
- var newValue = this.getValue();
+ var newValue = this.__getValue();
newValue = (newValue != this.defaultLabel) ? newValue : "";
this.__updateItemsFromCache(newValue);
@@ -274,7 +274,7 @@
return false;
}
});
- this.setValue(label);
+ this.__setValue(label);
this.hidePopup();
this.__setInputFocus();
this.__save();
@@ -287,7 +287,7 @@
__save: function() {
var value = "";
var label = "";
- var inputLabel = this.getValue();
+ var inputLabel = this.__getValue();
if(inputLabel && inputLabel != "") {
if(this.enableManualInput) {
@@ -302,16 +302,16 @@
}
}
- this.setValue(label);
+ this.__setValue(label);
this.selValueInput.val(value);
},
onblur: function(e) {
this.hidePopup();
- var inputLabel = this.getValue();
+ var inputLabel = this.__getValue();
if(!inputLabel || inputLabel == "") {
- this.setValue(this.defaultLabel);
+ this.__setValue(this.defaultLabel);
this.selValueInput.val("");
}
@@ -320,7 +320,28 @@
if(this.focusValue != this.selValueInput.val() ) {
this.invokeEvent.call(this, "change", document.getElementById(this.id), e);
}
- }
+ },
+
+ getValue: function() {
+ return this.selValueInput.val();
+ },
+
+ setValue: function(value) {
+ var item;
+ for (var i=0; i<this.clientItems.length; i++) {
+ item = this.clientItems[i];
+ if (item.value == value) {
+ this.__setValue(item.label);
+ this.__save();
+ this.popupList.__selectByIndex(i);
+ return;
+ }
+ }
+ },
+
+ getLabel: function() {
+ return this.__getValue();
+ }
}
})());
13 years, 2 months
JBoss Rich Faces SVN: r21377 - trunk/ui/common/ui/src/main/java/org/richfaces/component/util.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-02-01 14:07:49 -0500 (Tue, 01 Feb 2011)
New Revision: 21377
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
Log:
https://issues.jboss.org/browse/RF-10131
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2011-02-01 19:07:25 UTC (rev 21376)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2011-02-01 19:07:49 UTC (rev 21377)
@@ -67,16 +67,11 @@
private static final String ITEM_DISABLED = "itemDisabled";
private static final String NO_SELECTION_OPTION = "noSelectionOption";
- private String var;
-
- private UIComponent sourceComponent;
-
- private GenericObjectSelectItem(UIComponent sourceComponent) {
- this.var = (String) sourceComponent.getAttributes().get(VAR);
- this.sourceComponent = sourceComponent;
+ private GenericObjectSelectItem() {
}
- private void updateItem(FacesContext facesContext, Object value) {
+ private void updateItem(FacesContext facesContext, UIComponent sourceComponent, Object value) {
+ String var = (String) sourceComponent.getAttributes().get(VAR);
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
Object oldVarValue = null;
@@ -146,8 +141,6 @@
private Iterator<?> data;
- private GenericObjectSelectItem genericItem;
-
public GenericItemsIterator(FacesContext facesContext, UIComponent component, Iterator<?> data) {
super();
this.facesContext = facesContext;
@@ -163,12 +156,9 @@
if (next instanceof SelectItem) {
return (SelectItem) next;
} else {
- if (genericItem == null) {
- genericItem = new GenericObjectSelectItem(component);
- }
+ GenericObjectSelectItem genericItem = new GenericObjectSelectItem();
+ genericItem.updateItem(facesContext, component, next);
- genericItem.updateItem(facesContext, next);
-
return genericItem;
}
}
13 years, 2 months
JBoss Rich Faces SVN: r21376 - trunk/examples/input-demo/src/main/webapp/templates.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-02-01 14:07:25 -0500 (Tue, 01 Feb 2011)
New Revision: 21376
Modified:
trunk/examples/input-demo/src/main/webapp/templates/template.xhtml
Log:
Updated navigation in input-demo
Modified: trunk/examples/input-demo/src/main/webapp/templates/template.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/templates/template.xhtml 2011-02-01 19:04:38 UTC (rev 21375)
+++ trunk/examples/input-demo/src/main/webapp/templates/template.xhtml 2011-02-01 19:07:25 UTC (rev 21376)
@@ -31,14 +31,14 @@
<h:form id="nav">
<p>Input Component's Examples</p>
<ul>
- <li><h:commandLink value="rich:calendar" action="calendar" /></li>
- <li><h:commandLink value="rich:inplaceInput" action="inplaceInput" /></li>
- <li><h:commandLink value="rich:inplaceSelect" action="inplaceSelect" /></li>
- <li><h:commandLink value="rich:inputNumberSlider" action="inputNumberSlider" /></li>
- <li><h:commandLink value="rich:inputNumberSpinner" action="inputNumberSpinner" /></li>
- <li><h:commandLink value="rich:autocomplete" action="autocomplete" /></li>
- <li><h:commandLink value="rich:fileUpload" action="fileUpload" /></li>
- <li><h:commandLink value="rich:select" action="select" /></li>
+ <li><h:link value="rich:calendar" outcome="calendar" /></li>
+ <li><h:link value="rich:inplaceInput" outcome="inplaceInput" /></li>
+ <li><h:link value="rich:inplaceSelect" outcome="inplaceSelect" /></li>
+ <li><h:link value="rich:inputNumberSlider" outcome="inputNumberSlider" /></li>
+ <li><h:link value="rich:inputNumberSpinner" outcome="inputNumberSpinner" /></li>
+ <li><h:link value="rich:autocomplete" outcome="autocomplete" /></li>
+ <li><h:link value="rich:fileUpload" outcome="fileUpload" /></li>
+ <li><h:link value="rich:select" outcome="select" /></li>
</ul>
<h:panelGrid columns="3">
@@ -55,7 +55,7 @@
<p>QUnit tests</p>
<ul>
- <li><h:commandLink value="rich:autocomplete qunit" action="qunit/autocomplete" /></li>
+ <li><h:link value="rich:autocomplete qunit" outcome="qunit/autocomplete" /></li>
</ul>
</h:form>
</td>
13 years, 2 months
JBoss Rich Faces SVN: r21375 - trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: artdaw
Date: 2011-02-01 14:04:38 -0500 (Tue, 01 Feb 2011)
New Revision: 21375
Modified:
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemHeaderRenderer.java
Log:
RF-10352: @itemLeftIconActive is fixed
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemHeaderRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemHeaderRenderer.java 2011-02-01 18:44:46 UTC (rev 21374)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemHeaderRenderer.java 2011-02-01 19:04:38 UTC (rev 21375)
@@ -23,7 +23,7 @@
String iconInactive = panel.isDisabled() ? panel.getLeftDisabledIcon() : panel.getLeftInactiveIcon();
String iconActive = panel.isDisabled() ? panel.getLeftDisabledIcon() : panel.getLeftActiveIcon();
- encodeTdIcon(writer, context, cssClassPrefix + "-ico", iconInactive, iconActive, panel.isDisabled() ? State.commonDisabled : State.common);
+ encodeTdIcon(writer, context, cssClassPrefix + "-ico", iconInactive, iconActive, panel.isDisabled() ? State.headerDisabled : State.header);
}
protected void encodeHeaderRightIcon(ResponseWriter writer, FacesContext context, AbstractAccordionItem panel) throws IOException {
13 years, 2 months
JBoss Rich Faces SVN: r21374 - in trunk/ui: common/ui/src/test/java/org/richfaces/component/util and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2011-02-01 13:44:46 -0500 (Tue, 01 Feb 2011)
New Revision: 21374
Modified:
trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
trunk/ui/common/ui/src/test/java/org/richfaces/component/util/SelectUtilsTest.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
Log:
https://issues.jboss.org/browse/RF-10131
Modified: trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java
===================================================================
--- trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2011-02-01 18:38:31 UTC (rev 21373)
+++ trunk/ui/common/ui/src/main/java/org/richfaces/component/util/SelectUtils.java 2011-02-01 18:44:46 UTC (rev 21374)
@@ -21,97 +21,279 @@
package org.richfaces.component.util;
-import org.richfaces.log.Logger;
-import org.richfaces.log.RichfacesLogger;
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
import javax.el.ValueExpression;
import javax.faces.application.ProjectStage;
-import javax.faces.component.*;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.UIOutput;
+import javax.faces.component.UISelectItem;
+import javax.faces.component.UISelectItems;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
-import java.util.*;
-import java.util.Map.Entry;
+import org.richfaces.log.Logger;
+import org.richfaces.log.RichfacesLogger;
+import org.richfaces.renderkit.util.RendererUtils;
+
+import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.Iterators;
+
/**
* @author Maksim Kaszynski
*/
public final class SelectUtils {
+
private static final Logger LOG = RichfacesLogger.APPLICATION.getLogger();
+ private static final class GenericObjectSelectItem extends SelectItem {
+
+ private static final RendererUtils UTILS = RendererUtils.getInstance();
+
+ private static final String VAR = "var";
+ private static final String ITEM_VALUE = "itemValue";
+ private static final String ITEM_LABEL = "itemLabel";
+ private static final String ITEM_DESCRIPTION = "itemDescription";
+ private static final String ITEM_ESCAPED = "itemLabelEscaped";
+ private static final String ITEM_DISABLED = "itemDisabled";
+ private static final String NO_SELECTION_OPTION = "noSelectionOption";
- private SelectUtils() {
+ private String var;
+
+ private UIComponent sourceComponent;
+
+ private GenericObjectSelectItem(UIComponent sourceComponent) {
+ this.var = (String) sourceComponent.getAttributes().get(VAR);
+ this.sourceComponent = sourceComponent;
+ }
+
+ private void updateItem(FacesContext facesContext, Object value) {
+
+ Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+ Object oldVarValue = null;
+ if (var != null) {
+ oldVarValue = requestMap.put(var, value);
+ }
+ try {
+ Map<String, Object> attrs = sourceComponent.getAttributes();
+ Object itemValueResult = attrs.get(ITEM_VALUE);
+ Object itemLabelResult = attrs.get(ITEM_LABEL);
+ Object itemDescriptionResult = attrs.get(ITEM_DESCRIPTION);
+
+ setValue(itemValueResult != null ? itemValueResult : value);
+ setLabel(itemLabelResult != null ? itemLabelResult.toString() : value.toString());
+ setDescription(itemDescriptionResult != null ? itemDescriptionResult.toString() : null);
+ setEscape(UTILS.isBooleanAttribute(sourceComponent, ITEM_ESCAPED));
+ setDisabled(UTILS.isBooleanAttribute(sourceComponent, ITEM_DISABLED));
+ setNoSelectionOption(UTILS.isBooleanAttribute(sourceComponent, NO_SELECTION_OPTION));
+ } finally {
+ if (var != null) {
+ if (oldVarValue != null) {
+ requestMap.put(var, oldVarValue);
+ } else {
+ requestMap.remove(var);
+ }
+ }
+ }
+
+ }
+
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ throw new NotSerializableException();
+ }
+
+ private void readObject(ObjectInputStream in) throws IOException {
+ throw new NotSerializableException();
+ }
+
+ }
+
+ private static final class MapItemsIterator extends AbstractIterator<SelectItem> {
+
+ private Iterator<?> data;
+
+ public MapItemsIterator(Map<?, ?> map) {
+ super();
+ this.data = map.entrySet().iterator();
+ }
+
+ @Override
+ protected SelectItem computeNext() {
+ if (data.hasNext()) {
+ Entry<?, ?> next = (Entry<?, ?>) data.next();
+
+ return new SelectItem(next.getValue(), next.getKey().toString());
+ }
+
+ return endOfData();
+ }
}
- /**
- * Gathers all select items from specified component's children
- *
- * @param context Faces context
- * @param component UIComponent with UISelectItem or UISelectItems children
- * @return list of {@link SelectItem} taken from f:selectItem and f:selectItems
- */
- @SuppressWarnings("unchecked")
- public static List<SelectItem> getSelectItems(FacesContext context, UIComponent component) {
- ArrayList<SelectItem> list = new ArrayList<SelectItem>();
+ private static final class GenericItemsIterator extends AbstractIterator<SelectItem> {
- for (UIComponent uiComponent : component.getChildren()) {
+ private FacesContext facesContext;
+
+ private UIComponent component;
+
+ private Iterator<?> data;
- if (uiComponent instanceof UISelectItem) {
- UISelectItem uiSelectItem = (UISelectItem) uiComponent;
- Object value = uiSelectItem.getValue();
+ private GenericObjectSelectItem genericItem;
+
+ public GenericItemsIterator(FacesContext facesContext, UIComponent component, Iterator<?> data) {
+ super();
+ this.facesContext = facesContext;
+ this.component = component;
+ this.data = data;
+ }
- if (value == null) {
- UISelectItem item = (UISelectItem) uiComponent;
- list.add(new SelectItem(item.getItemValue(), item.getItemLabel(), item.getItemDescription(),
- item.isItemDisabled(), item.isItemEscaped(), item.isNoSelectionOption()));
- } else if (value instanceof SelectItem) {
- list.add((SelectItem) value);
+ @Override
+ protected SelectItem computeNext() {
+ if (data.hasNext()) {
+ Object next = data.next();
+
+ if (next instanceof SelectItem) {
+ return (SelectItem) next;
} else {
- ValueExpression expression = uiSelectItem.getValueExpression("value");
- throw new IllegalArgumentException("ValueExpression '"
- + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
- + RichfacesLogger.getComponentPath(uiComponent) + " does not reference an Object of type SelectItem");
+ if (genericItem == null) {
+ genericItem = new GenericObjectSelectItem(component);
+ }
+
+ genericItem.updateItem(facesContext, next);
+
+ return genericItem;
}
- } else if ((uiComponent instanceof UISelectItems) && (null != context)) {
- UISelectItems currentUISelectItems = ((UISelectItems) uiComponent);
- Object value = currentUISelectItems.getValue();
+ }
+
+ return endOfData();
+ }
+
+ }
+
+ private static final class SelectItemsIterator extends AbstractIterator<SelectItem> {
- if (value instanceof SelectItem) {
- list.add((SelectItem) value);
- } else if (value instanceof SelectItem[]) {
- SelectItem[] items = (SelectItem[]) value;
- list.addAll(Arrays.asList(items));
- } else if (value instanceof Collection) {
- list.addAll((Collection<SelectItem>) value);
- } else if (value instanceof Map) {
- Map<Object, Object> map = (Map<Object, Object>) value;
- Set<Entry<Object, Object>> entrySet = map.entrySet();
- for (Entry<Object, Object> entry : entrySet) {
- list.add(new SelectItem(entry.getValue(), entry.getKey().toString(), null));
+ private Iterator<UIComponent> children;
+
+ private Iterator<SelectItem> items = Iterators.emptyIterator();
+
+ private FacesContext context;
+
+ public SelectItemsIterator(FacesContext context, Iterator<UIComponent> children) {
+ this.context = context;
+ this.children = children;
+ }
+
+ @Override
+ protected SelectItem computeNext() {
+ while (items.hasNext() || children.hasNext()) {
+ if (items.hasNext()) {
+ SelectItem nextItem = items.next();
+
+ if (!items.hasNext()) {
+ //free iterator
+ items = Iterators.emptyIterator();
}
+
+ return nextItem;
} else {
- Logger.Level level = Logger.Level.INFO;
- if (!context.isProjectStage(ProjectStage.Production)) {
- level = Logger.Level.WARNING;
- }
- if (LOG.isLogEnabled(level)) {
- ValueExpression expression = currentUISelectItems.getValueExpression("value");
- LOG.log(level, String.format("ValueExpression %s of UISelectItems with component-path %s"
- + " does not reference an Object of type SelectItem,"
- + " array, Iterable or Map, but of type: %s",
- (expression == null ? null : expression.getExpressionString()),
- RichfacesLogger.getComponentPath(uiComponent),
- (value == null ? null : value.getClass().getName())
- ));
- }
+ items = createIterator(children.next());
}
}
+
+ return endOfData();
}
+
+ private Iterator<SelectItem> createUISelectItemIterator(UISelectItem selectItem) {
+ Object value = selectItem.getValue();
- return list;
+ SelectItem result = null;
+
+ if (value == null) {
+ result = new SelectItem(selectItem.getItemValue(), selectItem.getItemLabel(), selectItem.getItemDescription(),
+ selectItem.isItemDisabled(), selectItem.isItemEscaped(), selectItem.isNoSelectionOption());
+ } else if (value instanceof SelectItem) {
+ result = (SelectItem) value;
+ } else {
+ ValueExpression expression = selectItem.getValueExpression("value");
+ throw new IllegalArgumentException("ValueExpression '"
+ + (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
+ + RichfacesLogger.getComponentPath(selectItem) + " does not reference an Object of type SelectItem");
+ }
+
+ return Iterators.singletonIterator(result);
+ }
+
+ private Iterator<SelectItem> createUISelectItemsIterator(UISelectItems selectItems) {
+ Object value = selectItems.getValue();
+
+ if (value == null) {
+ return Iterators.emptyIterator();
+ } else if (value instanceof SelectItem) {
+ return Iterators.singletonIterator((SelectItem) value);
+ } else if (value instanceof Object[]) {
+ Iterator<Object> data = Iterators.forArray((Object[]) value);
+ return new GenericItemsIterator(context, selectItems, data);
+ } else if (value instanceof Iterable<?>) {
+ Iterator<?> data = ((Iterable<?>) value).iterator();
+ return new GenericItemsIterator(context, selectItems, data);
+ } else if (value instanceof Map) {
+ return new MapItemsIterator((Map<?, ?>) value);
+ } else {
+ Logger.Level level = Logger.Level.INFO;
+ if (!context.isProjectStage(ProjectStage.Production)) {
+ level = Logger.Level.WARNING;
+ }
+ if (LOG.isLogEnabled(level)) {
+ ValueExpression expression = selectItems.getValueExpression("value");
+ LOG.log(level, String.format("ValueExpression %s of UISelectItems with component-path %s"
+ + " does not reference an Object of type SelectItem,"
+ + " array, Iterable or Map, but of type: %s",
+ (expression == null ? null : expression.getExpressionString()),
+ RichfacesLogger.getComponentPath(selectItems),
+ (value == null ? null : value.getClass().getName())
+ ));
+ }
+ }
+
+ return Iterators.emptyIterator();
+ }
+
+ private Iterator<SelectItem> createIterator(UIComponent child) {
+ if (!child.isRendered()) {
+ return Iterators.emptyIterator();
+ }
+
+ if (child instanceof UISelectItem) {
+ return createUISelectItemIterator((UISelectItem) child);
+ } else if (child instanceof UISelectItems) {
+ return createUISelectItemsIterator((UISelectItems) child);
+ }
+
+ return Iterators.emptyIterator();
+ }
+ }
+ private SelectUtils() {
}
+ /**
+ * Gathers all select items from specified component's children
+ *
+ * @param context Faces context
+ * @param component UIComponent with UISelectItem or UISelectItems children
+ * @return list of {@link SelectItem} taken from f:selectItem and f:selectItems
+ */
+ public static Iterator<SelectItem> getSelectItems(FacesContext context, UIComponent component) {
+ return new SelectItemsIterator(context, component.getChildren().iterator());
+ }
+
public static Object getConvertedUIInputValue(FacesContext facesContext, UIInput component, String submittedValue) throws ConverterException {
if (InputUtils.EMPTY_STRING.equals(submittedValue)) {
return null;
Modified: trunk/ui/common/ui/src/test/java/org/richfaces/component/util/SelectUtilsTest.java
===================================================================
--- trunk/ui/common/ui/src/test/java/org/richfaces/component/util/SelectUtilsTest.java 2011-02-01 18:38:31 UTC (rev 21373)
+++ trunk/ui/common/ui/src/test/java/org/richfaces/component/util/SelectUtilsTest.java 2011-02-01 18:44:46 UTC (rev 21374)
@@ -1,14 +1,19 @@
package org.richfaces.component.util;
-import org.jboss.test.faces.AbstractFacesTest;
-import org.junit.Assert;
+import java.util.Iterator;
+import java.util.List;
import javax.faces.component.UIParameter;
import javax.faces.component.UISelectItem;
import javax.faces.component.UISelectOne;
import javax.faces.model.SelectItem;
-import java.util.List;
+import org.jboss.test.faces.AbstractFacesTest;
+import org.junit.Assert;
+
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+
/**
* @author Gleb Galkin
* @since 27.01.11
@@ -26,6 +31,13 @@
super.tearDown();
}
+
+ private static final <T> List<T> asList(Iterator<T> itr) {
+ List<T> result = Lists.newArrayList();
+ Iterators.addAll(result, itr);
+ return result;
+ }
+
/**
* The aim of this test is to check first part of {@link SelectUtils#getSelectItems}, for {@link UISelectOne}
*/
@@ -44,14 +56,14 @@
param.setValue("paramValue");
selectOne.getChildren().add(param);
- checkSelectItems(SelectUtils.getSelectItems(facesContext, selectOne));
+ checkSelectItems(asList(SelectUtils.getSelectItems(facesContext, selectOne)));
// non select item in middle
selectOne = new UISelectOne();
selectOne.getChildren().add(new UISelectItemStub("value1", "label1", "description1", false, false, false));
selectOne.getChildren().add(param);
selectOne.getChildren().add(new UISelectItemStub("value2", "label2", "description2", false, true, true));
- checkTwoSelectItems(SelectUtils.getSelectItems(facesContext, selectOne));
+ checkTwoSelectItems(asList(SelectUtils.getSelectItems(facesContext, selectOne)));
// non select item as value cause IllegalArgumentException
item = new UISelectItem();
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2011-02-01 18:38:31 UTC (rev 21373)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectHelper.java 2011-02-01 18:44:46 UTC (rev 21374)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -93,10 +94,12 @@
public static List<ClientSelectItem> getConvertedSelectItems(FacesContext facesContext, UIComponent component) {
AbstractSelectComponent select = (AbstractSelectComponent) component;
- List<SelectItem> selectItems = SelectUtils.getSelectItems(facesContext, select);
+ Iterator<SelectItem> selectItems = SelectUtils.getSelectItems(facesContext, select);
List<ClientSelectItem> clientSelectItems = new ArrayList<ClientSelectItem>();
- for (SelectItem selectItem : selectItems) {
+ while (selectItems.hasNext()) {
+ SelectItem selectItem = selectItems.next();
+
String convertedStringValue = InputUtils.getConvertedStringValue(facesContext, select, selectItem.getValue());
String label = selectItem.getLabel();
clientSelectItems.add(new ClientSelectItem(convertedStringValue,label));
@@ -139,9 +142,12 @@
if (value == null) {
value = select.getValue();
if (value != null) {
- List<SelectItem> items = SelectUtils.getSelectItems(
+ Iterator<SelectItem> items = SelectUtils.getSelectItems(
facesContext, component);
- for (SelectItem item : items) {
+
+ while (items.hasNext()) {
+ SelectItem item = items.next();
+
if (value.equals(item.getValue())) {
label = item.getLabel();
}
13 years, 2 months