0

How would I go about updating a UI component when a server process finishes or anytime else for that matter?

Can\Should I

  • extend the UI component and register some kind of EventListener on it?
  • bind the UI component in a backing bean?
  • use some of the new PrimePush features?
  • something else?

If anyone could guide me in the right direction I'd appreciate it.

Example Case One

Server process ends and updates the database.
I want to automatically update a DataTable with new rows based on the new information.
I don't want to poll for the new data.

EDIT

I want to update the UI component (a primefaces datatable) from an EJB Stateless Bean

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
feargal
  • 2,655
  • 2
  • 22
  • 27
  • Possible duplicate of [How can server push asynchronous changes to a HTML page created by JSF?](https://stackoverflow.com/questions/3787514/how-can-server-push-asynchronous-changes-to-a-html-page-created-by-jsf) – Kukeltje Aug 28 '17 at 11:06

2 Answers2

1

You didnt mention which version of primefaces you are using but you can update components from backed bean with addpartialupdatetarget.

RequestContext context = RequestContext.getCurrentInstance();
context.addPartialUpdateTarget("myForm:myComponent");
HRgiger
  • 2,750
  • 26
  • 37
0

You can just use the update attribute of your commandButton or whatever else you're using.

Something like this should work

<p:dataTable value="#{backer.bean}" id="table">
  // columns with data
</p:dataTable>

<p:commandButton actionListener="#{backer.updateDB}" update="table" />
Catfish
  • 18,876
  • 54
  • 209
  • 353
  • How do I fire "click"/fire the commandButton from an EJB? Did you read the question correctly? If so could you expand on this solution. – feargal Aug 09 '12 at 14:26