简体   繁体   English

primefaces commandButton“更新”不起作用

[英]primefaces commandButton “update” not working

I have this dialog: 我有这个对话框:

    <p:dialog 
        id="dlgComment"
        widgetVar="dialogComentario"
        modal="true"
        header="#{messages.comentarios}"
        width="600px"
        resizable="false" showEffect="clip" hideEffect="clip">
        <h:form id="formComentario">
            <p:panelGrid columns="2" style="width: 100%">
                <f:facet name="header">
                    <h:outputText value="#{monitorarEventoControlador.eventoSelecionado.titulo}"/>
                </f:facet>
                <h:outputText value="#{messages.inicio}" />  
                <h:outputText value="#{monitorarEventoControlador.eventoSelecionado.inicio}" />  

                <h:outputText value="#{messages.gravidade}" />  
                <h:outputText value="#{monitorarEventoControlador.eventoSelecionado.gravidade}" />  
            </p:panelGrid>
            <p:dataTable id="tableComentario" var="comentario" value="#{monitorarEventoControlador.eventoSelecionado.getComentariosAsList()}" emptyMessage="#{messages.noRecordsFound}">
                <f:facet name="header">
                    #{messages.comentarios}
                </f:facet>
                <p:column headerText="#{messages.dataHora}"> 
                    <h:outputText value="#{comentario.dataHora}">
                        <f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="#{monitorarEventoControlador.buscaTimeZone()}"/>
                    </h:outputText>
                </p:column>  
                <p:column headerText="#{messages.usuario}"> 
                    <h:outputText value="#{comentario.usuario.orgao.sigla} - #{comentario.usuario.apelido}"/>
                </p:column>  
                <p:column headerText="#{messages.texto}"> 
                    <h:outputText value="#{comentario.texto}" />  
                </p:column>  
            </p:dataTable>
            <p:panelGrid columns="2" style="width: 100%">
                <h:inputText value="#{monitorarEventoControlador.comentarioSelecionado.texto}" maxlength="80"/>
                <p:commandButton value="#{messages.comentar}" actionListener="#{monitorarEventoControlador.adicionarComentario()}" icon="ui-icon-check" update="tableComentario" />
            </p:panelGrid>
        </h:form>
    </p:dialog>

And the bean: 和豆:

    public void adicionarComentario() {
        comentarioSelecionado.setDataHora(new Date());
        comentarioSelecionado.setEvento(eventoSelecionado);
        comentarioSelecionado.setUsuario(autenticador.getUsuarioCorrente());
        todosOsComentarios.colocar(comentarioSelecionado);
        notificarComentario(comentarioSelecionado);
        eventoSelecionado.getComentarios().add(comentarioSelecionado);
        todosOsEventos.colocar(eventoSelecionado);
        iniciarComentario(eventoSelecionado);
    }

 private void notificarComentario(Comentario comentario) {
    Notificacao n = new Notificacao();
    n.setDataHora(comentario.getDataHora());
    n.setDescricao(DateUtil.dataHoraFormatada(n.getDataHora()) + " - " + comentario.getUsuario().getOrgao().getSigla() + "(" + comentario.getUsuario().getApelido() + "): " + comentario.getTexto());
    n.setComentario(true);
    n.setInforme(comentario.getEvento().getInforme());
    comentario.getEvento().getInforme().getNotificacoes().add(n);
}

public void iniciarComentario(Evento evento) {
    comentarioSelecionado = new Comentario();
    setEventoSelecionado(evento);
}

The commandButton should update a dataTable. commandButton应该更新一个dataTable。 I have just moved from Prime 3.5 to 5.1 and among other problems I managed to figure out, there is this one that's realy annoying. 我刚从Prime 3.5升级到5.1,我设法弄清的其他问题中,确实有一个令人讨厌。 It was working on Prime 3.5. 它正在Prime 3.5上运行。 To be more specific about what is going wrong here: The action is fired normaly, the data is inserted correctly, but the dataTable is no longer updated. 要更具体地说明这里出了什么问题:通常会触发该操作,正确插入数据,但不再更新dataTable。 It is the very same code I was using yesterday with Prime 3.5, but now, using Prime 5.1 the dataTable does not refresh anymore. 这与我昨天在Prime 3.5中使用的代码完全相同,但是现在使用Prime 5.1,dataTable不再刷新。
Any ideas ? 有任何想法吗 ? Thanks 谢谢

use : before id 使用 id之前


Remember 记得

if you make a dialog 如果您进行对话

  1. Before dialog old form tag should be close 在对话框之前,旧表格标签应关闭
  2. then dialog content should be placed into another form. 然后对话框内容应置于另一种形式。
  3. use :dialogid, :dialogFormId 使用:dialogid,:dialogFormId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM