• 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 Display

The value of the Timer can be formatted or hidden. 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
Interval format

Display the remaining time as seconds (default), percentage, human text, localized, with a custom moment.js pattern, or via a formatFunction. The script below sets moment.js locales globally, which is why this example is on a page without other formatted timers.

DefaultPercentageHumanLocale (de)CustomCustom with locale (fr)Function
Invisible

With visible="false" the timer is rendered but hidden. Use the ontimerstep client callback to update your view, here a Knob that acts like a timer.

Usage


<div class="card">
    <h5>Interval format</h5>
    <p>Display the remaining time as seconds (default), <code>percentage</code>, <code>human</code> text, localized, with a custom moment.js pattern, or via a <code>formatFunction</code>. The script below sets moment.js locales globally, which is why this example is on a page without other formatted timers.</p>
    <h:form id="formFormat">
        <h:panelGrid columns="7">
            <h:outputText value="Default"/>
            <h:outputText value="Percentage"/>
            <h:outputText value="Human"/>
            <h:outputText value="Locale (de)"/>
            <h:outputText value="Custom"/>
            <h:outputText value="Custom with locale (fr)"/>
            <h:outputText value="Function"/>
            <pe:timer
                timeout="1000"/>
            <pe:timer
                timeout="1000"
                format="percentage"/>
            <pe:timer
                timeout="1000"
                format="human"/>
            <pe:timer
                timeout="1000"
                format="human"
                locale="de"/>
            <pe:timer
                timeout="1000"
                format="HH:mm:ss"/>
            <pe:timer
                timeout="1000"
                format="MMMM"
                locale="fr_FR"/>
            <pe:timer
                timeout="1000"
                formatFunction="return formatMe(value);"/>
        </h:panelGrid>
    </h:form>
    <script>
        window.formatMe = function(value){
            return "The End is near (" + value + ")";
        };
        moment.locale('de', { relativeTime : { mm : '%d minuten' } });
        moment.locale('fr', { months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_') });
    </script>
</div>

<div class="card">
    <h5>Invisible</h5>
    <p>With <code>visible="false"</code> the timer is rendered but hidden. Use the <code>ontimerstep</code> client callback to update your view, here a Knob that acts like a timer.</p>
    <h:form id="formInvisible">
        <pe:timer
            visible="false"
            ontimerstep="sync(intervalData)"
            ontimercomplete="alert('BOOM')"
            timeout="100"/>
        <p:knob
            min="0"
            max="100"
            widgetVar="knobInvisible"
            disabled="true"
            value="0"/>
    </h:form>
    <script>
        window.sync = function(t){
            PF('knobInvisible').setValue(t.current);
        }
    </script>
</div>