JBoss Rich Faces SVN: r14948 - branches/community/3.3.X/ui/panelmenu/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2009-07-17 09:31:31 -0400 (Fri, 17 Jul 2009)
New Revision: 14948
Modified:
branches/community/3.3.X/ui/panelmenu/src/main/config/component/panelMenu.xml
Log:
https://jira.jboss.org/jira/browse/RF-7461 attribute description is corrected
Modified: branches/community/3.3.X/ui/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- branches/community/3.3.X/ui/panelmenu/src/main/config/component/panelMenu.xml 2009-07-17 12:33:40 UTC (rev 14947)
+++ branches/community/3.3.X/ui/panelmenu/src/main/config/component/panelMenu.xml 2009-07-17 13:31:31 UTC (rev 14948)
@@ -41,7 +41,7 @@
<name>mode</name>
<classname>java.lang.String</classname>
<description> Set the submission mode for all panel menu items on the panel menu except
- ones where this attribute redefined. Possible values are "ajax", "server", "none". Default value is "server".</description>
+ ones where this attribute redefined. Possible values are "ajax", "server", "server". Default value is "server".</description>
<defaultvalue><![CDATA["server"]]></defaultvalue>
</property>
<property>
@@ -423,35 +423,35 @@
You can also use predefined icons, setting the attribute to one of these possible values: "triangle", "triangleUp", "triangleDown", "disc", "chevron", "chevronUp", "chevronDown", "grid".
Default value is "grid".</description>
<defaultvalue><![CDATA["grid"]]></defaultvalue>
- </property>
- <property hidden="true">
- <name>accesskey</name>
- <classname>java.lang.String</classname>
- <description></description>
- </property>
- <property hidden="true">
- <name>maxlength</name>
- <classname>int</classname>
- <description>Specifies the maximum number of digits that could be entered into the input field.
- The maximum number is unlimited by default.
- </description>
</property>
+ <property hidden="true">
+ <name>accesskey</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ </property>
+ <property hidden="true">
+ <name>maxlength</name>
+ <classname>int</classname>
+ <description>Specifies the maximum number of digits that could be entered into the input field.
+ The maximum number is unlimited by default.
+ </description>
+ </property>
<property>
<name>expanded</name>
<classname>boolean</classname>
<description>If true group will be displayed expanded initially. Default value is "false".</description>
<defaultvalue>false</defaultvalue>
- </property>
- <property hidden="true">
- <name>size</name>
- <classname>int</classname>
- <description>This attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters</description>
- </property>
- <property hidden="true">
- <name>tabindex</name>
- <classname>int</classname>
- <description>Serves to define the tabbing order</description>
</property>
+ <property hidden="true">
+ <name>size</name>
+ <classname>int</classname>
+ <description>This attribute tells the user agent the initial width of the control. The width is given in pixels except when type attribute has the value "text" or "password". In that case, its value refers to the (integer) number of characters</description>
+ </property>
+ <property hidden="true">
+ <name>tabindex</name>
+ <classname>int</classname>
+ <description>Serves to define the tabbing order</description>
+ </property>
<property>
<name>iconDisabled</name>
<classname>java.lang.String</classname>
15 years, 2 months
JBoss Rich Faces SVN: r14947 - branches/community/3.3.X/docs/userguide/en/src/main/docbook/included.
by richfaces-svn-commits@lists.jboss.org
Author: atsebro
Date: 2009-07-17 08:33:40 -0400 (Fri, 17 Jul 2009)
New Revision: 14947
Modified:
branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/poll.xml
Log:
RF-7512:a4j:poll component description review
Modified: branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/poll.xml
===================================================================
--- branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/poll.xml 2009-07-17 09:48:42 UTC (rev 14946)
+++ branches/community/3.3.X/docs/userguide/en/src/main/docbook/included/poll.xml 2009-07-17 12:33:40 UTC (rev 14947)
@@ -1,48 +1,44 @@
<?xml version='1.0' encoding='UTF-8'?>
<chapter>
- <chapterinfo>
- <keywordset>
- <keyword>a4j:poll</keyword>
- </keywordset>
- </chapterinfo>
- <table>
- <title>Component identification parameters </title>
- <tgroup cols="2">
- <thead>
- <row>
- <entry>Name</entry>
- <entry>Value</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>component-type</entry>
- <entry>org.ajax4jsf.Poll</entry>
- </row>
- <row>
- <entry>component-family</entry>
- <entry>org.ajax4jsf.components.AjaxPoll</entry>
- </row>
- <row>
- <entry>component-class</entry>
- <entry>org.ajax4jsf.component.html.AjaxPoll</entry>
- </row>
- <row>
- <entry>renderer-type</entry>
- <entry>org.ajax4jsf.components.AjaxPollRenderer</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <chapterinfo>
+ <keywordset>
+ <keyword>a4j:poll</keyword>
+ </keywordset>
+ </chapterinfo>
+ <table>
+ <title>Component identification parameters</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Value</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>component-type</entry>
+ <entry>org.ajax4jsf.Poll</entry>
+ </row>
+ <row>
+ <entry>component-family</entry>
+ <entry>org.ajax4jsf.components.AjaxPoll</entry>
+ </row>
+ <row>
+ <entry>component-class</entry>
+ <entry>org.ajax4jsf.component.html.AjaxPoll</entry>
+ </row>
+ <row>
+ <entry>renderer-type</entry>
+ <entry>org.ajax4jsf.components.AjaxPollRenderer</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
- <section>
- <title>Creating on a page</title>
- <para id="creating">To create the simplest variant on a page use the following syntax:</para>
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
- <programlisting role="XML"><![CDATA[<a4j:poll interval="500" reRender="grid"/>
+ <section>
+ <title>Creating the component with a Page Tag</title>
+ <para id="creating">To create the simplest variant on a page use the following syntax:</para>
+ <programlisting role="XML"><![CDATA[<a4j:poll interval="500" reRender="grid"/>
]]></programlisting>
<!--para>The <emphasis role="bold">
<property><a4j:poll></property>
@@ -50,56 +46,41 @@
performs the corresponding action and renders a components with the <emphasis>
<property>"someDataTable"</property>
</emphasis> id after a response comes back.</para-->
- </section>
- <section>
- <title>Creating the Component Dynamically Using Java</title>
-
- <para>
- <emphasis role="bold">Example:</emphasis>
- </para>
- <programlisting role="JAVA"><![CDATA[import org.ajax4jsf.component.html.AjaxPoll;
+ </section>
+ <section>
+ <title>Creating the Component Dynamically Using Java</title>
+ <para>
+ <emphasis role="bold">Example:</emphasis>
+ </para>
+ <programlisting role="JAVA"><![CDATA[import org.ajax4jsf.component.html.AjaxPoll;
...
AjaxPoll myPoll = new AjaxPoll();
...]]></programlisting>
- </section>
- <section>
- <title>Key attributes and ways of usage</title>
- <para id="attributes">The <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> componet is used for periodical polling of server data. In order to use the component
- it's necessary to set an update interval. The <emphasis>
- <property>"interval"</property>
- </emphasis> attribute defines an interval in milliseconds between the previous
- response and the next request. The total period beetween two requests generated by the
- <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> component is a sum of an<emphasis>
- <property>"interval"</property>
- </emphasis> attribute value and server response time. Default value for <emphasis>
- <property>"interval"</property>
- </emphasis> attribute is set to "1000" milliseconds (1 second). See an example of definition in
- the <link linkend="creating">"Creating on a page" section</link>. </para>
- <para>The <emphasis>
- <property>"timeout"</property>
- </emphasis> attribute defines response waiting time in milliseconds. If a response
- isn't received during this period a connection is aborted and the next request is
- sent. Default value for <emphasis>
- <property>"timeout"</property>
- </emphasis> attribute isn't set.</para>
- <para>The <emphasis>
- <property>"enabled"</property>
- </emphasis> attribute defines should the <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> send request or not. It's necessary to render the
- <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> to apply the current value of <emphasis>
- <property>"enabled"</property>
- </emphasis> attribute. You can use an EL-expression for <emphasis>
- <property>"enabled"</property>
- </emphasis> attribute to point to a bean property. An example of usage of <link
- linkend="attributes">mentioned above attributes</link> is placed below:</para>
+ </section>
+
+ <section>
+ <title>Details of usage</title>
+ <para id="attributes">
+ The <emphasis role="bold"><property><a4j:poll></property></emphasis> componet is used for periodical polling of server data.
+ In order to use the component it's necessary to set an update interval.
+ The <emphasis><property>"interval"</property></emphasis> attribute defines an interval in milliseconds between the previous response and the next request.
+ The total period beetween two requests generated by the <emphasis role="bold"><property><a4j:poll></property></emphasis> component is a sum of an<emphasis><property>"interval"</property></emphasis> attribute value and server response time.
+ Default value for <emphasis><property>"interval"</property></emphasis> attribute is set to "1000" milliseconds (1 second).
+ See an example of definition in the "<link linkend="creating">Creating the component with a Page Tag</link>" section.
+ </para>
+ <para>
+ The <emphasis><property>"timeout"</property></emphasis> attribute defines response waiting time in milliseconds.
+ If a response isn't received during this period a connection is aborted and the next request is sent.
+ Default value for <emphasis><property>"timeout"</property></emphasis> attribute isn't set.
+ </para>
+
+ <para>
+ The <emphasis><property>"enabled"</property></emphasis> attribute defines should the <emphasis role="bold"><property><a4j:poll></property></emphasis> send request or not.
+ It's necessary to render the <emphasis role="bold"><property><a4j:poll></property></emphasis> to apply the current value of <emphasis><property>"enabled"</property></emphasis> attribute.
+ You can use an EL-expression for <emphasis><property>"enabled"</property></emphasis> attribute to point to a bean property.
+ An example of usage of mentioned above attributes is placed below:
+ </para>
<para>
<emphasis role="bold">Example:</emphasis>
</para>
@@ -115,11 +96,8 @@
<h:panelGrid columns="1">
<h:outputText value="Polling Inactive" rendered="#{not userBean.pollEnabled}" />
<h:outputText value="Polling Active" rendered="#{userBean.pollEnabled}" />
- <a4j:commandButton style="width:120px" id="control"
- value="#{userBean.pollEnabled?'Stop':'Start'} Polling"
- reRender="poll, grid">
- <a4j:actionparam name="polling" value="#{!userBean.pollEnabled}"
- assignTo="#{userBean.pollEnabled}"/>
+ <a4j:commandButton style="width:120px" id="control" value="#{userBean.pollEnabled?'Stop':'Start'} Polling" reRender="poll, grid">
+ <a4j:actionparam name="polling" value="#{!userBean.pollEnabled}" assignTo="#{userBean.pollEnabled}"/>
</a4j:commandButton>
</h:panelGrid>
<h:outputText id="serverDate" style="font-size:16px" value="Server Date: #{userBean.date}"/>
@@ -127,29 +105,32 @@
</h:form>
...]]></programlisting>
- <para>The example shows how date and time are updated on a page in compliance with data taken
- from a server. The <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> componet sends requests to the server every second. <emphasis>
- <property>"reRender"</property>
- </emphasis> attribute for <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> contains value of its own Id. Hence, it renders itself for applying the current value
- of <emphasis>
- <property>"enabled"</property>
- </emphasis> attribute.</para>
+ <para>
+ The example shows how date and time are updated on a page in compliance with data taken from a server.
+ The <emphasis role="bold"><property><a4j:poll></property></emphasis> componet sends requests to the server every second.
+ <emphasis><property>"reRender"</property></emphasis> attribute of the <emphasis role="bold"><property><a4j:poll></property></emphasis> contains poll's own <code>Id</code>.
+ Hence, it is self rendered for applying the current value of <emphasis><property>"enabled"</property></emphasis> attribute.
+ </para>
- <note><title>Note:</title><para> The form around the <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> component is required.</para></note>
-
+
<note>
- <title>Note:</title>
- <para>To make the <emphasis role="bold"><property><a4j:poll></property></emphasis> component
- send requests periodically when it <code>limitToList</code> is set to "true", pass the
- <emphasis role="bold"><property><a4j:poll></property></emphasis> ID to it <code>reRender</code> attribute.
- </para>
- </note>
+ <title>Notes:</title>
+ <itemizedlist>
+ <listitem>
+ <para>
+ The form around the <emphasis role="bold"><property><a4j:poll></property></emphasis> component is required.
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>
+ To make the <emphasis role="bold"><property><a4j:poll></property></emphasis> component send requests periodically when it <code>limitToList</code> is set to "true",
+ pass the <emphasis role="bold"><property><a4j:poll></property></emphasis> ID to it <code>reRender</code> attribute.
+ </para>
+ </listitem>
+
+ </itemizedlist>
+ </note>
<!--para>The component decodes all necessary JavaScript for time count and on the expiry of some
interval for calling of a RichFaces utility method for Ajax request sending (A4J.AJAX.Submit
@@ -173,64 +154,43 @@
<ulink url="index.html#support"><a4j:support></ulink>
</property>
</emphasis> component description. </para-->
- <para>
- Information about the <emphasis><property>"process"</property></emphasis> attribute usage you can find <link linkend="process">" Decide what to process " </link> guide section.
- </para>
+ <para>
+ Information about the <emphasis><property>"process"</property></emphasis> attribute usage you can find "<link linkend="process">Decide what to process</link>" guide section.
+ </para>
</section>
- <section>
- <title>Relevant resources links</title>
- <para>In
- <ulink
- url="http://wiki.jboss.org/wiki/CreateABannerUsingEffectsAndPoll">
- RichFaces Wiki article "Creating a Banner Using Effects and Poll"
- </ulink>
- you can get additional information how to create an image
- banner using
- <emphasis role="bold">
- <property><rich:effect></property>
- </emphasis>
- and
- <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis>
- components and also you can figure out how to create an HTML banner in
- <ulink
- url="http://wiki.jboss.org/auth/wiki/CreateAHTMLBannerUsingEffectsAndPoll">
- RichFaces Wiki article "Creating an HTML Banner Using Effects and Poll"
- </ulink>
- .
- </para>
- <para>In
- <ulink url="http://wiki.jboss.org/auth/wiki/RichFacesCookbook/SlideShow">RichFaces Cookbook article on Slide Show"</ulink>
- you can find information how to make a Slide Show with help of the
- <emphasis role="bold">
- <property><rich:effect></property></emphasis>
- and <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis> components.
- </para>
- <para>On
- <ulink
- url="http://livedemo.exadel.com/richfaces-demo/richfaces/poll.jsf?c=poll">
- RichFaces Live Demo page
- </ulink>
- you can see the example of
- <emphasis role="bold">
- <property><a4j:poll></property>
- </emphasis>
- usage and sources for the given example.
- </para>
- <para>
- The additional information about component usage you can find
- in
- <ulink
- url="http://jboss.com/index.html?module=bb&op=viewtopic&t=103909">
- RichFaces Users Forum
- </ulink>
- .
- </para>
+
+ <section>
+ <title>Relevant resources links</title>
+ <para>
+ Vizit the <ulink url="http://livedemo.exadel.com/richfaces-demo/richfaces/poll.jsf?c=poll">Poll page</ulink> at RichFaces LiveDemo for examples of the component usage and their sources.
+ </para>
+
+ <para>
+ Useful examples and articles:
+ </para>
+ <itemizedlist>
+ <listitem>
+ <para>
+ "<ulink url="http://www.jboss.org/community/wiki/CreateABannerUsingEffectsAndPoll">Create a Banner Using Effects and Poll</ulink>" article at RichFaces Wiki
+ gives an example of how to create an image banner using <emphasis role="bold"><property><rich:effect></property></emphasis> and <emphasis role="bold"><property><a4j:poll></property></emphasis>components;
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ "<ulink url="http://www.jboss.org/community/wiki/CreateAHTMLBannerUsingEffectsAndPoll">Create an HTML Banner Using Effects and Poll</ulink>" article at RichFaces Wiki
+ brings the code of the way of creating an HTML banner banner using <emphasis role="bold"><property><rich:effect></property></emphasis> and <emphasis role="bold"><property><a4j:poll></property></emphasis>components;
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ "<ulink url="http://www.jboss.org/index.html?module=bb&op=viewtopic&t=125621">RichFaces and Slideshow</ulink>" thread in the RichFaces users forum contains an information and code on making a Slide Show with the help of the <emphasis role="bold"><property><a4j:poll></property></emphasis> component;
+ </para>
+ </listitem>
+ </itemizedlist>
+ <para>
+ Manage the <ulink url="http://jboss.com/index.html?module=bb&op=viewtopic&t=103909">RichFaces Users Forum</ulink> for fresh issues about the component usage.
+ </para>
+ </section>
- </section>
-
</chapter>
15 years, 2 months
JBoss Rich Faces SVN: r14946 - branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-07-17 05:48:42 -0400 (Fri, 17 Jul 2009)
New Revision: 14946
Modified:
branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/ConvertedSelectItem.java
branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
Log:
rich:pickList does not html encode ampersand
https://jira.jboss.org/jira/browse/RF-7521
Modified: branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/ConvertedSelectItem.java
===================================================================
--- branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/ConvertedSelectItem.java 2009-07-17 08:33:11 UTC (rev 14945)
+++ branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/ConvertedSelectItem.java 2009-07-17 09:48:42 UTC (rev 14946)
@@ -25,6 +25,7 @@
import javax.faces.model.SelectItem;
import org.richfaces.component.UIPickList;
+import org.richfaces.json.XML;
public class ConvertedSelectItem {
private SelectItem item;
Modified: branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java
===================================================================
--- branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2009-07-17 08:33:11 UTC (rev 14945)
+++ branches/community/3.3.X/ui/pickList/src/main/java/org/richfaces/renderkit/PickListRenderer.java 2009-07-17 09:48:42 UTC (rev 14946)
@@ -54,96 +54,104 @@
import org.apache.commons.logging.LogFactory;
import org.richfaces.component.UIPickList;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.json.XML;
public class PickListRenderer extends HeaderResourcesRendererBase {
-
- private static Log logger = LogFactory.getLog(PickListRenderer.class);
-
- private static final String HIDDEN_SUFFIX = "valueKeeper";
-
- private static final String MESSAGE_BUNDLE_NAME = PickListRenderer.class.getPackage().getName() + ".pickList";
+ private static Log logger = LogFactory.getLog(PickListRenderer.class);
+
+ private static final String HIDDEN_SUFFIX = "valueKeeper";
+
+ private static final String MESSAGE_BUNDLE_NAME = PickListRenderer.class
+ .getPackage().getName()
+ + ".pickList";
+
private static final String SHOW_LABELS_ATTRIBUTE_NAME = "showButtonsLabel";
private static final OrderingComponentRendererBase.ControlsHelper[] SHUTTLE_HELPERS = PickListControlsHelper.HELPERS;
protected static final class ListStateFlags {
- public ListStateFlags() {
- super();
- }
-
- protected boolean isSelectedList;
-
- protected boolean isAvailableList;
+ public ListStateFlags() {
+ super();
+ }
+
+ protected boolean isSelectedList;
+
+ protected boolean isAvailableList;
}
- protected List<ConvertedSelectItem> selectItemsForSelectedList(List<ConvertedSelectItem> selectItems) {
- List<ConvertedSelectItem> result = new ArrayList<ConvertedSelectItem>();
-
- for (ConvertedSelectItem selectItem: selectItems) {
- if (selectItem.isSelected()) {
- result.add(selectItem);
- }
- }
-
- return result;
+ protected List<ConvertedSelectItem> selectItemsForSelectedList(
+ List<ConvertedSelectItem> selectItems) {
+ List<ConvertedSelectItem> result = new ArrayList<ConvertedSelectItem>();
+
+ for (ConvertedSelectItem selectItem : selectItems) {
+ if (selectItem.isSelected()) {
+ result.add(selectItem);
+ }
+ }
+
+ return result;
}
protected List<Object> getValuesList(UIPickList pickList) {
- List <Object> valuesList = new ArrayList<Object>();
-
- Object value = getCurrentValue(FacesContext.getCurrentInstance(), pickList);
-
- if(null == value || "".equals(value)) {
- return valuesList;
- }
-
- if(value.getClass().isArray()) {
- int len = Array.getLength(value);
-
- for (int i = 0; i < len; i++) {
-
- Object localValue = Array.get(value, i);
- if(localValue != null) {
- valuesList.add(localValue);
- }
- }
-
- return valuesList;
- } else if(value instanceof List) {
- valuesList.addAll((List<?>)value);
-
- return valuesList;
- } else {
- throw new IllegalArgumentException("Error: value of UIPickList component is not of type Array or List");
- }
-
+ List<Object> valuesList = new ArrayList<Object>();
+
+ Object value = getCurrentValue(FacesContext.getCurrentInstance(),
+ pickList);
+
+ if (null == value || "".equals(value)) {
+ return valuesList;
+ }
+
+ if (value.getClass().isArray()) {
+ int len = Array.getLength(value);
+
+ for (int i = 0; i < len; i++) {
+
+ Object localValue = Array.get(value, i);
+ if (localValue != null) {
+ valuesList.add(localValue);
+ }
+ }
+
+ return valuesList;
+ } else if (value instanceof List) {
+ valuesList.addAll((List<?>) value);
+
+ return valuesList;
+ } else {
+ throw new IllegalArgumentException(
+ "Error: value of UIPickList component is not of type Array or List");
+ }
+
}
-
+
/**
- * @param context the FacesContext for the current request
- * @param component the UIComponent whose value we're interested in
- *
+ * @param context
+ * the FacesContext for the current request
+ * @param component
+ * the UIComponent whose value we're interested in
+ *
* @return the value to be rendered and formats it if required. Sets to
- * empty string if value is null.
+ * empty string if value is null.
*/
- protected Object getCurrentValue(FacesContext context,
- UIComponent component) {
-
+ protected Object getCurrentValue(FacesContext context, UIComponent component) {
+
if (component instanceof UIInput) {
Object submittedValue = ((UIInput) component).getSubmittedValue();
if (submittedValue != null) {
return submittedValue;
}
}
-
- return ((UIPickList)component).getValue();
+
+ return ((UIPickList) component).getValue();
}
- protected List<ConvertedSelectItem> selectItemsForAvailableList(List<ConvertedSelectItem> selectItems) {
+ protected List<ConvertedSelectItem> selectItemsForAvailableList(
+ List<ConvertedSelectItem> selectItems) {
List<ConvertedSelectItem> result = new ArrayList<ConvertedSelectItem>();
- for (ConvertedSelectItem selectItem: selectItems) {
+ for (ConvertedSelectItem selectItem : selectItems) {
if (!selectItem.isSelected()) {
result.add(selectItem);
}
@@ -151,313 +159,366 @@
return result;
}
-
- protected List <SelectItem> getSelectItemsList(FacesContext context, UIComponent component) {
- return SelectUtils.getSelectItems(context, component);
+
+ protected List<SelectItem> getSelectItemsList(FacesContext context,
+ UIComponent component) {
+ return SelectUtils.getSelectItems(context, component);
}
-
+
public PickListRenderer() {
- super();
+ super();
}
-
+
public void decode(FacesContext context, UIComponent component) {
-
- UIPickList picklist = (UIPickList) component;
- if (!(picklist instanceof EditableValueHolder)) {
- throw new IllegalArgumentException("Component " + picklist.getClientId(context) + " is not an EditableValueHolder");
- }
-
- String hiddenClientId = picklist.getClientId(context) + HIDDEN_SUFFIX;
- Map <String, String> paramMap = context.getExternalContext().getRequestParameterMap();
-
- if (picklist.isDisabled()) {
- return;
- }
-
- String value = paramMap.get(hiddenClientId);
- if (value != null) {
- if (value.trim().equals("")) {
-
- ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
-
- } else {
- String[] reqValues = value.split(",");
- ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
- }
-
- } else {
- ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
- }
-
+
+ UIPickList picklist = (UIPickList) component;
+ if (!(picklist instanceof EditableValueHolder)) {
+ throw new IllegalArgumentException("Component "
+ + picklist.getClientId(context)
+ + " is not an EditableValueHolder");
+ }
+
+ String hiddenClientId = picklist.getClientId(context) + HIDDEN_SUFFIX;
+ Map<String, String> paramMap = context.getExternalContext()
+ .getRequestParameterMap();
+
+ if (picklist.isDisabled()) {
+ return;
+ }
+
+ String value = paramMap.get(hiddenClientId);
+ if (value != null) {
+ if (value.trim().equals("")) {
+
+ ((EditableValueHolder) picklist)
+ .setSubmittedValue(new String[] {});
+
+ } else {
+ String[] reqValues = value.split(",");
+ ((EditableValueHolder) picklist).setSubmittedValue(reqValues);
+ }
+
+ } else {
+ ((EditableValueHolder) picklist).setSubmittedValue(new String[] {});
+ }
+
}
-
+
private static boolean isTrue(Object obj) {
- if (!(obj instanceof Boolean)) {
- return false;
- }
-
- return ((Boolean) obj).booleanValue();
-
+ if (!(obj instanceof Boolean)) {
+ return false;
+ }
+
+ return ((Boolean) obj).booleanValue();
+
}
-
+
@Override
- public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
-
- Object convertedValue = null;
-
- if(component instanceof UIPickList) {
- UIPickList pickList = (UIPickList)component;
- convertedValue = SelectUtils.getConvertedUISelectManyValue(context, pickList, (String[]) submittedValue);
- }
-
- return convertedValue;
+ public Object getConvertedValue(FacesContext context,
+ UIComponent component, Object submittedValue)
+ throws ConverterException {
+
+ Object convertedValue = null;
+
+ if (component instanceof UIPickList) {
+ UIPickList pickList = (UIPickList) component;
+ convertedValue = SelectUtils.getConvertedUISelectManyValue(context,
+ pickList, (String[]) submittedValue);
+ }
+
+ return convertedValue;
}
- private void encodeRows(FacesContext context, UIPickList pickList, boolean source, ListStateFlags flags, List<ConvertedSelectItem> selectItemList) throws IOException {
- for (ConvertedSelectItem item : selectItemList) {
- encodeItem(context, pickList, item, source);
- }
+ private void encodeRows(FacesContext context, UIPickList pickList,
+ boolean source, ListStateFlags flags,
+ List<ConvertedSelectItem> selectItemList) throws IOException {
+ for (ConvertedSelectItem item : selectItemList) {
+ encodeItem(context, pickList, item, source);
+ }
}
-
- public void encodeItem(FacesContext context, UIComponent component, ConvertedSelectItem selectItem, boolean source)
- throws IOException {
-
- ResponseWriter writer = context.getResponseWriter();
- writer.startElement(HTML.TR_ELEMENT, component);
-
- String clientId = component.getClientId(context);
-
- if (source) {
- clientId += ":source:";
- }
-
- String id = clientId + ":" + selectItem.getSuffix();
- writer.writeAttribute("id", id, null);
-
- StringBuffer rowClassName = new StringBuffer();
- StringBuffer cellClassName = new StringBuffer();
-
- if (source) {
- rowClassName.append("rich-picklist-source-row");
- cellClassName.append("rich-picklist-source-cell");
- } else {
- rowClassName.append("rich-picklist-target-row");
- cellClassName.append("rich-picklist-target-cell");
- }
-
- writer.writeAttribute("class", rowClassName.toString(), null);
- writer.startElement(HTML.td_ELEM, component);
- writer.writeAttribute(HTML.class_ATTRIBUTE, cellClassName, null);
-
- Object width = component.getAttributes().get("width");
- if (width != null) {
- writer.writeAttribute("style", "width: " + HtmlUtil.qualifySize(width.toString()), null);
- }
-
- encodeSpacer(context, component, writer);
-
- boolean escape = isTrue(component.getAttributes().get("escape"));
- if (escape) {
- writer.writeText(selectItem.getItem().getLabel(), null);
- } else {
- writer.write(selectItem.getItem().getLabel());
- }
- encodeItemValue(context, component, writer, id, selectItem.getConvertedValue());
-
- writer.endElement(HTML.td_ELEM);
- writer.endElement(HTML.TR_ELEMENT);
+
+ public void encodeItem(FacesContext context, UIComponent component,
+ ConvertedSelectItem selectItem, boolean source) throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.TR_ELEMENT, component);
+
+ String clientId = component.getClientId(context);
+
+ if (source) {
+ clientId += ":source:";
+ }
+
+ String id = clientId + ":" + selectItem.getSuffix();
+ writer.writeAttribute("id", id, null);
+
+ StringBuffer rowClassName = new StringBuffer();
+ StringBuffer cellClassName = new StringBuffer();
+
+ if (source) {
+ rowClassName.append("rich-picklist-source-row");
+ cellClassName.append("rich-picklist-source-cell");
+ } else {
+ rowClassName.append("rich-picklist-target-row");
+ cellClassName.append("rich-picklist-target-cell");
+ }
+
+ writer.writeAttribute("class", rowClassName.toString(), null);
+ writer.startElement(HTML.td_ELEM, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, cellClassName, null);
+
+ Object width = component.getAttributes().get("width");
+ if (width != null) {
+ writer.writeAttribute("style", "width: "
+ + HtmlUtil.qualifySize(width.toString()), null);
+ }
+
+ encodeSpacer(context, component, writer);
+
+ boolean escape = isTrue(component.getAttributes().get("escape"));
+ if (escape) {
+ writer.writeText(selectItem.getItem().getLabel(), null);
+ } else {
+ writer.write(XML.escape(selectItem.getItem().getLabel()));
+ }
+ encodeItemValue(context, component, writer, id, selectItem
+ .getConvertedValue());
+
+ writer.endElement(HTML.td_ELEM);
+ writer.endElement(HTML.TR_ELEMENT);
}
-
- public void encodeTargetRows(FacesContext context, UIPickList pickList, ListStateFlags flags, List<ConvertedSelectItem> convertedItems) throws IOException {
- List<ConvertedSelectItem> selectItemsForSelectedValues =
- selectItemsForSelectedList(convertedItems);
+
+ public void encodeTargetRows(FacesContext context, UIPickList pickList,
+ ListStateFlags flags, List<ConvertedSelectItem> convertedItems)
+ throws IOException {
+ List<ConvertedSelectItem> selectItemsForSelectedValues = selectItemsForSelectedList(convertedItems);
flags.isSelectedList = !selectItemsForSelectedValues.isEmpty();
- flags.isAvailableList = selectItemsForSelectedValues.size() != convertedItems.size();
+ flags.isAvailableList = selectItemsForSelectedValues.size() != convertedItems
+ .size();
- encodeRows(context, pickList, false, flags, selectItemsForSelectedValues);
+ encodeRows(context, pickList, false, flags,
+ selectItemsForSelectedValues);
}
-
- public void encodeSourceRows(FacesContext context, UIPickList pickList, ListStateFlags flags, List<ConvertedSelectItem> convertedItems) throws IOException {
- List<ConvertedSelectItem> selectItemsForAvailableList =
- selectItemsForAvailableList(convertedItems);
-
- flags.isSelectedList = selectItemsForAvailableList.size() != convertedItems.size();
+
+ public void encodeSourceRows(FacesContext context, UIPickList pickList,
+ ListStateFlags flags, List<ConvertedSelectItem> convertedItems)
+ throws IOException {
+ List<ConvertedSelectItem> selectItemsForAvailableList = selectItemsForAvailableList(convertedItems);
+
+ flags.isSelectedList = selectItemsForAvailableList.size() != convertedItems
+ .size();
flags.isAvailableList = !selectItemsForAvailableList.isEmpty();
- encodeRows(context, pickList, true, flags, selectItemsForAvailableList);
+ encodeRows(context, pickList, true, flags, selectItemsForAvailableList);
}
-
- private void encodeItemValue(FacesContext context, UIComponent component, ResponseWriter writer, String id, String itemValue) throws IOException { //rowKey = i
-
- writer.startElement(HTML.INPUT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
- writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
- writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
-
- StringBuffer value = new StringBuffer();
-
- value.append(itemValue);
-
- writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
- writer.endElement(HTML.INPUT_ELEM);
-
+
+ private void encodeItemValue(FacesContext context, UIComponent component,
+ ResponseWriter writer, String id, String itemValue)
+ throws IOException { // rowKey = i
+
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, id, null);
+
+ StringBuffer value = new StringBuffer();
+
+ value.append(itemValue);
+
+ writer.writeAttribute(HTML.value_ATTRIBUTE, value.toString(), null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, id + "StateInput", null);
+ writer.endElement(HTML.INPUT_ELEM);
+
}
-
- protected void encodeSpacer(FacesContext context, UIComponent component, ResponseWriter writer) throws IOException {
- writer.startElement(HTML.IMG_ELEMENT, component);
-
- writer.writeAttribute(HTML.src_ATTRIBUTE, getResource("/org/richfaces/renderkit/html/images/spacer.gif").getUri(context, null), null);
- writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
- writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;", null);
-
- writer.endElement(HTML.IMG_ELEMENT);
+
+ protected void encodeSpacer(FacesContext context, UIComponent component,
+ ResponseWriter writer) throws IOException {
+ writer.startElement(HTML.IMG_ELEMENT, component);
+
+ writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
+ "/org/richfaces/renderkit/html/images/spacer.gif").getUri(
+ context, null), null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, " ", null);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "width:1px;height:1px;",
+ null);
+
+ writer.endElement(HTML.IMG_ELEMENT);
}
-
- public void encodeHiddenField(FacesContext context, UIPickList component, List<ConvertedSelectItem> lookupList) throws IOException {
-
- String hiddenFieldCliendId = component.getClientId(context) + HIDDEN_SUFFIX;
-
- ResponseWriter writer = context.getResponseWriter();
-
- writer.startElement(HTML.INPUT_ELEM, component);
- writer.writeAttribute(HTML.TYPE_ATTR, "hidden", "type");
- writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
- writer.writeAttribute(HTML.id_ATTRIBUTE, hiddenFieldCliendId, "id");
- writer.writeAttribute("name", hiddenFieldCliendId, null);
-
- StringBuffer sb = new StringBuffer();
-
- int n = 0;
- for (Iterator<ConvertedSelectItem> i = selectItemsForSelectedList(lookupList).iterator(); i.hasNext();) {
- if (n > 0) {
- sb.append(",");
- }
-
- ConvertedSelectItem value = i.next();
- sb.append(value.getConvertedValue());
- n++;
- }
-
- writer.writeAttribute(HTML.value_ATTRIBUTE, sb.toString(), null);
- writer.endElement(HTML.INPUT_ELEM);
-
+
+ public void encodeHiddenField(FacesContext context, UIPickList component,
+ List<ConvertedSelectItem> lookupList) throws IOException {
+
+ String hiddenFieldCliendId = component.getClientId(context)
+ + HIDDEN_SUFFIX;
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ writer.startElement(HTML.INPUT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "hidden", "type");
+ writer.writeAttribute(HTML.autocomplete_ATTRIBUTE, "off", null);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, hiddenFieldCliendId, "id");
+ writer.writeAttribute("name", hiddenFieldCliendId, null);
+
+ StringBuffer sb = new StringBuffer();
+
+ int n = 0;
+ for (Iterator<ConvertedSelectItem> i = selectItemsForSelectedList(
+ lookupList).iterator(); i.hasNext();) {
+ if (n > 0) {
+ sb.append(",");
+ }
+
+ ConvertedSelectItem value = i.next();
+ sb.append(value.getConvertedValue());
+ n++;
+ }
+
+ writer.writeAttribute(HTML.value_ATTRIBUTE, sb.toString(), null);
+ writer.endElement(HTML.INPUT_ELEM);
+
}
-
+
protected Class<? extends UIComponent> getComponentClass() {
- return UIPickList.class;
+ return UIPickList.class;
}
-
- public String getAsEventHandler(FacesContext context, UIComponent component, String attributeName) {
-
- String event = (String) component.getAttributes().get(attributeName);
- ScriptString result = JSReference.NULL;
-
- if (event != null) {
-
- event = event.trim();
-
- if (event.length() != 0) {
-
- JSFunctionDefinition function = new JSFunctionDefinition();
- function.addParameter("event");
- function.addToBody(event);
-
- result = function;
- }
-
- }
-
- return ScriptUtils.toScript(result);
-
+
+ public String getAsEventHandler(FacesContext context,
+ UIComponent component, String attributeName) {
+
+ String event = (String) component.getAttributes().get(attributeName);
+ ScriptString result = JSReference.NULL;
+
+ if (event != null) {
+
+ event = event.trim();
+
+ if (event.length() != 0) {
+
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("event");
+ function.addToBody(event);
+
+ result = function;
+ }
+
+ }
+
+ return ScriptUtils.toScript(result);
+
}
-
- public String getColumnClassesAsJSArray(FacesContext context, UIComponent component) {
- return ScriptUtils.toScript(getClassesAsList(context, component, "columnClasses"));
+
+ public String getColumnClassesAsJSArray(FacesContext context,
+ UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component,
+ "columnClasses"));
}
-
- public String getRowClassesAsJSArray(FacesContext context, UIComponent component) {
- return ScriptUtils.toScript(getClassesAsList(context, component, "rowClasses"));
+
+ public String getRowClassesAsJSArray(FacesContext context,
+ UIComponent component) {
+ return ScriptUtils.toScript(getClassesAsList(context, component,
+ "rowClasses"));
}
-
- protected List <String> getClassesAsList(FacesContext context, UIComponent component, String attr) {
- String value = (String) ((UIComponent) component).getAttributes().get(attr);
-
- if (value != null && (value.length() != 0)) {
- return Arrays.asList(value.split(","));
- }
-
- return null;
+
+ protected List<String> getClassesAsList(FacesContext context,
+ UIComponent component, String attr) {
+ String value = (String) ((UIComponent) component).getAttributes().get(
+ attr);
+
+ if (value != null && (value.length() != 0)) {
+ return Arrays.asList(value.split(","));
+ }
+
+ return null;
}
-
- public void encodePickListControlsFacets(FacesContext context, UIComponent component, ListStateFlags listStateFlags) throws IOException {
- boolean needsStrut = true;
-
- String clientId = component.getClientId(context);
- boolean enable = false;
-
- ResponseWriter writer = context.getResponseWriter();
- boolean componentDisabled = ((UIPickList) component).isDisabled();
-
- for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
- //Conditionally render the control based on the return value of the control's corresponding helper.isRendered method
- if (SHUTTLE_HELPERS[i].isRendered(context, component)){
- needsStrut = false;
-
- OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
-
- boolean isDisabled = helper.getButtonStyleClass().equals(PickListControlsHelper.DISABLED_STYLE_PREF);
-
- if (helper.getBundlePropertyName().equals(PickListControlsHelper.BUNDLE_REMOVE_ALL_LABEL)) {
-
- enable = listStateFlags.isSelectedList;
- enable = (enable != isDisabled) || (isDisabled && componentDisabled) ? true : false;
-
- } else if (helper.getBundlePropertyName().equals(PickListControlsHelper.BUNDLE_COPY_ALL_LABEL)) {
-
- enable = listStateFlags.isAvailableList;
- enable = (enable != isDisabled) || (isDisabled && componentDisabled) ? true : false;
-
- } else {
-
- if (helper.getButtonStyleClass().equals(PickListControlsHelper.DISABLED_STYLE_PREF)) {
- enable = true;
- } else {
- enable = false;
- }
-
- }
-
- encodeControlFacet(context, component, SHUTTLE_HELPERS[i], clientId, writer, enable, "rich-list-picklist-button", " rich-picklist-control");
- }
- }
-
- if (needsStrut) {
- writer.startElement(HTML.SPAN_ELEM, component);
- writer.endElement(HTML.SPAN_ELEM);
- }
+
+ public void encodePickListControlsFacets(FacesContext context,
+ UIComponent component, ListStateFlags listStateFlags)
+ throws IOException {
+ boolean needsStrut = true;
+
+ String clientId = component.getClientId(context);
+ boolean enable = false;
+
+ ResponseWriter writer = context.getResponseWriter();
+ boolean componentDisabled = ((UIPickList) component).isDisabled();
+
+ for (int i = 0; i < SHUTTLE_HELPERS.length; i++) {
+ // Conditionally render the control based on the return value of the
+ // control's corresponding helper.isRendered method
+ if (SHUTTLE_HELPERS[i].isRendered(context, component)) {
+ needsStrut = false;
+
+ OrderingComponentRendererBase.ControlsHelper helper = SHUTTLE_HELPERS[i];
+
+ boolean isDisabled = helper.getButtonStyleClass().equals(
+ PickListControlsHelper.DISABLED_STYLE_PREF);
+
+ if (helper.getBundlePropertyName().equals(
+ PickListControlsHelper.BUNDLE_REMOVE_ALL_LABEL)) {
+
+ enable = listStateFlags.isSelectedList;
+ enable = (enable != isDisabled)
+ || (isDisabled && componentDisabled) ? true : false;
+
+ } else if (helper.getBundlePropertyName().equals(
+ PickListControlsHelper.BUNDLE_COPY_ALL_LABEL)) {
+
+ enable = listStateFlags.isAvailableList;
+ enable = (enable != isDisabled)
+ || (isDisabled && componentDisabled) ? true : false;
+
+ } else {
+
+ if (helper.getButtonStyleClass().equals(
+ PickListControlsHelper.DISABLED_STYLE_PREF)) {
+ enable = true;
+ } else {
+ enable = false;
+ }
+
+ }
+
+ encodeControlFacet(context, component, SHUTTLE_HELPERS[i],
+ clientId, writer, enable, "rich-list-picklist-button",
+ " rich-picklist-control");
+ }
+ }
+
+ if (needsStrut) {
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
}
-
- protected void encodeControlFacet(FacesContext context, UIComponent component, OrderingComponentRendererBase.ControlsHelper helper, String clientId,
- ResponseWriter writer, boolean enabled, String baseStyle, String baseControlStyle) throws IOException {
-
- renderDefaultControl(context, component, writer, helper, clientId, enabled, baseStyle, baseControlStyle);
-
+
+ protected void encodeControlFacet(FacesContext context,
+ UIComponent component,
+ OrderingComponentRendererBase.ControlsHelper helper,
+ String clientId, ResponseWriter writer, boolean enabled,
+ String baseStyle, String baseControlStyle) throws IOException {
+
+ renderDefaultControl(context, component, writer, helper, clientId,
+ enabled, baseStyle, baseControlStyle);
+
}
-
- public List<ConvertedSelectItem> getConvertedItems(FacesContext context, UIPickList pickList) {
+
+ public List<ConvertedSelectItem> getConvertedItems(FacesContext context,
+ UIPickList pickList) {
List<ConvertedSelectItem> convertedItems = new ArrayList<ConvertedSelectItem>();
- final List<SelectItem> selectItems = SelectUtils.getSelectItems(context, pickList);
- for (int i = 0; i < selectItems.size(); i++ ) {
+ final List<SelectItem> selectItems = SelectUtils.getSelectItems(
+ context, pickList);
+ for (int i = 0; i < selectItems.size(); i++) {
SelectItem item = selectItems.get(i);
if (item instanceof SelectItemGroup) {
- SelectItem[] groupItems = ((SelectItemGroup) item).getSelectItems();
+ SelectItem[] groupItems = ((SelectItemGroup) item)
+ .getSelectItems();
for (int j = 0; j < groupItems.length; j++) {
- convertedItems.add(ConvertedSelectItem.get(context, pickList, groupItems[j], "group:" + j));
- }
+ convertedItems.add(ConvertedSelectItem.get(context,
+ pickList, groupItems[j], "group:" + j));
+ }
} else {
- convertedItems.add(ConvertedSelectItem.get(context, pickList, item, Integer.toString(i)));
+ convertedItems.add(ConvertedSelectItem.get(context, pickList,
+ item, Integer.toString(i)));
}
}
@@ -476,195 +537,225 @@
protected ClassLoader getCurrentLoader(Object fallbackClass) {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
- if (loader == null) {
+ if (loader == null) {
loader = fallbackClass.getClass().getClassLoader();
}
-
+
return loader;
}
- protected String findLocalisedLabel(FacesContext context, String propertyId, String bundleName) {
- String label = null;
- Locale locale = null;
- String userBundleName = null;
- ResourceBundle bundle = null;
-
- UIViewRoot viewRoot = context.getViewRoot();
- if ( viewRoot != null) {
- locale = viewRoot.getLocale();
- } else {
- locale = Locale.getDefault();
- }
-
- if(locale != null) {
-
- try {
-
- if( null != (userBundleName = context.getApplication().getMessageBundle())) {
- bundle = ResourceBundle.getBundle(userBundleName,locale, getCurrentLoader(userBundleName));
-
- if (bundle != null) {
- label = bundle.getString(propertyId);
- }
- }
-
- } catch (MissingResourceException e) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Can't find bundle properties file " + userBundleName + " " + locale.getLanguage() + " " + locale.getCountry()) ;
- }
-
- }
-
- if(label == null && bundleName != null) {
-
- try {
-
- bundle = ResourceBundle.getBundle(bundleName ,locale, getCurrentLoader(bundleName));
- if (bundle != null) {
- label = bundle.getString(propertyId);
- }
-
- } catch (MissingResourceException e) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("Can't find bundle properties file " + bundleName + " " + locale.getLanguage() + " " + locale.getCountry()) ;
- }
-
- }
- }
-
- }
-
- return label;
+ protected String findLocalisedLabel(FacesContext context,
+ String propertyId, String bundleName) {
+ String label = null;
+ Locale locale = null;
+ String userBundleName = null;
+ ResourceBundle bundle = null;
+
+ UIViewRoot viewRoot = context.getViewRoot();
+ if (viewRoot != null) {
+ locale = viewRoot.getLocale();
+ } else {
+ locale = Locale.getDefault();
+ }
+
+ if (locale != null) {
+
+ try {
+
+ if (null != (userBundleName = context.getApplication()
+ .getMessageBundle())) {
+ bundle = ResourceBundle.getBundle(userBundleName, locale,
+ getCurrentLoader(userBundleName));
+
+ if (bundle != null) {
+ label = bundle.getString(propertyId);
+ }
+ }
+
+ } catch (MissingResourceException e) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Can't find bundle properties file "
+ + userBundleName + " " + locale.getLanguage() + " "
+ + locale.getCountry());
+ }
+
+ }
+
+ if (label == null && bundleName != null) {
+
+ try {
+
+ bundle = ResourceBundle.getBundle(bundleName, locale,
+ getCurrentLoader(bundleName));
+ if (bundle != null) {
+ label = bundle.getString(propertyId);
+ }
+
+ } catch (MissingResourceException e) {
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Can't find bundle properties file "
+ + bundleName + " " + locale.getLanguage() + " "
+ + locale.getCountry());
+ }
+
+ }
+ }
+
+ }
+
+ return label;
}
- protected void renderDefaultControl(FacesContext context, UIComponent component, ResponseWriter writer,
- OrderingComponentRendererBase.ControlsHelper helper, String clientId, boolean enabled, String baseStyle,
- String baseControlStyle) throws IOException {
-
- UIComponent facet = component.getFacet(getAltAttribbute(helper));
-
- boolean useFacet = (facet != null && facet.isRendered());
-
- String customEvent = null;
-
- Map<String,Object> attributes = component.getAttributes();
-
- if (helper.customEvent != null) {
- customEvent = (String) attributes.get(helper.customEvent);
- }
-
- String styleFromAttribute = (String) attributes.get(helper.styleFromAttribute);
- String baseStyleLight = baseStyle.concat("-light");
- String baseStylePress = baseStyle.concat("-press");
- String currentStyle = baseControlStyle + helper.getStyleClassName();
-
- if (styleFromAttribute != null) {
- currentStyle = styleFromAttribute.concat(currentStyle);
- }
-
- String controlId = clientId + helper.getIdSuffix();
- writer.startElement(HTML.DIV_ELEM, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); // FIXME:
- writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
-
- String style = enabled ? "display:block;" : "display:none;";
-
- writer.writeAttribute(HTML.style_ATTRIBUTE, style, null);
-
- if (!useFacet) {
-
- writer.startElement(HTML.DIV_ELEM, component);
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + helper.getButtonStyleClass(), null);
-
- if (helper.enable) {
- writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, "this.className='" + baseStyleLight + "'", null);
- writer.writeAttribute(HTML.onmousedown_ATTRIBUTE, "this.className='" + baseStylePress + "'", null);
- writer.writeAttribute(HTML.onmouseup_ATTRIBUTE, "this.className='" + baseStyle + "'", null);
- writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, "this.className='" + baseStyle + "'", null);
- }
-
- if (!helper.enable) {
- //writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
- //writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-a-disabled", null);
- //writer.startElement(HTML.a_ELEMENT, component);
- } else {
- writer.startElement(HTML.a_ELEMENT, component);
- writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link", null); // FIXME:
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;", null);
-
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-selection", null);
- writer.writeAttribute(HTML.onblur_ATTRIBUTE, "Richfaces.Control.onblur(this);", null);
- writer.writeAttribute(HTML.onfocus_ATTRIBUTE, "Richfaces.Control.onfocus(this);", null);
- }
-
- writer.startElement(HTML.DIV_ELEM, component);
- writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content", null);
- }
-
- if (customEvent != null) {
- writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent, null);
- }
-
- if (useFacet) {
- renderChild(context, facet);
- } else {
-
- writer.startElement(HTML.IMG_ELEMENT, component);
- writer.writeAttribute(HTML.class_ATTRIBUTE, "rich-picklist-control-img", null);
- writer.writeAttribute(HTML.alt_ATTRIBUTE, component.getAttributes().get(helper.getTitle()), null);
- writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(helper.getImageURI()).getUri(context, null), null);
- writer.endElement(HTML.IMG_ELEMENT);
-
- if (getUtils().isBooleanAttribute(component, SHOW_LABELS_ATTRIBUTE_NAME)) {
- String label = (String) attributes.get(helper.getLabelAttributeName());
- if (label == null || label.equals("")) {
- label = findLocalisedLabel(context, helper.getBundlePropertyName(), MESSAGE_BUNDLE_NAME);
- }
-
- if (label == null || label.equals("")) {
- label = helper.getDefaultText();
- }
-
- writer.write(label);
- }
- }
-
- if (!useFacet) {
- writer.endElement(HTML.DIV_ELEM);
-
- if (helper.enable) {
- writer.endElement(HTML.a_ELEMENT);
- }
-
- writer.endElement(HTML.DIV_ELEM);
- }
-
- writer.endElement(HTML.DIV_ELEM);
- }
-
- private String getAltAttribbute(
- OrderingComponentRendererBase.ControlsHelper helper) {
-
- return helper.getFacetName() != null ? helper.getFacetName() : " ";
-
- }
+ protected void renderDefaultControl(FacesContext context,
+ UIComponent component, ResponseWriter writer,
+ OrderingComponentRendererBase.ControlsHelper helper,
+ String clientId, boolean enabled, String baseStyle,
+ String baseControlStyle) throws IOException {
+
+ UIComponent facet = component.getFacet(getAltAttribbute(helper));
+
+ boolean useFacet = (facet != null && facet.isRendered());
+
+ String customEvent = null;
+
+ Map<String, Object> attributes = component.getAttributes();
+
+ if (helper.customEvent != null) {
+ customEvent = (String) attributes.get(helper.customEvent);
+ }
+
+ String styleFromAttribute = (String) attributes
+ .get(helper.styleFromAttribute);
+ String baseStyleLight = baseStyle.concat("-light");
+ String baseStylePress = baseStyle.concat("-press");
+ String currentStyle = baseControlStyle + helper.getStyleClassName();
+
+ if (styleFromAttribute != null) {
+ currentStyle = styleFromAttribute.concat(currentStyle);
+ }
+
+ String controlId = clientId + helper.getIdSuffix();
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId, null); // FIXME:
+ writer.writeAttribute(HTML.class_ATTRIBUTE, currentStyle, null);
+
+ String style = enabled ? "display:block;" : "display:none;";
+
+ writer.writeAttribute(HTML.style_ATTRIBUTE, style, null);
+
+ if (!useFacet) {
+
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle
+ + helper.getButtonStyleClass(), null);
+
+ if (helper.enable) {
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE,
+ "this.className='" + baseStyleLight + "'", null);
+ writer.writeAttribute(HTML.onmousedown_ATTRIBUTE,
+ "this.className='" + baseStylePress + "'", null);
+ writer.writeAttribute(HTML.onmouseup_ATTRIBUTE,
+ "this.className='" + baseStyle + "'", null);
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE,
+ "this.className='" + baseStyle + "'", null);
+ }
+
+ if (!helper.enable) {
+ // writer.writeAttribute(HTML.DISABLED_ATTR, "disabled", null);
+ // writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle +
+ // "-a-disabled", null);
+ // writer.startElement(HTML.a_ELEMENT, component);
+ } else {
+ writer.startElement(HTML.a_ELEMENT, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, controlId + "link",
+ null); // FIXME:
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, "return false;",
+ null);
+
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle
+ + "-selection", null);
+ writer.writeAttribute(HTML.onblur_ATTRIBUTE,
+ "Richfaces.Control.onblur(this);", null);
+ writer.writeAttribute(HTML.onfocus_ATTRIBUTE,
+ "Richfaces.Control.onfocus(this);", null);
+ }
+
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE, baseStyle + "-content",
+ null);
+ }
+
+ if (customEvent != null) {
+ writer.writeAttribute(HTML.onclick_ATTRIBUTE, customEvent, null);
+ }
+
+ if (useFacet) {
+ renderChild(context, facet);
+ } else {
+
+ writer.startElement(HTML.IMG_ELEMENT, component);
+ writer.writeAttribute(HTML.class_ATTRIBUTE,
+ "rich-picklist-control-img", null);
+ writer.writeAttribute(HTML.alt_ATTRIBUTE, component.getAttributes()
+ .get(helper.getTitle()), null);
+ writer.writeAttribute(HTML.src_ATTRIBUTE, getResource(
+ helper.getImageURI()).getUri(context, null), null);
+ writer.endElement(HTML.IMG_ELEMENT);
+
+ if (getUtils().isBooleanAttribute(component,
+ SHOW_LABELS_ATTRIBUTE_NAME)) {
+ String label = (String) attributes.get(helper
+ .getLabelAttributeName());
+ if (label == null || label.equals("")) {
+ label = findLocalisedLabel(context, helper
+ .getBundlePropertyName(), MESSAGE_BUNDLE_NAME);
+ }
+
+ if (label == null || label.equals("")) {
+ label = helper.getDefaultText();
+ }
+
+ writer.write(label);
+ }
+ }
+
+ if (!useFacet) {
+ writer.endElement(HTML.DIV_ELEM);
+
+ if (helper.enable) {
+ writer.endElement(HTML.a_ELEMENT);
+ }
+
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ writer.endElement(HTML.DIV_ELEM);
+ }
- public void reRenderScript(FacesContext context, UIComponent component) throws IOException {
-
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
-
- Set <String> areas = ajaxContext.getAjaxRenderedAreas();
- String clientId = component.getClientId(context);
-
- if (ajaxContext.isAjaxRequest() && areas.contains(clientId)){
- areas.add(clientId + "script");
- }
-
+ private String getAltAttribbute(
+ OrderingComponentRendererBase.ControlsHelper helper) {
+
+ return helper.getFacetName() != null ? helper.getFacetName() : " ";
+
}
+ public void reRenderScript(FacesContext context, UIComponent component)
+ throws IOException {
+
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+
+ Set<String> areas = ajaxContext.getAjaxRenderedAreas();
+ String clientId = component.getClientId(context);
+
+ if (ajaxContext.isAjaxRequest() && areas.contains(clientId)) {
+ areas.add(clientId + "script");
+ }
+
+ }
+
}
15 years, 2 months
JBoss Rich Faces SVN: r14945 - branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util.
by richfaces-svn-commits@lists.jboss.org
Author: mvitenkov
Date: 2009-07-17 04:33:11 -0400 (Fri, 17 Jul 2009)
New Revision: 14945
Added:
branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/RegressionTestReporter.java
branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/ReporterBean.java
branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/SeleniumClass.java
branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/XMLParser.java
Log:
Added: branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/RegressionTestReporter.java
===================================================================
--- branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/RegressionTestReporter.java (rev 0)
+++ branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/RegressionTestReporter.java 2009-07-17 08:33:11 UTC (rev 14945)
@@ -0,0 +1,159 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.testng.util;
+
+import java.util.ArrayList;
+
+public class RegressionTestReporter {
+ private ArrayList<SeleniumClass> oldFailed;
+ private ArrayList<SeleniumClass> newPassed;
+ private ArrayList<SeleniumClass> newFailed;
+ private ArrayList<SeleniumClass> oldPassed;
+
+ public RegressionTestReporter() {
+ this.oldFailed = new ArrayList<SeleniumClass>();
+ this.newPassed = new ArrayList<SeleniumClass>();
+ this.newFailed = new ArrayList<SeleniumClass>();
+ this.oldPassed = new ArrayList<SeleniumClass>();
+ }
+
+ public void generateReport(){
+ XMLParser.parse();
+ fillOldFailedMethods();
+ fillNewPassedMethods();
+ fillNewFailedMethods();
+ fillOldPassedMethods();
+ }
+
+ private void fillOldFailedMethods(){
+ ArrayList<String> previousFailedMethods = new ArrayList<String>();
+ ArrayList<String> actualFailedMethods = new ArrayList<String>();
+ for(SeleniumClass sc1:XMLParser.testngResultsClassList){
+ for(SeleniumClass sc2:XMLParser.testngFailedClassList){
+ if(sc1.equals(sc2)){
+ previousFailedMethods.addAll(sc1.getMethods());
+ actualFailedMethods.addAll(sc2.getMethods());
+ previousFailedMethods.retainAll(actualFailedMethods);
+ if(previousFailedMethods.size() > 0){
+ SeleniumClass sc = new SeleniumClass(sc1.getName());
+ sc.getMethods().addAll(previousFailedMethods);
+ oldFailed.add(sc);
+ }
+ }
+ }
+ previousFailedMethods.clear();
+ actualFailedMethods.clear();
+ }
+ }
+ private void fillNewPassedMethods(){
+ ArrayList<String> previousFailedMethods = new ArrayList<String>();
+ ArrayList<String> actualPassedMethods = new ArrayList<String>();
+ for(SeleniumClass sc1:XMLParser.testngResultsClassList){
+ for(SeleniumClass sc2:XMLParser.passedClassList){
+ if(sc1.equals(sc2)){
+ previousFailedMethods.addAll(sc1.getMethods());
+ actualPassedMethods.addAll(sc2.getMethods());
+ previousFailedMethods.retainAll(actualPassedMethods);
+ if(previousFailedMethods.size() > 0){
+ SeleniumClass sc = new SeleniumClass(sc1.getName());
+ sc.getMethods().addAll(previousFailedMethods);
+ newPassed.add(sc);
+ }
+ }
+ }
+ previousFailedMethods.clear();
+ actualPassedMethods.clear();
+ }
+ }
+ private void fillNewFailedMethods(){
+ ArrayList<String> actualFailedMethods = new ArrayList<String>();
+ ArrayList<String> previousFailedMethods = new ArrayList<String>();
+ for(SeleniumClass sc1:XMLParser.testngFailedClassList){
+ for(SeleniumClass sc2:XMLParser.testngResultsClassList){
+ if(sc1.equals(sc2)){
+ actualFailedMethods.addAll(sc1.getMethods());
+ previousFailedMethods.addAll(sc2.getMethods());
+ actualFailedMethods.removeAll(previousFailedMethods);
+ if(actualFailedMethods.size() > 0){
+ SeleniumClass sc = new SeleniumClass(sc1.getName());
+ sc.getMethods().addAll(actualFailedMethods);
+ newFailed.add(sc);
+ }
+ }
+ }
+ actualFailedMethods.clear();
+ previousFailedMethods.clear();
+ }
+ }
+ private void fillOldPassedMethods(){
+ ArrayList<String> actualPassedMethods = new ArrayList<String>();
+ ArrayList<String> previousFailedMethods = new ArrayList<String>();
+ for(SeleniumClass sc1:XMLParser.passedClassList){
+ for(SeleniumClass sc2:XMLParser.testngResultsClassList){
+ if(sc1.equals(sc2)){
+ actualPassedMethods.addAll(sc1.getMethods());
+ previousFailedMethods.addAll(sc2.getMethods());
+ actualPassedMethods.removeAll(previousFailedMethods);
+ if(actualPassedMethods.size() > 0){
+ SeleniumClass sc = new SeleniumClass(sc1.getName());
+ sc.getMethods().addAll(actualPassedMethods);
+ oldPassed.add(sc);
+ }
+ }
+ }
+ actualPassedMethods.clear();
+ previousFailedMethods.clear();
+ }
+ }
+
+ public ArrayList<SeleniumClass> getOldFailed() {
+ return oldFailed;
+ }
+
+ public void setOldFailed(ArrayList<SeleniumClass> oldFailed) {
+ this.oldFailed = oldFailed;
+ }
+
+ public ArrayList<SeleniumClass> getNewPassed() {
+ return newPassed;
+ }
+
+ public void setNewPassed(ArrayList<SeleniumClass> newPassed) {
+ this.newPassed = newPassed;
+ }
+
+ public ArrayList<SeleniumClass> getNewFailed() {
+ return newFailed;
+ }
+
+ public void setNewFailed(ArrayList<SeleniumClass> newFailed) {
+ this.newFailed = newFailed;
+ }
+
+ public ArrayList<SeleniumClass> getOldPassed() {
+ return oldPassed;
+ }
+
+ public void setOldPassed(ArrayList<SeleniumClass> oldPassed) {
+ this.oldPassed = oldPassed;
+ }
+
+}
Added: branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/ReporterBean.java
===================================================================
--- branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/ReporterBean.java (rev 0)
+++ branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/ReporterBean.java 2009-07-17 08:33:11 UTC (rev 14945)
@@ -0,0 +1,147 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.testng.util;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+public class ReporterBean {
+
+ public ReporterBean() {
+
+ }
+
+ public void drawReport() {
+ RegressionTestReporter rtr = new RegressionTestReporter();
+ rtr.generateReport();
+
+ try {
+ FileOutputStream fs = new FileOutputStream("RegressionReportByQA.html");
+ OutputStreamWriter out = new OutputStreamWriter(fs);
+ drawUpperPart(out);
+ drawNewFailedMethods(out, rtr);
+ drawNewPassedMethods(out, rtr);
+ drawOldFailedMethods(out, rtr);
+ drawOldPassedMethods(out, rtr);
+ drawDownerPart(out);
+ out.write("<h4>Note: stopSeleniumServer, startSeleniumServer, stopSelenium, startSelenium shouldn't be tested(not richfaces methods)</h2>");
+ out.close();
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawUpperPart(OutputStreamWriter out) {
+ try {
+ out.write("<html>");
+ out.write("<head>");
+ out.write("<title>");
+ out.write("Richfaces regression report");
+ out.write("</title>");
+ out.write("</head>");
+ out.write("<body>");
+ out.write("<table border=\"1px\" style=\"border:1px solid black; width:500px; align:center;\"");
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawDownerPart(OutputStreamWriter out) {
+ try {
+ out.write("</table>");
+ out.write("</body>");
+ out.write("</html>");
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawOldFailedMethods(OutputStreamWriter out,
+ RegressionTestReporter rtr) {
+ try {
+ out
+ .write("<tr><td><div style=\"font-weight:bold;font-size:16px;\">Old Failed methods:</div><td></tr>");
+ for (SeleniumClass sc : rtr.getOldFailed()) {
+ out.write("<tr><td style=\"font-weight:bold;\">Class:" + sc.getName() + "</td></tr>");
+ for (String method : sc.getMethods()) {
+ out.write("<tr><td style=\"color:grey;\">" + method + "</td></tr>");
+ }
+ }
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawNewPassedMethods(OutputStreamWriter out,
+ RegressionTestReporter rtr) {
+ try {
+ out
+ .write("<tr><td><div style=\"font-weight:bold;font-size:16px;\">New Passed methods:</div><td></tr>");
+ for (SeleniumClass sc : rtr.getNewPassed()) {
+ out.write("<tr><td style=\"font-weight:bold;\">Class:" + sc.getName() + "</td></tr>");
+ for (String method : sc.getMethods()) {
+ out.write("<tr><td style=\"color:green;\">" + method + "</td></tr>");
+ }
+ }
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawNewFailedMethods(OutputStreamWriter out,
+ RegressionTestReporter rtr) {
+ try {
+ out
+ .write("<tr><td><div style=\"font-weight:bold;font-size:16px;\">New Failed(!) methods:</div><td></tr>");
+ for (SeleniumClass sc : rtr.getNewFailed()) {
+ out.write("<tr><td style=\"font-weight:bold;\">Class:" + sc.getName() + "</td></tr>");
+ for (String method : sc.getMethods()) {
+ out.write("<tr><td style=\"color:red;\">" + method + "</td></tr>");
+ }
+ }
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public void drawOldPassedMethods(OutputStreamWriter out,
+ RegressionTestReporter rtr) {
+ try {
+ out
+ .write("<tr><td><div style=\"font-weight:bold;font-size:16px;\">Old Passed methods:</div><td></tr>");
+ for (SeleniumClass sc : rtr.getOldPassed()) {
+ out.write("<tr><td style=\"font:bold;\">Class:" + sc.getName() + "</td></tr>");
+ for (String method : sc.getMethods()) {
+ out.write("<tr><td style=\"color:blue;\">" + method + "</td></tr>");
+ }
+ }
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ public static void main(String[] args) {
+ ReporterBean rb = new ReporterBean();
+ rb.drawReport();
+ }
+
+}
Added: branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/SeleniumClass.java
===================================================================
--- branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/SeleniumClass.java (rev 0)
+++ branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/SeleniumClass.java 2009-07-17 08:33:11 UTC (rev 14945)
@@ -0,0 +1,63 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.testng.util;
+
+import java.util.ArrayList;
+
+public class SeleniumClass {
+
+ private String name;
+ private ArrayList<String> methods;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public ArrayList<String> getMethods() {
+ return methods;
+ }
+
+ public void setMethods(ArrayList<String> methods) {
+ this.methods = methods;
+ }
+
+ public SeleniumClass() {
+ this.methods = new ArrayList<String>();
+ }
+
+ public SeleniumClass(String name) {
+ this.name = name;
+ this.methods = new ArrayList<String>();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null)
+ return false;
+ if (!(obj instanceof SeleniumClass))
+ return false;
+ return ((SeleniumClass) obj).getName().equals(this.name);
+ }
+}
Added: branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/XMLParser.java
===================================================================
--- branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/XMLParser.java (rev 0)
+++ branches/community/3.3.X/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/util/XMLParser.java 2009-07-17 08:33:11 UTC (rev 14945)
@@ -0,0 +1,228 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.testng.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+public class XMLParser {
+ private static String TESTNG_FAILED_PATH;
+ private static String TESTNG_RESULTS_PATH;
+ protected static ArrayList<SeleniumClass> testngFailedClassList;
+ protected static ArrayList<SeleniumClass> testngResultsClassList;
+ protected static ArrayList<SeleniumClass> passedClassList;
+
+ public static ArrayList<SeleniumClass> getPassedClassList() {
+ return passedClassList;
+ }
+
+ public static void setPassedClassList(
+ ArrayList<SeleniumClass> passedClassList) {
+ XMLParser.passedClassList = passedClassList;
+ }
+
+ public ArrayList<SeleniumClass> getTestngFailedClassList() {
+ return testngFailedClassList;
+ }
+
+ public void setTestngFailedClassList(
+ ArrayList<SeleniumClass> testngFailedClassList) {
+ XMLParser.testngFailedClassList = testngFailedClassList;
+ }
+
+ public ArrayList<SeleniumClass> getTestngResultsClassList() {
+ return testngResultsClassList;
+ }
+
+ public void setTestngResultsClassList(
+ ArrayList<SeleniumClass> testngResultsClassList) {
+ XMLParser.testngResultsClassList = testngResultsClassList;
+ }
+
+ public static void fillTestngFailedClassList() {
+
+ Document doc = buildDocument(TESTNG_FAILED_PATH);
+ NodeList classLst = doc.getElementsByTagName("class");
+
+ ArrayList<String> tempMethods = new ArrayList<String>();
+ for (int i = 0; i < classLst.getLength(); i++) {
+ Node classNode = classLst.item(i);// enter to the <class>
+ SeleniumClass seleniumClass = new SeleniumClass(classNode
+ .getAttributes().item(0).getNodeValue());
+
+ if (classNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element classEl = (Element) classNode;
+
+ NodeList includeList = classEl.getElementsByTagName("include");
+
+ tempMethods.clear();
+ for (int j = 0; j < includeList.getLength(); j++) {
+ Node failedMethodName = includeList.item(j).getAttributes()
+ .item(0);
+ tempMethods.add(failedMethodName.getNodeValue());
+ }
+ seleniumClass.getMethods().addAll(tempMethods);
+ }
+ testngFailedClassList.add(seleniumClass);
+ }
+ }
+
+ public static void fillTestngResultsClassList() {
+
+ Document doc = buildDocument(TESTNG_RESULTS_PATH);
+ NodeList methodLst = doc.getElementsByTagName("group");
+
+ ArrayList<String> tempMethods = new ArrayList<String>();
+
+ Node groupNode = methodLst.item(0);// enter to the <group>
+
+ if (groupNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element groupEl = (Element) groupNode;
+
+ NodeList methodList = groupEl.getElementsByTagName("method");
+
+ tempMethods.clear();
+ for (int i = 0; i < methodList.getLength(); i++) {
+ Node failuresMethodName = methodList.item(i).getAttributes()
+ .getNamedItem("name");
+ Node failuresClassName = methodList.item(i).getAttributes()
+ .getNamedItem("class");
+ String s = failuresClassName.getNodeValue();
+ if (!XMLParser.getStringArrayRepresentation(
+ testngResultsClassList).contains(s)) {
+ SeleniumClass seleniumClass = new SeleniumClass(s);
+ seleniumClass.getMethods().add(
+ failuresMethodName.getNodeValue());
+ testngResultsClassList.add(seleniumClass);
+ } else {
+ testngResultsClassList.get(
+ testngResultsClassList
+ .indexOf(new SeleniumClass(s)))
+ .getMethods()
+ .add(failuresMethodName.getNodeValue());
+ }
+ }
+ }
+ }
+
+ public static void fillPassedClassList() {
+
+ Document doc = buildDocument(TESTNG_RESULTS_PATH);
+ NodeList classLst = doc.getElementsByTagName("class");
+
+ ArrayList<String> passedMethods = new ArrayList<String>();
+ ArrayList<String> failedMethods = new ArrayList<String>();
+ for (int i = 0; i < classLst.getLength(); i++) {
+ Node classNode = classLst.item(i);// enter to the <class>
+ SeleniumClass seleniumClass = new SeleniumClass(classNode
+ .getAttributes().item(0).getNodeValue());
+
+ if (classNode.getNodeType() == Node.ELEMENT_NODE) {
+ Element classEl = (Element) classNode;
+
+ NodeList testMethodList = classEl
+ .getElementsByTagName("test-method");
+
+ passedMethods.clear();
+ failedMethods.clear();
+ for (int j = 0; j < testMethodList.getLength(); j++) {
+ Node methodName = testMethodList.item(j).getAttributes()
+ .getNamedItem("name");
+ Node methodStatus = testMethodList.item(j).getAttributes()
+ .getNamedItem("status");
+ String name = methodName.getNodeValue();
+ String status = methodStatus.getNodeValue();
+ if (status.equals("PASS")
+ && !(passedMethods.contains(name))) {
+ passedMethods.add(name);
+ }
+ if (status.equals("FAIL")
+ && !(failedMethods.contains(name))) {
+ failedMethods.add(name);
+ }
+ }
+ passedMethods.removeAll(failedMethods);
+ seleniumClass.getMethods().addAll(passedMethods);
+ }
+ passedClassList.add(seleniumClass);
+ }
+ }
+
+ public static void parse() {
+ try {
+ init();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ fillTestngFailedClassList();
+ fillTestngResultsClassList();
+ fillPassedClassList();
+ }
+
+ private static void init() throws IOException {
+ String currentPath = (new File("")).getAbsolutePath();
+ TESTNG_FAILED_PATH = currentPath + "/test-output/testng-failed.xml";
+ TESTNG_RESULTS_PATH = currentPath + "/test-output/testng-results.xml";
+
+ testngFailedClassList = new ArrayList<SeleniumClass>();
+ testngResultsClassList = new ArrayList<SeleniumClass>();
+ passedClassList = new ArrayList<SeleniumClass>();
+ }
+
+ public static Document buildDocument(String PATH) {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ Document doc = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ doc = db.parse(PATH);
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ doc.getDocumentElement().normalize();
+ return doc;
+ }
+
+ private static ArrayList<String> getStringArrayRepresentation(
+ ArrayList<SeleniumClass> classes) {
+ ArrayList<String> strs = new ArrayList<String>();
+ for (SeleniumClass sc : classes) {
+ strs.add(sc.getName());
+ }
+ return strs;
+ }
+
+}
15 years, 2 months