9

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Guwanch
  • 375
  • 3
  • 6
  • 19

4 Answers4

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
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.

Community
  • 1
  • 1
Ioan
  • 5,152
  • 3
  • 31
  • 50
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