【问题标题】:Redirect to one page in all Clients (Each client is a SessionScoped ManagedBean)重定向到所有客户端中的一个页面(每个客户端都是一个 SessionScoped ManagedBean)
【发布时间】:2012-11-21 08:09:14
【问题描述】:

我有一个包含多个用户(客户端 1、客户端 2,...)的页面,我想按下按钮“Salir de reunion”(按钮 1)将我重定向到主页(http://localhost:8080/FasMe/faces/Public/ Inicio.xhtml) 在所有客户端上。

每个客户端都是一个 SessionScoped ManagedBean。

我只会被重定向到按下按钮的用户(客户端)的主页 (/Public/Inicio.xhtml)。 我想在所有客户端(浏览器)上进行重定向。我该怎么办?

ReunionActiva.xhtml

    <h:panelGrid id="reunionPanel" columns="2" >
            <h:commandButton value="Salir de Reunion" styleClass="btn" action="#{reunionBean.salirReunion}"  ></h:commandButton>                
    </h:panelGrid>

我的按钮“退出会议”的业务逻辑是:

ReunionManagedBean.java @ManagedBean(name="usuarioBean")

public String salirReunion(){

    Cuenta ctaCoordinador=participanteF.getCuentaReunion(reu, reuF.getCoordinadorReunion(reu.getIdReunion()));
    Cuenta ctaParticipante=ctaF.getCuentaByUsuario(usuarioActualBean.getCurrent(), ctaCoordinador.getServidorTareas());

    // If user is ADMIN then I want to delete all user of meeting and close de Meeting
    if(ctaCoordinador.getId().equals(ctaParticipante.getId())){
        Calendar cal = Calendar.getInstance();
        reu.setFechaFin(cal.getTime());
        reu.setEstado("Cerrada"); // It´s meaning setStatus CLOSE
        reuF.modificacionReunion(reu);

        List<CuentaHasReunion> p=participanteF.getAllParticipantes(reu);
        for (Object element : p) {
            CuentaHasReunion part= (CuentaHasReunion) element;
            participanteF.bajaParticipante(part); //Here I delete all user from meeting
            // Here is where I need to do the redirect to all Clients (Client1 , Client2)
         }
        ReunionSingleton.eliminarReunionActiva(reu);
    }
    // If user isn't ADMIN then I only delete user who click the button "salir reunion"
    else{
        participanteF.bajaParticipante(participanteF.getParticipante(ctaParticipante, reu));

    }

    return "/Public/Reunion.xhtml?faces-redirect=true";
}

【问题讨论】:

  • 在纯 JSF2/Ajax 中,定期调用组件/ajax 调用,检查会议是否仍然处于活动状态,如果不是,则导致重定向。在 Primefaces 中有一个组件实现了这一点,并显示为“从服务器向浏览器发送消息”,但我不记得它的名字,也没有使用过。

标签: java html ajax jsf jsf-2


【解决方案1】:

看看ICEfaces Push(似乎是这个街区的第一个孩子)和PrimeFaces Push。通常网络是基于请求的,所以每个客户端都需要请求刷新。我相信这些允许客户端通过 ajax 定期询问服务器上是否有任何有趣的请求数据包。如果服务器说是,客户端然后说更新我。无论如何,我认为这就是您可能正在寻找的。

如果您需要更同步的东西,您可能需要使用网络套接字或 RMI 来实现某些东西,也许是通过小程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-14
    • 2017-05-03
    • 1970-01-01
    • 2011-04-08
    • 2021-06-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多