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.
Asked
Active
Viewed 4.1k times
4 Answers
17
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")

Kishor Prakash
- 8,011
- 12
- 61
- 92
-
1In Primefaces 7.0 (2019) is import org.primefaces.PrimeFaces; PrimeFaces.current().ajax().update("Element ID"); – Hernaldo Gonzalez Sep 03 '19 at 13:49
2
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.
2
It has changed from primefaces 7.0
PrimeFaces.current().ajax().update("elementJS");

manelseo
- 587
- 4
- 6
1
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.

Guwanch
- 375
- 3
- 6
- 19
-
I had also followed this approach. Invoking `remoteCommand`'s javascript function on `onMessage` of `p:socket`. – Parkash Kumar Aug 15 '17 at 12:26