I try to get a confirmation dialog when i deselect an item from a mutli-select p:selectManyMenu.
<p:outputLabel for="ccs" value="CS" styleClass="toplabel"/>
<p:selectManyMenu id="ccs" value="#{ccView.selectedCSs}"
var="cs" filter="true" filterMatchMode="contains" showCheckbox="true">
<p:ajax event="change" listener="#{ccView.onCSChanged}" />
<f:selectItems value="#{ccView.CSs}" var="source" itemLabel="#{source.name}" itemValue="#{source}" />
<p:column>
<h:outputText value="#{cs.name}" />
</p:column>
</p:selectManyMenu>
now, if an item is deselected (checkbox change to unchecked) i want to show a confirmation dialog.
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
I tried it with ajax events like "unselect", "deselect", "rowUnselect"..
any idea?
Related
This is what I've got:
<p:growl id="message" showDetail="true" />
<p:commandButton value="delete user" actionListener="#{bean.deleteUser(user)}" update="#form">
<p:confirm header="Confirm" message="Are you sure to delete #{user.username}?" icon="ui-icon-alert" />
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="yes" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
</p:confirmDialog>
The variable #{user.username} won't be shown at all.
what am I doing wrong?
I have a strange problem with Primefaces' confirm Dialog.
What I need is a confirmation dialog that displays some variables im my Bean, working in a modal dialog window and firing a Bean method. But it seems I can't get the 3... :-(
Here is what I've been trying:
<p:confirmDialog header="Aviso de Confirmação"
closable="false"
appendToBody="true"
global="false"
showEffect="fade"
hideEffect="fade"
widgetVar="confirmDlg">
<h:form>
<f:facet name="message">
<h:outputText value="Confirma o registro de desistência do candidato(a) #{registrosCandidatoBean.candidatoInclusaoDesistencia.inscricao} - #{registrosCandidatoBean.candidatoInclusaoDesistencia.papelPessoa.pessoaFisica.nomeCompleto}?" />
</f:facet>
<p:commandButton value="Sim"
styleClass="ui-confirmdialog-yes"
icon="ui-icon-check"
action="#{registrosCandidatoBean.gravarDesistencia()}"
update=":formDesistencia :formMensagem:mensagemFixa"
ajax="false"
immediate="true" />
<p:commandButton value="Não"
styleClass="ui-confirmdialog-no"
icon="ui-icon-close"
onclick="confirmDlg.hide();" />
</h:form>
</p:confirmDialog>
*** This one displays the message and calls the method. But the "message" in f:facet is not displayed. Id I use the normal "message" attribute, It doesn't use the variables in my bean.
<p:confirmDialog header="Aviso de Confirmação"
closable="false"
appendToBody="true"
global="false"
showEffect="fade"
hideEffect="fade"
widgetVar="confirmDlg">
<f:facet name="message">
<h:outputText value="Confirma o registro de desistência do candidato(a) #{registrosCandidatoBean.candidatoInclusaoDesistencia.inscricao} - #{registrosCandidatoBean.candidatoInclusaoDesistencia.papelPessoa.pessoaFisica.nomeCompleto}?" />
</f:facet>
<p:commandButton value="Sim"
styleClass="ui-confirmdialog-yes"
icon="ui-icon-check"
action="#{registrosCandidatoBean.gravarDesistencia()}"
update=":formDesistencia :formMensagem:mensagemFixa"
ajax="false"
immediate="true" />
<p:commandButton value="Não"
styleClass="ui-confirmdialog-no"
icon="ui-icon-close"
onclick="confirmDlg.hide();" />
</p:confirmDialog>
*** This one displays the message and "message" in f:facet. But any Bean methods aren't called.
<p:confirmDialog header="Aviso de Confirmação"
closable="false"
global="false"
showEffect="fade"
hideEffect="fade"
widgetVar="confirmDlg">
<f:facet name="message">
<h:outputText value="Confirma o registro de desistência do candidato(a) #{registrosCandidatoBean.candidatoInclusaoDesistencia.inscricao} - #{registrosCandidatoBean.candidatoInclusaoDesistencia.papelPessoa.pessoaFisica.nomeCompleto}?" />
</f:facet>
<p:commandButton value="Sim"
styleClass="ui-confirmdialog-yes"
icon="ui-icon-check"
action="#{registrosCandidatoBean.gravarDesistencia()}"
update=":formDesistencia :formMensagem:mensagemFixa"
ajax="false"
immediate="true" />
<p:commandButton value="Não"
styleClass="ui-confirmdialog-no"
icon="ui-icon-close"
onclick="confirmDlg.hide();" />
</p:confirmDialog>
*** This one displays the message and "message" in f:facet. Apparently it calls the Bean methods, but I can't test it since the dialog is greyed and I can't click the buttons.
Can it work the way I need?
Primefaces 4.0
Thanks! :)
for the third scenario, try adding;
appendTo="#(body)"
I have a problem related to a <p:contextMenu> within a <p:dataTable> of PrimeFaces. There is a <p:commandLink> and also some command buttons within columns in this table, when I open the context menu automatically inserted is the value of that column my variable, but the problem is this when I open this <p:contexMenu> menu by clicking the right button on top of one of these link command or command button the value of this column is not passed to variable.
This is my code.
<h:form id="form-arquivo-listar">
<p:contextMenu id="menuArquivos" for="dataArquivos">
<p:menuitem value="Baixar" icon="ui-icon-disk" url="../../arquivos/#{arquivoBean.arquivoSelecionado.nome}" target="arquivo"/>
<p:menuitem value="Excluir" icon="ui-icon-close" actionListener="#{arquivoBean.excluir()}" update="form-arquivo-listar"/>
<p:menuitem value="Transferir" icon="ui-icon-extlink" actionListener="#{arquivoBean.getPastas()}" update=":formArquivoTransferir:treeArquivos" oncomplete="PF('arquivoTransferirDialog').show()"/>
</p:contextMenu>
<p:menubar model="#{arquivoBean.menu}"/>
<p:dataTable id="dataArquivos" value="#{arquivoBean.objetos}" var="o" rowKey="#{o.id}" selection="#{arquivoBean.arquivoSelecionado}" selectionMode="single" styleClass="ui-datatable-no-border">
<f:facet name="header">#{text['arquivo.pagina.listar.titulo']}</f:facet>
<p:column style="width: 20px">
<i class="#{o.tipo.icone}"></i>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.nome']}" rendered="#{o.tipo.id != 5}">
<p:link value="#{o.nomeOriginal}" href="../../arquivos/#{o.nome}" target="arquivo">
</p:link>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.nome']}" rendered="#{o.tipo.id == 5}">
<p:commandLink styleClass="link" id="link" value="#{o.nomeOriginal}" actionListener="#{arquivoBean.alterarPasta(o.id)}" update=":form-arquivo-listar" >
</p:commandLink>
</p:column>
<p:column headerText="#{text['arquivo.pagina.form.publico']}" style="width: 50px">
<h:outputText value="#{o.publico ? 'Sim' : 'Não'}" rendered="#{o.tipo.id != 5}"/>
</p:column>
<p:column style="width: 26px">
<p:commandButton id="editarButton" title="Exibir" icon="ui-icon-search" update=":form-arquivo-listar:arquivo-detalhes" oncomplete="PF('arquivoDialog').show()" rendered="#{o.tipo.id != 5}">
<f:setPropertyActionListener value="#{o}" target="#{arquivoBean.objeto}" />
</p:commandButton>
</p:column>
<p:column style="width: 26px">
<p:commandButton icon="ui-icon-pencil" oncomplete="PF('cadastroArquivo').show()">
<f:setPropertyActionListener value="#{o}" target="#{arquivoBean.objeto}" />
</p:commandButton>
</p:column>
<p:column style="width: 26px">
<p:commandButton id="excluirButton" title="#{text['arquivo.pagina.form.confirmacao.botao.titulo']}" icon="ui-icon-close" update=":form-arquivo-listar" actionListener="#{arquivoBean.excluir(o.id)}">
<p:confirm header="#{text['arquivo.pagina.form.confirmacao.titulo']}" icon="ui-icon-alert" message="#{text['arquivo.pagina.form.confirmacao.mensagem']}" />
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton icon="ui-icon-check" value="#{text['arquivo.pagina.form.confirmacao.sim']}" type="button" styleClass="ui-confirmdialog-yes" />
<p:commandButton icon="ui-icon-close" value="#{text['arquivo.pagina.form.confirmacao.nao']}" type="button" styleClass="ui-confirmdialog-no" />
</p:confirmDialog>
</p:column>
</p:dataTable>
<p:dialog id="arquivo-detalhes" widgetVar="arquivoDialog">
<h:panelGrid columns="2" cellpadding="4" style="margin:0 auto;">
<h:outputLabel value="#{text['arquivo.pagina.form.id']}:" />
<h:outputText value="#{arquivoBean.objeto.id}" />
<h:outputLabel value="#{text['arquivo.pagina.form.arquivo']}:" />
<h:graphicImage value="../../arquivos/#{arquivoBean.objeto.nome}" width="200" rendered="#{arquivoBean.isImagem()}" />
<p:media value="../../arquivos/#{arquivoBean.objeto.nome}" width="200" height="80" player="quicktime" rendered="#{arquivoBean.isAudio()}" />
<p:media value="../../arquivos/#{arquivoBean.objeto.nome}" width="300" height="300" rendered="#{arquivoBean.isVideo()}"/>
</h:panelGrid>
</p:dialog>
</h:form>
<p:dialog id="arquivoTransferirDialog" widgetVar="arquivoTransferirDialog">
<h:form id="formArquivoTransferir">
<p:growl id="msg" showDetail="false"/>
<h:panelGrid columns="1">
<p:tree id="treeArquivos" value="#{arquivoBean.raiz}" var="arquivo" selection="#{arquivoBean.raizSelecionada}" selectionMode="single">
<p:treeNode expandedIcon="ui-icon ui-icon-folder-open" collapsedIcon="ui-icon ui-icon-folder-collapsed">
<h:outputText value="#{arquivo.nomeOriginal}" />
</p:treeNode>
</p:tree>
<h:panelGrid columns="2">
<p:commandButton value="Transferir" actionListener="#{arquivoBean.transferirArquivo()}" oncomplete="PF('arquivoTransferirDialog').hide()" update="formArquivoTransferir, :form-arquivo-listar:dataArquivos"/>
<p:commandButton value="Cancelar" onclick="PF('arquivoTransferirDialog').hide()"/>
</h:panelGrid>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="arquivoCriarPasta" widgetVar="arquivoCriarPasta">
<h:form id="formCriarPasta">
<p:growl id="msg" showDetail="false"/>
<h:panelGrid columns="2">
<h:outputText value="Nome" />
<p:inputText value="#{arquivoBean.objeto.nomeOriginal}" required="true"/>
<h:column/>
<h:panelGrid columns="2">
<p:commandButton value="Salvar" actionListener="#{arquivoBean.salvarPasta()}" update="formCriarPasta,:form-arquivo-listar:dataArquivos" oncomplete="PF('arquivoCriarPasta').hide()"/>
<p:commandButton value="Cancelar" onclick="PF('arquivoCriarPasta').hide()"/>
</h:panelGrid>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="cadastroArquivo" header="#{text['arquivo.pagina.editar.titulo']}" widgetVar="cadastroArquivo" >
<h:form id="form-arquivo-editar" enctype="multipart/form-data">
<p:growl id="msg" showDetail="false"/>
<h:inputHidden value="#{arquivoBean.objeto.id}" rendered="#{arquivoBean.objeto.id!=null}" />
<h:panelGrid columns="2" style="margin:20px">
<p:outputLabel value="#{text['arquivo.pagina.form.arquivo']}" for="inputArquivo" />
<p:fileUpload id="inputArquivo" value="#{arquivoBean.file}" required="true" label="#{text['arquivo.pagina.form.arquivo']}" mode="simple"
disabled="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<p:outputLabel value="#{text['arquivo.pagina.form.nome']}" rendered="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<h:outputText value="#{arquivoBean.objeto.nomeOriginal}" rendered="#{arquivoBean.objeto.id!=null and arquivoBean.objeto.id!=0}" />
<p:outputLabel value="#{text['arquivo.pagina.form.descricao']}" for="inputDescricao" />
<p:inputTextarea id="inputDescricao" value="#{arquivoBean.objeto.descricao}" />
<p:outputLabel value="#{text['arquivo.pagina.form.publico']}" for="inputPublico" />
<p:selectBooleanCheckbox id="inputPublico" value="#{arquivoBean.objeto.publico}" />
<p:outputLabel value="#{text['arquivo.pagina.form.tipo']}" for="inputTipo" />
<p:selectOneMenu id="inputTipo" value="#{arquivoBean.objeto.tipo}" required="true" label="#{text['arquivo.pagina.form.tipo']}"
converter="#{arquivoTipoBean.converter()}">
<f:selectItem itemLabel="#{text['arquivo.pagina.form.tipo.default']}" />
<f:selectItems value="#{arquivoTipoBean.selectObjetos}" />
</p:selectOneMenu>
</h:panelGrid>
<h:panelGrid columns="2" style="margin-bottom:10px">
<p:commandButton value="#{text['arquivo.pagina.form.salvar']}" update=":form-arquivo-editar,:form-arquivo-listar"
process="#form" actionListener="#{arquivoBean.salvar}" ajax="false" />
</h:panelGrid>
</h:form>
</p:dialog>
the method remove is called either I click YES or NO.
How can I tell if NO is pressed ?
<p:commandLink actionListener="#{mybean.remove}"
ajax="false"
>
<p:confirm header="Confirm" message="Are you sure?" icon="ui-icon-alert"></p:confirm> <h:graphicImage value="images/erasebig.png" />
</p:commandLink>
<p:confirmDialog id="dialog" global="true" showEffect="fade" hideEffect="explode" message="Are you sure?">
<p:commandButton value="Yes" type="button"
styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
/>
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-close" />
</p:confirmDialog>
Put styleClass="ui-confirmdialog-no" on the no-button and mybean.remove() wont be called
I have a Form to add a new user. I am using Validator messages to control empty fields. If I enter invalid data and submit the form, error messages were displayed. After that I click on reset button, it doesn't work.
This my code in html:
<h:form id="newCustomerForm">
<p:dialog draggable="true" header="New Customer" widgetVar="customerDialogNew" resizable="false"
showEffect="clip" hideEffect="fold" style="position: absolute ;" id="dialog2">
<p:panelGrid id="newCustomer" columns="6" >
<f:facet name="header">
<p:graphicImage value="../../pictures/customerAdd.jpg"/>
</f:facet>
<p:outputLabel value="Name:" for="name" />
<p:inputText id="name" value="#{customerMB.name}" title="Name" required="true" requiredMessage="The Name field is required."/>
<p:message for="name" />
<p:outputLabel value="FamilyName:" for="familyName" />
<p:inputText id="familyName" value="#{customerMB.familyName}" title="FamilyName" required="true" requiredMessage="The FamilyName field is required."/>
<p:message for="familyName" />
</p:panelGrid>
<p:commandButton type="reset" immediate="true" update="newCustomerForm" value="Clear" icon="ui-icon-arrowrefresh-1-n" styleClass="ui-priority-primary">
</p:commandButton>
<p:commandButton value="Save" ajax="false" icon="ui-icon-circle-check" styleClass="ui-priority-primary" action="#{customerMB.addCustomer()}" />
</p:dialog>
</h:form>