在其他窗口/选项卡中更新组件,而无需手动刷新 [英] Update component in a different window/tab without manually refreshing it

查看:142
本文介绍了在其他窗口/选项卡中更新组件,而无需手动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的页面,它们具有不同的布局,例如index.xhtml和user.xhtml,每个页面都有自己的模板.如果我对user.xhtml进行了更改,我想更新index.xhtml中的数据表.

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:

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:

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>

因此,当我关闭user.xhtml时,我看到index.xhtml数据表已更新,而无需手动刷新.是否有可能 ?有什么方法可以实现这一目标?我看到有一种方法可以使用.

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 .

推荐答案

请参见 PrimeFaces用户指南以下选项.

  • p:poll组件(定期服务器轮询).
  • PrimeFaces Push(一种在Atmosphere框架之上的更通用的解决方案).
  • p:poll component (periodic server polling).
  • PrimeFaces Push (a more versatile solution on top of Atmosphere framework).

这篇关于在其他窗口/选项卡中更新组件,而无需手动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆