-1

I have two buttons and two dialog, each button calls a dialog, each dialog has a save button, you send two different methods in the Bean. The problem is that it only works sending a dialog and not the other. xhtml

<h:form id='form1'>
    <p:panel id="basic" header="#{usuarioBean.nompagina}" footer="" style="margin-bottom:20px">
        <p:panelGrid columns="3" style="width: 100%">
            <p:commandButton value="Nuevo" icon="ui-icon-document" actionListener="#{menuBean.setAccion('Registrar')}" type="button" onclick="PF('dlg').show();" update=":dialog"/>
        </p:panelGrid>
            .......
            <p:column headerText="Acción">
                <p:commandButton value="Asignar Rol" actionListener="#{usuarioBean.leerUsuario(rowusu)}" oncomplete="PF('wdatosvar').show()" update=":wdatosid" icon="ui-icon-person"/>
            </p:column>
        </p:dataTable>
    </p:panel>
</h:form>

    <p:dialog position="center top" styleClass="ui-widget-container" id="dialog" header="Usuarios" widgetVar="dlg" dynamic="true" modal="true" width="400">
        <h:form>
        <p:panelGrid columns="2">
            ...
            <p:commandButton value="Guardar" actionListener="#{usuarioBean.inUsuario()}" oncomplete="handleDialogSubmit2(args)" update=":form1:listusuario" icon="ui-icon-check" />
            <p:commandButton value="Cancelar" immediate="true" onclick="PF('dlg').hide();" icon="ui-icon-cancel" />
            <p:outputLabel id="refresc" />
        </p:panelGrid>
        </h:form>
    </p:dialog>

    <p:dialog header="Datos" position="center top" widgetVar="wdatosvar" id="wdatosid" modal="true" showEffect="explode" hideEffect="explode">
        <h:form>
            <h:panelGrid columns="2">
                ...
                <p:commandButton value="Guardar" actionListener="#{usuarioBean.saveUsuario()}" oncomplete="handleDialogSubmit(xhr, status, args)"  update=":form1:listusuario,@form,refrescar" icon="ui-icon-check" />
                <p:commandButton value="Cancelar" immediate="true" onclick="PF('wdatosvar').hide();" icon="ui-icon-cancel" />
                <p:outputLabel id="refrescar" />
            </h:panelGrid>
        </h:form>
    </p:dialog>  

And usuarioBean.java

@ManagedBean
@SessionScoped
public class usuarioBean {
    public void saveUsuario() throws Exception {
        usuariohistorialDAO dao = new usuariohistorialDAO();
        try {
            dao.insertCredencial(usuariohis,value1);            
            this.listarUsuarios(palabra);
        } catch (Exception e) {
            throw e;
        }
    }

    public void inUsuario() throws Exception{
        usuariohistorialDAO dao = new usuariohistorialDAO();        
        try {
            dao.insertarUsuario(usuariohis);
            this.listarUsuarios(palabra);
        } catch (Exception e) {
            throw e;
        }
    }
}

inUsuario does no work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 'does not work' is like an end-user describing things. What do you as a developer see? What did you investigate? what is in all the ... does it still not work if you actually remove all what is in that place from the code? (that is what using ... suggests: it being not relevant – Kukeltje Jun 16 '16 at 18:54
  • It seems to be more a criticism of me, but I would like a collaboration to understand my problem code – Wilmer Hilaquita Jun 16 '16 at 19:04
  • It is 'constructive' criticism... all things mentioned in http://www.stackoverflow.com/tags/jsf/info and [mcve]. Thinks like you editing your post and removing the int parameter should not be needed (I almost metioned that it should be obivious why id did not work, and you should have errors, or more methods). There are even more things, like: does it work if you don't use dialogs? Is the code in the methods relevant (sysout would not be called either?) Did you read http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked etc : – Kukeltje Jun 16 '16 at 19:22
  • And all this is a 'collaboration' but it is now mainly to help you to improve your question so next questions are better from the start. All this makes it easier for us to help (our time IS limited, and there are few that actually help, so being grateful helps as does answering/acting on the comments)... Cheers – Kukeltje Jun 16 '16 at 19:29
  • Ok thanks, but back to my problem, you could help to identify the error code? – Wilmer Hilaquita Jun 16 '16 at 19:29
  • No since there is to much noise... Make an [mcve]. Then I can have a look. I suspect there are thing involved that you did not post. And e.g. #{usarioBean.nompagina} is not existant. Is that panel relevant for the problem at all? If not remove it. What I would do to try to reproduce is to copy paste all code you posted in a clean project and run it. Try that yourself. And please read all in the other question I referred to – Kukeltje Jun 16 '16 at 19:32

1 Answers1

-1

Do not know exactly why but this form solves my problem

<h:form id='form1'>
    <p:panel id="basic" header="Lista de Usuarios" footer="" style="margin-bottom:20px">
        <p:panelGrid columns="3" style="width: 100%">
            <p:commandButton value="Nuevo" icon="ui-icon-document" oncomplete="PF('dlg').show()" update=":dialog"/>
        </p:panelGrid>
        <p:inputText  value="#{usuarioBean.palabra}" id="search" class="inputmediano"/>
        <p:commandButton  value="Buscar" icon="ui-icon-refresh" actionListener="#{usuarioBean.bucarUsuario()}" update="listusuario"/>

        <p:dataTable tableStyleClass="ui-table-columntoggle" var="rowusu" value="#{usuarioBean.arrayusu}" paginator="true" paginatorPosition="bottom" rows="30"  id="listusuario" style="width: 100%;margin-top: 10px"  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
            <p:column headerText="Id" style="width: 25px">
                <h:outputText value="#{rowusu.ush_id}"/>
            </p:column>
            <p:column headerText="Usuario" >
                <h:outputText value="#{rowusu.usu_nombre}"/>
            </p:column>
            <p:column headerText="Sexo" >
                <h:outputText value="#{rowusu.usu_sexo}"/>
            </p:column>
            <p:column headerText="Nick">
                <h:outputText value="#{rowusu.ush_correo}" />
            </p:column> 
            <p:column headerText="Rol">
                <h:outputText value="#{rowusu.nomrol}"/>
            </p:column>
            <p:column headerText="Cargo">
                <h:outputText value="#{rowusu.nomcargo}"/>
            </p:column>
            <p:column headerText="Acción">
                <p:commandButton value="Asignar Rol" actionListener="#{usuarioBean.leerUsuario(rowusu)}" oncomplete="PF('wdatosvar').show()" update=":wdatosid" icon="ui-icon-person"/>
                <p:commandButton value="Modificar" actionListener="#{usuarioBean.leerUsuario(rowusu)}" oncomplete="PF('dlg').show()" update=":dialog" icon="ui-icon-person"/>
            </p:column>
        </p:dataTable>
    </p:panel>
</h:form>
  • Large parts of the code you post in this answer is not visible in the question. So there is no clue for anyone on what it actually solves. It might e.g. be that you changed something significantly that is not visible. Please, please please create a [mcve] in your origical question and and post the relevant difference **with comment** in the answer – Kukeltje Jun 17 '16 at 14:58
  • Perhaps you feel that you have no credit, if you're my friend, that the publication of the rules in PrimeFaces if helped me a lot. so stop worrying, if I give you credit. :) – Wilmer Hilaquita Jun 20 '16 at 20:02
  • I have no clue what you mean by all this... sorry, and no it is not about credit for me. – Kukeltje Jun 20 '16 at 20:45