5 Replies Latest reply on Sep 6, 2009 3:47 PM by nbelaevski

    <rich:progressBar> no behaviour as in the demo

    marianr

      Hi, I have a problem with the <rich:progressBar> component.

      I read the other messages from the other discussions but I haven't found a solution.

      I have exactly the same code as in the demo (the server side one), but I never get any command button displayed on the page. I always have the same text label : "Process dosen't started yet".

      Here is my jsp:

      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
       pageEncoding="ISO-8859-1"%>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <%-- JSF taglibs --%>
      <%@taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@taglib uri="http://richfaces.org/rich" prefix="rich" %>
      <%@taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
      <%@taglib uri="http://openfaces.org/" prefix="o" %>
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html">
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      
      
      <title>Web Data Admin - test</title>
      </head>
      <body>
      <f:view>
      <h:form>
       <a4j:outputPanel id="progressPanel">
       <rich:progressBar value="#{test.currentValue}"
       interval="2000" label="#{test.currentValue} %"
       enabled="#{test.enabled}" minValue="-1" maxValue="100"
       reRenderAfterComplete="progressPanel">
       <f:facet name="initial">
       <br />
       <h:outputText value="Process doesn't started yet" />
       <a4j:commandButton action="#{test.startProcess}"
       value="Start Process" reRender="progressPanel"
       rendered="#{test.buttonRendered}"
       style="margin: 9px 0px 5px;" />
       </f:facet>
       <f:facet name="complete">
       <br />
       <h:outputText value="Process Done" />
       <a4j:commandButton action="#{test.startProcess}"
       value="Restart Process" reRender="progressPanel"
       rendered="#{test.buttonRendered}"
       style="margin: 9px 0px 5px;" />
       </f:facet>
       </rich:progressBar>
       </a4j:outputPanel>
       </h:form>
      </f:view>
      </body>
      </html>
      


      Here is the bean:
      package formation.jsf.presentation;
      
      import java.util.Date;
      
      
      public class test {
      
       private boolean buttonRendered = true;
       private boolean enabled=false;
       private Long startTime;
      
       public test() {
       }
      
       public String startProcess() {
       setEnabled(true);
       setButtonRendered(false);
       setStartTime(new Date().getTime());
       return null;
       }
      
       public Long getCurrentValue(){
       if (isEnabled()){
       Long current = (new Date().getTime() - startTime)/1000;
       if (current>100){
       setButtonRendered(true);
       }else if (current.equals(0)){
       return new Long(1);
       }
       return (new Date().getTime() - startTime)/1000;
       } if (startTime == null) {
       return Long.valueOf(-1);
       }
       else
       return Long.valueOf(101);
       }
      
       public boolean isEnabled() {
       return enabled;
       }
      
       public void setEnabled(boolean enabled) {
       this.enabled = enabled;
       }
      
       public Long getStartTime() {
       return startTime;
       }
      
       public void setStartTime(Long startTime) {
       this.startTime = startTime;
       }
      
       public boolean isButtonRendered() {
       return buttonRendered;
       }
      
       public void setButtonRendered(boolean buttonRendered) {
       this.buttonRendered = buttonRendered;
       }
      }
      


      So, I think this is exactly as in the demo.

      I get no error in FireBug, so I don't know how to solve it.
      I am working with OpenFaces in the same project.

      Here is my web.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       id="WebApp_ID" version="2.5">
      
       <display-name>DataEntry</display-name>
      
       <welcome-file-list>
       <welcome-file>/index.jsp</welcome-file>
       </welcome-file-list>
      
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
       <!--
       <context-param>
       <param-name>org.richfaces.LoadStyleStrategy</param-name>
       <param-value>ALL</param-value>
       </context-param>
       <context-param>
       <param-name>org.richfaces.LoadScriptStrategy</param-name>
       <param-value>ALL</param-value>
       </context-param>
       -->
       <filter>
       <filter-name>ResourceFilter</filter-name>
       <filter-class>org.openfaces.util.ResourceFilter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>ResourceFilter</filter-name>
       <url-pattern>/openFacesResources/*</url-pattern>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       </filter-mapping>
      
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <!--
       <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/myFacesExtensionRessource/*</url-pattern>
       </filter-mapping>
       -->
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
       </servlet-mapping>
      
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>/faces/*</url-pattern>
       </servlet-mapping>
      
       <error-page>
       <error-code>500</error-code>
       <location>/VueErreur.jsp</location>
       </error-page>
      
      </web-app>
      


      Thanks for helping me!

      Marian

        • 1. Re: <rich:progressBar> no behaviour as in the demo
          nbelaevski

          Hi Marian,

          There's a problem with your page code: facet cannot contain more than component, but you're trying to put several components there. Solution: wrap content into h:panelGroup.

          • 2. Re: <rich:progressBar> no behaviour as in the demo
            marianr

            Hi, thanks for helping, but I still have the same problem.

            Here is what I tried in my JSP:

            <f:view>
            <h:form>
            <h:panelGrid id="grid" columns="1">
            <h:panelGroup>
             <a4j:outputPanel id="progressPanel">
             <rich:progressBar value="#{test.currentValue}"
             interval="2000" label="#{test.currentValue} %"
             enabled="#{test.enabled}" minValue="-1" maxValue="100"
             reRenderAfterComplete="progressPanel">
             <f:facet name="initial">
             <br />
             <h:outputText value="Process doesn't started yet" />
             <a4j:commandButton action="#{test.startProcess}"
             value="Start Process" reRender="progressPanel"
             rendered="#{test.buttonRendered}"
             style="margin: 9px 0px 5px;" />
             </f:facet>
             <f:facet name="complete">
             <br />
             <h:outputText value="Process Done" />
             <a4j:commandButton action="#{test.startProcess}"
             value="Restart Process" reRender="progressPanel"
             rendered="#{test.buttonRendered}"
             style="margin: 9px 0px 5px;" />
             </f:facet>
             </rich:progressBar>
             </a4j:outputPanel>
             </h:panelGroup>
             </h:panelGrid>
             </h:form>
            </f:view>
            


            The problem is still exactly the same...

            • 3. Re: <rich:progressBar> no behaviour as in the demo
              nbelaevski

              The second example is also using incorrect code.

              • 4. Re: <rich:progressBar> no behaviour as in the demo
                marianr

                Hi, sorry but I just tried to wrap the components into a panelGroup, as you told me, but it still doesn't work. I really have no idea of what I'm doing wrong... sorry!

                Here is the latest code I tried:

                <f:view>
                <h:form>
                <h:messages />
                <h:panelGroup>
                
                 <a4j:outputPanel id="progressPanel">
                 <rich:progressBar value="#{test.currentValue}"
                 interval="2000" label="#{test.currentValue} %"
                 enabled="#{test.enabled}" minValue="-1" maxValue="100"
                 reRenderAfterComplete="progressPanel">
                 <f:facet name="initial">
                 <br />
                 <h:outputText value="Process doesn't started yet" />
                 <a4j:commandButton action="#{test.startProcess}"
                 value="Start Process" reRender="progressPanel"
                 rendered="#{test.buttonRendered}"
                 style="margin: 9px 0px 5px;" />
                 </f:facet>
                 <f:facet name="complete">
                 <br />
                 <h:outputText value="Process Done" />
                 <a4j:commandButton action="#{test.startProcess}"
                 value="Restart Process" reRender="progressPanel"
                 rendered="#{test.buttonRendered}"
                 style="margin: 9px 0px 5px;" />
                 </f:facet>
                 </rich:progressBar>
                 </a4j:outputPanel>
                 </h:panelGroup>
                 </h:form>
                </f:view>
                


                My page is still displayed the same way...

                Thanks for helping!


                • 5. Re: <rich:progressBar> no behaviour as in the demo
                  nbelaevski

                  You are trying to put several components into facet, but it allows only one component. Wrap facet content into h:panelGroup like this:

                  <f:facet name="initial"><h:panelGroup>
                   <br />
                   <h:outputText value="Process doesn't started yet" />
                   <a4j:commandButton action="#{test.startProcess}"
                   value="Start Process" reRender="progressPanel"
                   rendered="#{test.buttonRendered}"
                   style="margin: 9px 0px 5px;" />
                   </h:panelGroup></f:facet>