AJAX счетчик в PrimeFaces Бин
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package org.primefaces.examples.view;
import javax.faces.bean.ManagedBean; import javax.faces.bean.SessionScoped;
/** * * @author martyshov */ @ManagedBean @SessionScoped public class CounterBean {
/** * Creates a new instance of CounterBean */ public CounterBean() { } private int count; public int getCount() { return count; } public void setCount(int count) { this.count = count; } public void increment() { count++; } } Интерфейс: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:head> <title>Facelet Title</title> </h:head> <h:body>
<h:form id="form"> <h:outputText id="txt_count" value="#{counterBean.count}" /> <p:poll interval="1" listener="#{counterBean.increment}" update="txt_count" /> </h:form> </h:body> </html>
|