From f703aef6c67f3c5431e2b744d90ecb293d783682 Mon Sep 17 00:00:00 2001 From: Jasper de Vries Date: Tue, 23 May 2017 22:11:13 +0200 Subject: [PATCH] Documented poll JS start and added demo. --- .../net/bootsfaces/demo/PollDemoBean.java | 15 +- src/main/webapp/forms/PollAttributes.xhtml | 5 - src/main/webapp/forms/poll.xhtml | 333 +++++++++--------- 3 files changed, 185 insertions(+), 168 deletions(-) diff --git a/src/main/java/net/bootsfaces/demo/PollDemoBean.java b/src/main/java/net/bootsfaces/demo/PollDemoBean.java index 83e4d67b..a1872a54 100644 --- a/src/main/java/net/bootsfaces/demo/PollDemoBean.java +++ b/src/main/java/net/bootsfaces/demo/PollDemoBean.java @@ -2,17 +2,18 @@ import java.io.Serializable; import java.util.Date; - import javax.faces.bean.ManagedBean; -import javax.faces.bean.RequestScoped; +import javax.faces.bean.ViewScoped; import javax.faces.event.ActionEvent; -@RequestScoped +@ViewScoped @ManagedBean public class PollDemoBean implements Serializable { private static final long serialVersionUID = 1L; private int counter=0; + + private boolean stop; public Date getCurrentTime() { return new Date(); } @@ -24,6 +25,14 @@ public void setCounter(int counter) { this.counter = counter+1; } + public boolean isStop() { + return stop; + } + + public void setStop(boolean stop) { + this.stop = stop; + } + public void listener(ActionEvent event) { // System.out.println("Poll called me"); } diff --git a/src/main/webapp/forms/PollAttributes.xhtml b/src/main/webapp/forms/PollAttributes.xhtml index ceb4326e..e6c05e96 100644 --- a/src/main/webapp/forms/PollAttributes.xhtml +++ b/src/main/webapp/forms/PollAttributes.xhtml @@ -47,11 +47,6 @@ (none) How often is the poll action to be called? Denotes the number of milliseconds between polls. Default value is 1000. - - once - (none) - If true, the poll is called only once. Default value: false. - rendered false diff --git a/src/main/webapp/forms/poll.xhtml b/src/main/webapp/forms/poll.xhtml index 432435d2..726b0a11 100644 --- a/src/main/webapp/forms/poll.xhtml +++ b/src/main/webapp/forms/poll.xhtml @@ -1,187 +1,200 @@ + xmlns="http://www.w3.org/1999/xhtml" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:b="http://bootsfaces.net/ui" + xmlns:ui="http://java.sun.com/jsf/facelets"> - - -

Poll (<b:poll >)

+

Poll (<b:poll >)

-

- <b:poll /> - refreshes a part of the screen periodically. It can also call an action or an actionListener. -

-

Basic usage

- - - - - - - - - - - - - -
-
-
-
- -

AJAX

-

Prior to BootsFaces 1.1.2, the attributes update and execute where simply passed to the HTML code. - Since 1.1.2, they are evaluated by the advanced search expression engine of BootsFaces, as they should. However, this may - break programs relying on the bug (such as this showcase).

- -

JavaScript API

-

You can access the JavaScript API by setting the widgetVar attribute. This attribute is the name of the JavaScript - object implementing <b:poll /> on the client side. Currently, the public API consists of a single funktion:

-
    -
  • widgetVar.stop() allows you to stop polling from JavaScript.
  • -
- - - If <b:poll /> is inside the region it updates, you have to set the attribute once="true". Otherwise, - <b:poll /> is initialized over and over again and starts to send more and more polls until your server is saturated. - - - - - - - - - - - - - - -
-
-
-
- - - - Attributes of <b:poll > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDefault valueDescription
actionnoneCalls a JSF bean method and initiates a navigation.
actionListenernoneCalls an action listener in the JSF bean.
execute@noneWhich input fields are to be sent?
interval1000How often is the poll action to be called? Denotes the number of milliseconds between polls.
oncefalseIf true, the poll is called only once.
update@formWhich region of the screen is to be updated?
stopfalseIf true, the poll will stop.
widgetVarnoneOptional widget variable to access the datatable widget in JavaScript code.
-
+ + + + + + + Attributes of <b:poll > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDefault valueDescription
actionnoneCalls a JSF bean method and initiates a navigation.
actionListenernoneCalls an action listener in the JSF bean.
execute@noneWhich input fields are to be sent?
interval1000How often is the poll action to be called? Denotes the number of milliseconds between polls.
update@formWhich region of the screen is to be updated?
stopfalseIf true, the poll will stop.
widgetVarnoneOptional widget variable to access the datatable widget in JavaScript code.
+
- -
-
-
-
-
+
+
+
+
+