На моей странице JSF 2.0 содержатся некоторые данные, которые динамичны, поэтому требуется автоматическое обновление в течение определенного предопределенного интервала времени (скажем, каждые 10 секунд). Я использую PrimeFaces 3.5 в качестве мощного набора компонентов. Ниже управляемый bean-Как регулярно обновлять страницу в jsf2.0?
@ManagedBean
@ViewScoped
public Monitor implements Serializable {
//max,min,avg,stdDev,reason are caluclated based on some dynamic data
private int max;
private int min;
private double avg;
private double stdDev;
private String reason;
public int getMax() {
//Here before returning I am calling some methods to get the max from dynamic data
return max;
}
public int getMin() {
//Here before returning I am calling some methods to get the min from dynamic data
return min;
}
public double getAvg() {
//Here before returning I am calling some methods to get the avg from dynamic data
return avg;
}
public String getReason() {
//Here before returning I am calling some methods to get the reason from dynamic data
return reason;
}
public double getStdDev() {
//Here before returning I am calling some methods to get the stdDev from dynamic data
return stdDev;
}
public void setMax(int max) {
this.max = max;
}
public void setMin(int min) {
this.min = min;
}
public void setAvg(double avg) {
this.avg = avg;
}
public void setStdDev(double stdDev) {
this.stdDev = stdDev;
}
public void setReason(String reason) {
this.reason = reason;
}
}
Я не завершить макет до сих пор, однако я бы как this-
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Insert title here</title>
</h:head>
<h:body>
<p:panel>
<h:outputLabel value="#{monitor.min}" />
<h:outputLabel value="#{monitor.max}" />
<h:outputLabel value="#{monitor.avg}" />
<h:outputLabel value="#{monitor.stdDev}" />
<h:outputLabel value="#{monitor.reason}" />
</p:panel>
</h:body>
</html>
Как я могу обновить страницу регулярно в JSF 2.0?
Вы пытаетесь ** Опрос **: HTTP: //www.primefaces.org/showcase/ui/poll.jsf –
@RongNK: Могу ли я получить условное обновление? Я имею в виду, скажем, когда avg больше 50. Я хочу остановить этот процесс обновления и просто хочу показать другую страницу. –
Вы можете, опрос может остановить и начать. –