Update ui components from server event

两盒软妹~` 提交于 2019-12-12 05:27:23

问题


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


回答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");



回答2:


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" />


来源:https://stackoverflow.com/questions/11656415/update-ui-components-from-server-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!