1 Reply Latest reply on Jan 19, 2012 4:38 PM by Maheswara Sunkara

    How to integrate progressBar in my project

    yas EL Newbie

      Hello,

      I have a login.jsf page , where users brings in the parameters to connect in Oracle, I want that when they click on Connect, a progressBar displays and after it display 100 % users will be redirect towards the page welcome.jsf

      PS: the connection to Oracle (works) , the redirection to welcome.jsf page  also (works), I just want to integrate(join) the progressBar

       

      Login.jsf

       

      <?xml version='1.0' encoding='UTF-8' ?> 
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich">
      <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link href="css/default.css" rel="stylesheet" type="text/css" />
            <title> LOGICA TESTING BI TOOL</title>
          </head>
      
       <f:view>
          <body>
      
            <img src="img/logica.jpg" class="floatLeft" 
                      height="82" width="96"/>
            <h1> LOGICA TESTING BI TOOL</h1> 
            <br clear="all" ></br>
            <table width="100%">
              <tr><td style="background-color: #200070" height="5"></td></tr>
            </table>
            <br clear="all" ></br>   
      
           <h:form>
      
      
      
          <rich:tabPanel headerAlignment="right" switchType="client">
                   <rich:tab label="ORACLE">
                  <h:panelGrid columns="2">
                      <h:outputText value="Host"></h:outputText>
                      <h:inputText value="#{ManagedBeanO.host}"></h:inputText>
                      <h:outputText value="Port"></h:outputText>
                      <h:inputText value="#{ManagedBeanO.port}"></h:inputText>
                      <h:outputText value="User"></h:outputText>
                      <h:inputText value="#{ManagedBeanO.user}"></h:inputText>
                      <h:outputText value="Password"></h:outputText>
                      <h:inputSecret value="#{ManagedBeanO.mdp}"></h:inputSecret>
                      <h:outputText value="Base Name"></h:outputText>
                      <h:inputText value="#{ManagedBeanO.baseName}"></h:inputText>
                  </h:panelGrid>
                   <h:commandButton value="Connect" 
                  action="#{ManagedBeanO.process}" style="width: 6em" />
              </rich:tab>
      
       </h:form>     
       </body>
       </f:view> 
      </html>
      
      

       

       

      I found a code of progressBar in the Richefaces website  .... but I didn't succed to integrate it into my project:

       

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich">
      
        <h:form>
        <a4j:outputPanel id="progressPanel">
        <rich:progressBar value="#{progressBarBean.currentValue}"
        interval="2000" label="#{progressBarBean.currentValue} %"
        enabled="#{progressBarBean.enabled}" minValue="-1" maxValue="100"
        reRenderAfterComplete="progressPanel">
        <f:facet name="initial">
        <br />
        <h:outputText value="Process doesn't started yet" />
        <a4j:commandButton action="#{progressBarBean.startProcess}"
        value="Start Process" reRender="progressPanel"
        rendered="#{progressBarBean.buttonRendered}"
        style="margin: 9px 0px 5px;" />
        </f:facet>
        <f:facet name="complete">
        <br />
        <h:outputText value="Process Done" />
        <a4j:commandButton action="#{progressBarBean.startProcess}"
        value="Restart Process" reRender="progressPanel"
        rendered="#{progressBarBean.buttonRendered}"
        style="margin: 9px 0px 5px;" />
        </f:facet>
        </rich:progressBar>
        </a4j:outputPanel>
        </h:form>
      </ui:composition>
      
      

       

      JavaBeanSource

       

       

      /**
       * 
       */
      package org.richfaces.demo.progressBar;
      
      import java.util.Date;
      
      /**
       * @author Ilya Shaikovsky
       *
       */
      public class ProgressBarBean {
      
         private boolean buttonRendered = true;
         private boolean enabled=false;
         private Long startTime;
      
         public ProgressBarBean() {
         }
      
         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;
         }
      }
      
      

       

       

      Thanks for your help.