Update component in a different window/tab without manually refreshing it

非 Y 不嫁゛ 提交于 2019-12-25 02:57:08

问题


I have different pages with different layouts, for example index.xhtml and user.xhtml, each page has it's own template. If I make a change in user.xhtml I want to update a datatable in index.xhtml.

index.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:p="http://primefaces.org/ui">
<ui:composition template="/template.xhtml">
    <ui:define name="body">
 <h:form id="indexFormId">
         <p:dataTable id="datalist" value="#{userController.items}"var="item" widgetVar="userWidget">
 -----datatable columns and rows with user data------
 </p:datatable>
 </h:form>

user.xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templateB.xhtml">

    <ui:define name="body">
 <h:form>
 <p:commandButton value="Modify User" actionListner="some action" update=":thisForm, :indexFormId"/>
 </h:form>

So when I close user.xhtml i see index.xhtml datatable updated without ask for a manually refresh. Is it possible ? There are some way to achieve this ? I see that there is a way to do that with the same template using .


回答1:


See the PrimeFaces User Guide on the following options.

  • p:poll component (periodic server polling).
  • PrimeFaces Push (a more versatile solution on top of Atmosphere framework).


来源:https://stackoverflow.com/questions/30235793/update-component-in-a-different-window-tab-without-manually-refreshing-it

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