7
votes

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.

4

4 Answers

16
votes

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")
2
votes

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.

1
votes

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.

0
votes

It has changed from primefaces 7.0

PrimeFaces.current().ajax().update("elementJS");