• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

Timer Basic

Timer fires a JSF listener after a customizable interval. It also provides a JavaScript API to start, pause and stop the timer.

Timer Tag Documentation

Timer Component

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
async boolean false false When set to true, ajax requests are not queued.
autoStart boolean false true If true, timer starts automatically.
delay String false If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded. If this option is not specified, or if the value of delay is the literal string 'none' without the quotes, no delay is used.
form String false The enclosing form Form to serialize for an ajax request.
format String false Display format.
formatFunction String false Client-side function used to format the remaining duration.
forward boolean false false Timer direction, true is forward.
global boolean false true Global ajax requests are listened by ajaxStatus component, setting global to false will not trigger ajaxStatus.
ignoreAutoUpdate boolean false false If true, components which autoUpdate="true" will not be updated for this request. If not specified, or the value is false, no such indication is made.
ignoreComponentNotFound boolean false false If true, unresolvable components (ComponentNotFoundException) referenced in the update/process attribute are ignored.
immediate boolean false false Determines the phaseId, true means APPLY_REQUEST_VALUES, false means INVOKE_APPLICATION.
interval int false 1000 Interval in milliseconds.
listener MethodExpression false A method expression to invoke by polling.
locale Object false String or Locale representing user locale.
oncomplete String false Client-side javascript callback to execute when ajax request is completed.
onerror String false Client-side javascript callback to execute when ajax request fails.
onstart String false Client-side javascript callback to execute before ajax request begins.
onsuccess String false Client-side javascript callback to execute when ajax request succeeds.
ontimercomplete String false JavaScript callback before timer completion.
ontimerstep String false JavaScript callback on each timer step.
partialSubmit boolean false false Enables serialization of values belonging to the partially processed components only.
partialSubmitFilter String false Selector to use when partial submit is on, default is ":input" to select all descendant inputs of a partially processed components.
process String false Component(s) to process in partial request.
resetValues boolean false false If true, local values of input components to be updated within the ajax request would be reset.
singleRun boolean false true When true, timer executes once and stops.
style String false Inline style of the component.
styleClass String false Style class of the component.
timeout int false 10 Timeout in seconds.
title String false Title rendered on the timer element.
update String false Component(s) to update with ajax.
visible boolean false true Controls visibility.
Tag Documentation Widget Source Basic Display
Basic usage

The interval is set via timeout. Set singleRun to false to make it periodic; the listener fires every 5 seconds here.

Direction

Choose the direction of the timer with the forward attribute.

ForwardBackward
JS Api

The timer can be controlled from JavaScript: start, pause, restart and stop. When stopping, pass true to stop silently and skip the JSF listener.


Usage


<div class="card">
    <h5>Basic usage</h5>
    <p>The interval is set via <code>timeout</code>. Set <code>singleRun</code> to <code>false</code> to make it periodic; the listener fires every 5 seconds here.</p>
    <h:form id="formBasic">
        <p:messages id="messages" showSummary="true" showDetail="true"/>

        <pe:timer
            timeout="5"
            singleRun="false"
            listener="#{basicTimerController.onTimeout}"
            update="messages"
            style="color: red;"/>
    </h:form>
</div>

<div class="card">
    <h5>Direction</h5>
    <p>Choose the direction of the timer with the <code>forward</code> attribute.</p>
    <h:form id="formDirection">
        <h:panelGrid columns="2">
            <h:outputText value="Forward"/>
            <h:outputText value="Backward"/>
            <pe:timer
                timeout="1000"
                forward="true"/>
            <pe:timer
                timeout="1000"
                forward="false"/>
        </h:panelGrid>
    </h:form>
</div>

<div class="card">
    <h5>JS Api</h5>
    <p>The timer can be controlled from JavaScript: start, pause, restart and stop. When stopping, pass <code>true</code> to stop silently and skip the JSF listener.</p>
    <h:form id="formJsApi">
        <p:messages id="messages" showSummary="true" showDetail="true"/>

        <pe:timer
            widgetVar="timerJsApi"
            timeout="10000"
            forward="true"
            listener="#{jsApiTimerController.listener}" update="messages"
            singleRun="false"/>
        <hr/>
        <p:commandButton value="Start" onclick="PF('timerJsApi').start()" type="button"/>
        <p:commandButton value="Pause" onclick="PF('timerJsApi').pause()" type="button"/>
        <p:commandButton value="Restart" onclick="PF('timerJsApi').restart()" type="button"/>
        <p:commandButton value="Stop" onclick="PF('timerJsApi').stop()" type="button"/>
        <p:commandButton value="Stop (Silent)" onclick="PF('timerJsApi').stop(true)" type="button"/>
    </h:form>
</div>