Change object in p:dialog taking object from datatable primeFaces

Asked

Viewed 92 times

0

I have a DataTable with a button to add a note to the service.

I can pick up the object, step to the Dialog, but my save button does not upadate the object

<body>
    <ui:composition template="/paginas/template/template.xhtml">
        <ui:define name="conteudo">
            <h:form id="formFicha">
      <p:tabView id="Tabficha" scrollable="true"...>
           <body>
    <ui:composition template="/paginas/template/template.xhtml">
        <ui:define name="conteudo">
            <h:form id="formFicha">
      <p:tabView id="Tabficha" scrollable="true"...>
          <p:tab>    
          </p:tab> 
        <p:tab id="tabAndamento" title="Proc.Andamento">
            <h:form id="frmProcedimentosAndamento">

                <p:dataTable id="dataInsereProcedimentosAndamento"
                    tabindex="6" emptyMessage="Nenhum registro encontrado"
                    var="pro"
                    value="#{fichaConsultaControlador.listaProcedimentosAndamento()}"
                    paginator="true" rows="10" style="margin:10px 0px 0px 0px">

                    <f:facet name="header">
                              Precedimentos em Andamento
                      </f:facet>

                    <p:column style="width:10px;">
                        <f:facet name="header">
                            <div align="center">
                                <h:outputText style="font-size:14px" value="ID" />
                            </div>
                        </f:facet>
                        <h:outputText style="font-size:14px" value="#{pro.id}" />
                    </p:column>

                    <p:column style="width:70px;">
                        <f:facet name="header">
                            <h:outputText style="font-size:14px" value="Região" />
                        </f:facet>
                        <h:outputText style="font-size:14px"
                            value="#{pro.regiao}" />
                    </p:column>

                    <p:column style="width:100px;">
                        <f:facet name="header">
                            <h:outputText style="font-size:14px" value="Serviço" />
                        </f:facet>
                        <h:outputText style="font-size:14px"
                            value="#{pro.servico.nome}" />
                    </p:column>                     



                    <p:column style="width:30px">
                        <f:facet name="header">

                        </f:facet>
                        <p:commandButton icon="ui-icon-search" title="pesquisa"
                            update=":formFichaPaciente:formDialogObs"
                            style="width:25px; height:25px"

                            oncomplete="PF('dObservacao').show();" 
                            process="@this">
                             <f:setPropertyActionListener value="#{pro}" target="#{fichaConsultaControlador.servicoNaFicha}" />
                        </p:commandButton>
                    </p:column>
                </p:dataTable>
            </h:form>
        </p:tab>

Within the same formPrincipal I do the Dialog

<p:dialog header=" Observação do Procedimento" closable="true"
             widgetVar="dObservacao"
            position="center" resizable="false">

             <h:form id="formDialogObs" >
                <p:messages id="dialogMessages" style="font-size:14px" autoUpdate="true"
                    closable="true" />
                <div>
                    <h:panelGrid columns="2" style="margin:0px 0px 0px 10px">

                        <h:column>
                            <div>
                                <h:outputLabel style="margin:0px 0px 5px 0px" value="ID: " />

                                <h:outputText size="10" tabindex="2"
                                    style="margin:0px 5px 0px 0px; color:blue"
                                    value="#{fichaConsultaControlador.servicoNaFicha.id}">

                                </h:outputText>
                            </div>
                        </h:column>

                    </h:panelGrid>

                    <h:panelGrid columns="2" style="margin:0px 0px 0px 10px">
                        <h:column>
                            <div>
                                <h:outputLabel style="margin:0px 0px 5px 0px"
                                    value="Procedimento: " />

                                <h:outputText size="20" tabindex="3"
                                    style="margin:0px 5px 0px 0px;color:blue"
                                    value="#{fichaConsultaControlador.servicoNaFicha.servico.nome}" />
                            </div>
                        </h:column>
                    </h:panelGrid>


                    <h:panelGrid columns="2" style="margin:0px 0px 0px 10px">
                        <h:column>
                            <div>
                                <h:outputLabel style="display:block;margin:0px 0px 5px 0px"
                                    value="Observacao" />

                                <p:inputTextarea id="obs"
                                    value="#{fichaConsultaControlador.servicoNaFicha.observacao}"
                                    style="font-size:14px" rows="4" cols="50" />
                            </div>
                        </h:column>
                    </h:panelGrid>

                </div>
                <p:commandButton value="Salvar"
                    style="margin:10px 8px 0px 10px;width:120px;background-image:none;background-color:lightgreen;border:none!important"
                    action="#{fichaConsultaControlador.salvarservicoNaFicha}"

                    process="@this"
                    >
                </p:commandButton>


        </h:form>       
        </p:dialog>

The save method:

public void salvarServicoNaFicha(){     
    servicoNaFichaServico.salvar(servicoNaFicha);       
}

I can call the dialog with the information, but when I type a note and click save does not update.

  • But does it update the object? If you update the screen, the information appears updated?

  • Thank you for having responded Marcus Martins. I delayed the reply, but the data came up to date. I think it was some problem in Dependency Injection. I changed and made the change in the object. See you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.