Comment intégrer le ProgressBar dans mon projet
Bonjour,
j'ai une page login.jsf, où les users rentrent les paramètres necessaire pour se connecter à Oracle, je veux que quand ils clique sur Connect un progressBar s'affiche et les rediriger vers la page welcome.jsf
PS: la connexion à Oracle marche nikel, la refirection à la page welcome.jsf marche aussi, je veux juste intégrer le progressBar
login.xhtml :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<?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> |
j'ai trouvé un code de progressBar dans le site de Richefaces mais j'ai pas réussi (ni comprendre ) comment l'intégrer voici leurs code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| <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 :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| /**
*
*/
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;
}
} |