问题
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