[richfaces-svn-commits] JBoss Rich Faces SVN: r5014 - in trunk/sandbox/ui: progressBAR and 24 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Dec 26 11:43:00 EST 2007
Author: andrei_exadel
Date: 2007-12-26 11:42:59 -0500 (Wed, 26 Dec 2007)
New Revision: 5014
Added:
trunk/sandbox/ui/progressBAR/
trunk/sandbox/ui/progressBAR/pom.xml
trunk/sandbox/ui/progressBAR/src/
trunk/sandbox/ui/progressBAR/src/main/
trunk/sandbox/ui/progressBAR/src/main/config/
trunk/sandbox/ui/progressBAR/src/main/config/component/
trunk/sandbox/ui/progressBAR/src/main/config/component/README
trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml
trunk/sandbox/ui/progressBAR/src/main/java/
trunk/sandbox/ui/progressBAR/src/main/java/org/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
trunk/sandbox/ui/progressBAR/src/main/resources/
trunk/sandbox/ui/progressBAR/src/main/resources/org/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar.png
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar_perm.gif
trunk/sandbox/ui/progressBAR/src/main/templates/
trunk/sandbox/ui/progressBAR/src/main/templates/README
trunk/sandbox/ui/progressBAR/src/main/templates/org/
trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/
trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx
trunk/sandbox/ui/progressBAR/src/test/
trunk/sandbox/ui/progressBAR/src/test/java/
trunk/sandbox/ui/progressBAR/src/test/java/org/
trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/
trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/
trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java
Log:
RF-1686
Added: trunk/sandbox/ui/progressBAR/pom.xml
===================================================================
--- trunk/sandbox/ui/progressBAR/pom.xml (rev 0)
+++ trunk/sandbox/ui/progressBAR/pom.xml 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+ <parent>
+ <artifactId>ui</artifactId>
+ <groupId>org.richfaces.sandbox</groupId>
+ <version>3.2.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.sandbox.ui</groupId>
+ <artifactId>progressBar</artifactId>
+ <name>progressBar</name>
+ <version>3.2.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <library>
+ <prefix>org.richfaces.sandbox.ui</prefix>
+ <taglib>
+ <shortName>progressBar</shortName>
+ </taglib>
+ </library>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.framework</groupId>
+ <artifactId>richfaces-impl</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.richfaces.ui</groupId>
+ <artifactId>core</artifactId>
+ <version>3.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added: trunk/sandbox/ui/progressBAR/src/main/config/component/README
===================================================================
Added: trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/main/config/component/progressBar.xml 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
+<components>
+ <component>
+ <name>org.richfaces.ProgressBar</name>
+ <family>org.richfaces.ProgressBar</family>
+ <classname>org.richfaces.component.html.HtmlProgressBar</classname>
+ <superclass>org.richfaces.component.UIProgressBar</superclass>
+ <description>
+ <![CDATA[
+ ]]>
+ </description>
+ <renderer generate="true" override="true">
+ <name>org.richfaces.renderkit.ProgressBarRenderer</name>
+ <template>org/richfaces/progressBar.jspx</template>
+ </renderer>
+ <tag>
+ <name>progressBar</name>
+ <classname>org.richfaces.taglib.ProgressBarTag</classname>
+ <superclass>
+ org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ </superclass>
+ <test/>
+ </tag>
+ <taghandler generate="false">
+ <classname>org.ajax4jsf.webapp.taglib.AjaxComponentHandler</classname>
+ </taghandler>
+ &ui_component_attributes;
+ &html_universal_attributes;
+ &html_events;
+ <property>
+ <name>completeClass</name>
+ <classname>java.lang.String</classname>
+ <description>CSS class that defines style for progress line rendering</description>
+ </property>
+ <property>
+ <name>remainClass</name>
+ <classname>java.lang.String</classname>
+ <description>CSS class that defines style for remained part of progress bar</description>
+ </property>
+ <property>
+ <name>determined</name>
+ <classname>java.lang.String</classname>
+ <description>Attribute defines if component should render percent value</description>
+ </property>
+ <property>
+ <name>permanent</name>
+ <classname>java.lang.String</classname>
+ <description>Attribute defines background should be permanent</description>
+ </property>
+ <property>
+ <name>reRenderAfterComplete</name>
+ <classname>java.lang.String</classname>
+ <description>Set of componets to rerender after completion</description>
+ </property>
+ <property hidden="true">
+ <name>actionExpression</name>
+ </property>
+ <property>
+ <name>onsubmit</name>
+ <classname>java.lang.String</classname>
+ <description>
+ JavaScript code for call before submission of ajax
+ event
+ </description>
+ </property>
+ <property>
+ <name>interval</name>
+ <classname>int</classname>
+ <description>
+ Interval (in ms) for call poll requests. Default value
+ 1000 (1 sec)
+ </description>
+ <defaultvalue>1000</defaultvalue>
+ </property>
+ <property>
+ <name>enabled</name>
+ <classname>boolean</classname>
+ <description>
+ <![CDATA[Enable/disable polling]]>
+ </description>
+ <defaultvalue>true</defaultvalue>
+ </property>
+ <property>
+ <name>value</name>
+ <classname>java.lang.Object</classname>
+ </property>
+ <property hidden="true">
+ <name>submitted</name>
+ <classname>boolean</classname>
+ </property>
+ <property hidden="true">
+ <name>requestDelay</name>
+ <classname>int</classname>
+ </property>
+ <property>
+ <name>ignoreDupResponses</name>
+ <classname>boolean</classname>
+ <description>
+Attribute allows to ignore an Ajax Response produced by a request if the newest 'similar' request is
+in a queue already. ignoreDupResponses="true" does not cancel the request while it is processed on the server,
+but just allows to avoid unnecessary updates on the client side if the response isn't actual now
+ </description>
+ </property>
+ </component>
+
+</components>
Added: trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/component/UIProgressBar.java 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,26 @@
+/*
+ * UIProgressBar.java Date created: 19.12.2007
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.component;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.component.UIPoll;
+import org.ajax4jsf.context.AjaxContext;
+
+/**
+ * TODO Class description goes here.
+ *
+ * @author "Andrey Markavtsov"
+ *
+ */
+public abstract class UIProgressBar extends UIPoll {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.ProgressBar";
+
+ public static final String COMPONENT_FAMILY = "org.richfaces.ProgressBar";
+
+}
Added: trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/AbstractProgressBarRenderer.java 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,192 @@
+/*
+ * AbstractProgressBarRenderer.java Date created: 20.12.2007
+ * Last modified by: $Author$
+ * $Revision$ $Date$
+ */
+
+package org.richfaces.renderkit;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
+import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.ajax4jsf.renderkit.ComponentVariables;
+import org.ajax4jsf.renderkit.ComponentsVariableResolver;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.UIProgressBar;
+
+/**
+ * Abstract progress bar renderer
+ *
+ * @author "Andrey Markavtsov"
+ *
+ */
+public class AbstractProgressBarRenderer extends AjaxCommandRendererBase {
+
+ /** AJAX polling function name */
+ private static final String AJAX_POLL_FUNCTION = "A4J.AJAX.Poll";
+
+ /**
+ * Methods encodes AJAX script for polling
+ *
+ * @param context -
+ * faces context
+ * @param component -
+ * component instance
+ * @throws IOException -
+ * IOException
+ */
+ public void encodePollScript(FacesContext context, UIComponent component)
+ throws IOException {
+
+ ResponseWriter writer = context.getResponseWriter();
+ UIProgressBar progressBar = (UIProgressBar) component;
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display:none;", null);
+ writer.startElement(HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(HTML.TYPE_ATTR, "text/javascript", null);
+ StringBuffer script = new StringBuffer("\n");
+ if (progressBar.isEnabled()) {
+ JSFunction function = AjaxRendererUtils.buildAjaxFunction( // encode
+ // script
+ // if
+ // polling
+ // enable
+ component, context, AJAX_POLL_FUNCTION);
+ Map options = AjaxRendererUtils.buildEventOptions(context,
+ component);
+ Integer interval = new Integer(progressBar.getInterval());
+ options.put("pollinterval", interval);
+ options.put("pollId", component.getClientId(context));
+ Object onsubmit = component.getAttributes().get("onsubmit");
+ if (null != onsubmit) {
+ JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
+ onsubmitFunction.addToBody(onsubmit);
+ options.put("onsubmit", onsubmitFunction);
+ }
+
+ function.addParameter(options);
+ function.appendScript(script);
+ } else {
+ script.append("A4J.AJAX.StopPoll('").append(
+ component.getClientId(context)).append("')");
+ }
+ script.append(";\n");
+ writer.writeText(script.toString(), null);
+ writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ public void encodePersent(FacesContext context, UIComponent component)
+ throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+ String determinedAttr = (String)component.getAttributes().get("determined");
+ if (determinedAttr != null && "true".equals(determinedAttr)) {
+ ComponentVariables variables = ComponentsVariableResolver
+ .getVariables(this, component);
+ Integer percent = (Integer) variables.getVariable("percent");
+ if (percent != null) {
+ writer.write(percent.toString() + "%");
+ }
+ }
+
+ }
+
+ /**
+ * Methods encodes start facet of progress bar component
+ *
+ * @param context -
+ * faces context
+ * @param component -
+ * component instance
+ * @throws IOException -
+ * IOException
+ */
+ public void encodeInitialState(FacesContext context, UIComponent component)
+ throws IOException {
+ String clientId = component.getClientId(context);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
+ UIComponent initial = component.getFacet("initial");
+ if (initial != null) {
+ renderChild(context, initial);
+ }
+ encodePollScript(context, component);
+ writer.endElement(HTML.DIV_ELEM);
+
+ }
+
+ /**
+ * Methods encodes finish facet of progress bar component
+ *
+ * @param context -
+ * faces context
+ * @param component -
+ * component instance
+ * @throws IOException -
+ * IOException
+ */
+ public void encodeCompletedState(FacesContext context, UIComponent component)
+ throws IOException {
+
+ Object rerenderAfterComplete = component.getAttributes().get(
+ "reRenderAfterComplete");
+ Set ajaxRegions = AjaxRendererUtils.asSet(rerenderAfterComplete);
+
+ if (ajaxRegions != null) {
+ for (Iterator iter = ajaxRegions.iterator(); iter.hasNext();) {
+ String id = iter.next().toString();
+ AjaxContext ajaxContext = AjaxContext
+ .getCurrentInstance(context);
+ ajaxContext.addComponentToAjaxRender(component, id);
+ }
+ }
+
+ String clientId = component.getClientId(context);
+ ResponseWriter writer = context.getResponseWriter();
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute(HTML.id_ATTRIBUTE, clientId, null);
+ UIComponent completed = component.getFacet("completed");
+ if (completed != null) {
+ renderChild(context, completed);
+ }
+ writer.endElement(HTML.DIV_ELEM);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ */
+ protected Class getComponentClass() {
+ // only poll component is allowed.
+ return UIProgressBar.class;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.renderkit.AjaxCommandRendererBase#isSubmitted(javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected boolean isSubmitted(FacesContext facesContext,
+ UIComponent uiComponent) {
+ boolean submitted = super.isSubmitted(facesContext, uiComponent);
+ UIProgressBar poll = (UIProgressBar) uiComponent;
+ poll.setSubmitted(submitted);
+ return submitted;
+ }
+
+}
Added: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:template
+ xmlns:f="http://jsf.exadel.com/template"
+ xmlns:u="http://jsf.exadel.com/template/util"
+ xmlns="http://www.w3.org/1999/xhtml"
+ component="org.richfaces.component.UIProgressBar">
+
+ <f:verbatim>
+
+*{font-family : verdana; font-size : 11px}
+.rich-progress-bar-uploaded{overflow : hidden; position : absolute; border : 0px solid #cccccc; height : 16px;}
+.rich-progress-bar{position : relative; margin-bottom : 2px; height : 16px; width : 200px}
+.rich-progress-bar-base{text-align : center; position : absolute; height : 16px; width : 200px; font-weight : bold;}
+.rich-progress-bar-remained{background : #F1F1F1; border : 1px solid #cccccc; color : #000000;}
+.rich-progress-bar-completed{background : #FF9409; color : #FFFFFF;; background-repeat : repeat-x; repeat-y;}
+.rich-progress-bar-permanent{background : #FF9409; color : #FFFFFF;; background-repeat : repeat-x; repeat-y;}
+
+ </f:verbatim>
+
+ <u:selector name=".rich-progress-bar-completed">
+ <u:style name="background-image">
+ <f:resource f:key="/org/richfaces/renderkit/html/images/bg_ProgressBar.png" />
+ </u:style>
+ </u:selector>
+
+ <u:selector name=".rich-progress-bar-permanent">
+ <u:style name="background-image">
+ <f:resource f:key="/org/richfaces/renderkit/html/images/bg_ProgressBar_perm.gif" />
+ </u:style>
+ </u:selector>
+
+
+</f:template>
\ No newline at end of file
Added: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar.png
===================================================================
(Binary files differ)
Property changes on: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar_perm.gif
===================================================================
(Binary files differ)
Property changes on: trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/images/bg_ProgressBar_perm.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/sandbox/ui/progressBAR/src/main/templates/README
===================================================================
Added: trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx
===================================================================
--- trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/main/templates/org/richfaces/progressBar.jspx 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<f:root
+ xmlns:f="http://ajax4jsf.org/cdk/template"
+ xmlns:h=" http://ajax4jsf.org/cdk/headers"
+ class="org.richfaces.renderkit.ProgressBarRenderer"
+ baseclass="org.richfaces.renderkit.AbstractProgressBarRenderer"
+ component="org.richfaces.component.UIProgressBar"
+ >
+
+<h:styles>/org/richfaces/renderkit/html/css/progressBar.xcss</h:styles>
+
+<h:scripts>
+ new org.ajax4jsf.javascript.PrototypeScript(),
+ new org.ajax4jsf.javascript.AjaxScript(),
+</h:scripts>
+
+<f:clientId var="clientId" />
+
+<jsp:scriptlet>
+<![CDATA[
+ Integer percent = (Integer)component.getAttributes().get("value");
+
+ variables.setVariable("percent",percent);
+ variables.setVariable("style",(String)component.getAttributes().get("style"));
+
+ String permanent = (String)component.getAttributes().get("permanent");
+
+ variables.setVariable("completeClass",(component.getAttributes().get("completeClass") != null) ?
+ (String)component.getAttributes().get("completeClass") :
+ ((permanent != null && "true".equals(permanent)) ?
+ "rich-progress-bar-permanent" : "rich-progress-bar-completed"));
+
+ variables.setVariable("remainClass",(component.getAttributes().get("remainClass") != null) ?
+ (String)component.getAttributes().get("remainClass"): "rich-progress-bar-remained" );
+
+
+ ]]>
+</jsp:scriptlet>
+
+<jsp:scriptlet>
+<![CDATA[
+if (percent <= 0) {
+ encodeInitialState(context, component);
+} else if (percent >= 100) {
+ encodeCompletedState(context, component);
+} else {
+ ]]>
+</jsp:scriptlet>
+<div class="rich-progress-bar" style="#{style}" id="#{clientId}">
+ <div class="#{remainClass} rich-progress-bar-base" style="#{style}">
+ <f:call name="encodePersent"/>
+ </div>
+ <div class="rich-progress-bar-uploaded" style="#{style}; width: #{percent}%;">
+ <div class="#{completeClass} rich-progress-bar-base" style="#{style}">
+ <f:call name="encodePersent"/>
+ </div>
+ </div>
+<f:call name="encodePollScript"/>
+</div>
+
+<jsp:scriptlet>
+<![CDATA[
+}
+]]>
+</jsp:scriptlet>
+
+</f:root>
\ No newline at end of file
Added: trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java
===================================================================
--- trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java (rev 0)
+++ trunk/sandbox/ui/progressBAR/src/test/java/org/richfaces/sandbox/ProgressBarComponentTest.java 2007-12-26 16:42:59 UTC (rev 5014)
@@ -0,0 +1,102 @@
+package org.richfaces.sandbox;
+
+import javax.faces.component.UIForm;
+import javax.faces.component.html.HtmlForm;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.richfaces.component.UIProgressBar;
+
+import com.gargoylesoftware.htmlunit.html.DomText;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * Unit test for Progress bar component.
+ */
+public class ProgressBarComponentTest extends AbstractAjax4JsfTestCase {
+
+ /** Form component */
+ private UIForm form = null;
+
+ /** Progress bar component */
+ private UIProgressBar progressBar = null;
+
+ /**
+ * TODO Description goes here.
+ *
+ * @param name
+ */
+ public ProgressBarComponentTest(String name) {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ @Override
+ public void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+ form = new HtmlForm();
+ form.setId("form");
+ facesContext.getViewRoot().getChildren().add(form);
+
+ progressBar = (UIProgressBar) application
+ .createComponent("org.richfaces.ProgressBar");
+ progressBar.setId("prgs");
+ progressBar.setValue(50);
+ progressBar.setInterval(1000);
+ progressBar.getAttributes().put("determined", "true");
+
+ form.getChildren().add(progressBar);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ @Override
+ public void tearDown() throws Exception {
+ // TODO Auto-generated method stub
+ super.tearDown();
+ }
+
+ /**
+ * Method tests progress bar component
+ * @throws Exception
+ */
+ public void testProgressBar() throws Exception {
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ HtmlElement progress = page.getHtmlElementById(progressBar
+ .getClientId(facesContext));
+ assertNotNull(progress);
+ assertEquals("div", progress.getNodeName());
+
+ String classAttr = progress.getAttributeValue("class");
+ assertTrue(classAttr.contains("rich-progress-bar"));
+
+ HtmlElement node = (HtmlElement)progress.getFirstChild();
+ assertTrue(node.getAttributeValue("class").contains("rich-progress-bar-base"));
+ assertTrue("50%".equals(node.asText()));
+
+ node = (HtmlElement) progress.getLastChild();
+ assertTrue("span".equalsIgnoreCase(node.getTagName()));
+
+ node = (HtmlElement) node.getLastChild();
+ assertTrue("script".equalsIgnoreCase(node.getTagName()));
+
+ DomText text = (DomText) node.getFirstChild();
+ assertTrue(text.getData().contains("A4J.AJAX.Poll"));
+ assertTrue(text.getData().contains("1000"));
+
+
+ }
+
+}
More information about the richfaces-svn-commits
mailing list