I use schedule(Timer) in bean which update variable when employees enrolling which get data from fingerprint device. I need to update component in jsf from backing bean when variable in bean updated. I try to use primefaces poll component but it update component every time.
Assuming you'll be calling a Java method using Listener from Fingerprint device API, and from ManagedBean you can update any Primefaces Component using RequestContext.
RequestContext.getCurrentInstance().update("ID_OF_YOUR_DATATABLE")
There's already a component in Primefaces, as you can see : here.
RequestContext is a feature with various handy utilities.
Update component(s) programmatically. Execute javascript from beans. Add ajax callback parameters. ScrollTo a specific component after ajax update.
Have a look here for an example.
I resolved my problem with primefaces push component.
java code is:
PushContext pushContext = PushContextFactory.getDefault().getPushContext();
pushContext.push("/finger", "Pressed");
in jsf:
<p:socket channel="/finger" onMessage="clearCookies" />
"clearCookies" is remoteCommand function which update my dataTable.
It has changed from primefaces 7.0
PrimeFaces.current().ajax().update("elementJS");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With