jsf 2 - How to set start time for primefaces clock widget? -
is possible set start time primefaces clock widget? know analog clock primefaces extensions, need digital clock option. have tried override javascript method clock, doesn't work.
primefaces.widget.clock = primefaces.widget.basewidget.extend({ init: function(cfg) { this._super(cfg); this.cfg.value = 1430304817141; this.current = this.isclient() ? new date() : new date(this.cfg.value); var $this = this; }, isclient: function() { return this.cfg.mode === 'client'; }, });
the first problem overriding widget late, after primefaces has instantiated original unmodified widget. according primefaces customizable resource ordering right place override in h:head
.
second problem you're overriding widget crippled version, doesn't contain many necessary functions present in original widget.
i wouldn't recommend approach @ - break whole primefaces widget that. if you'd want use normal unchanged clock? copy-pasted code harder maintain too. advise going more localized approach: tweak single widget instance.
<p:clock id="my_clock" /> <script> // widgetvar via el function, since p:clock doesn't have widgetvar attribute var myclockvar = #{p:widgetvar('my_clock')}; myclockvar.current = new date(1430304817141); </script>
just careful not update clock ajax requests, or reset showing client time; , not update script, or clock reset specified time again.
Comments
Post a Comment