I have this dialog:
The code for this dialog:
<p:dialog header="Détails du produit" showEffect="fade" modal="true"
widgetVar="manageProductDialog" responsive="true">
<p:outputPanel id="manage-product-content" class="ui-fluid">
<p:outputPanel rendered="#{not empty productMB.selectedProduct}">
<p:graphicImage
name="images/product/#{productMB.selectedProduct.img}"
library="demo" styleClass="product-image"
rendered="#{not empty productMB.selectedProduct.img}" />
<div class="p-field">
<p:outputLabel for="name">Nom</p:outputLabel>
<p:inputText id="name" value="#{productMB.selectedProduct.name}"
required="true" />
</div>
<div class="p-field">
<p:outputLabel for="category">Catégorie</p:outputLabel>
<p:selectOneMenu id="category"
value="#{productMB.selectedProduct.category}"
layout="responsive">
<f:selectItem itemLabel="Select One" itemValue="#{null}" noSelectionOption="true" />
<f:selectItems value="#{categoryMB.categories}" var="cat" itemValue="#{cat}" itemLabel="#{cat.name}" />
</p:selectOneMenu>
</div>
<div class="p-formgrid p-grid">
<div class="p-field p-col">
<p:outputLabel for="price">Prix</p:outputLabel>
<p:inputNumber id="price"
value="#{productMB.selectedProduct.price}" symbol=" DH"
symbolPosition="s" decimalSeparator="." thousandSeparator="," />
</div>
</div>
</p:outputPanel>
</p:outputPanel>
<f:facet name="footer">
<p:commandButton value="Enregister" icon="pi pi-check"
actionListener="#{productMB.saveProduct}"
update="manage-product-content"
process="manage-product-content #this" />
<p:commandButton value="Annuler" icon="pi pi-times"
onclick="PF('manageProductDialog').hide()"
class="ui-button-secondary" />
</f:facet>
</p:dialog>
The problem I have is that when I click on Enregister button the p:selectOneMenu is not validated even that a value was selected.
How can I solve this issue ?
Related
I implement a <h:form> to edit Employee data which gets preloaded from the database. The preload works fine - all fields get filled with data. The <h:form id="editEmployeeForm"> is surrounded by a <h:form> which contains a <p:dataTable>.
When I do an edit on Employee data and click the "Speichern"-button nothing happens. <p:messages> says all my fields are empty what is obviously a wrong validation because all fields are prefilled. Then I deleted all <p:message> tags from my <h:inputText> tags to check whether the doSaveEmployeeEdit() gets called at all. But nothing happens - no error in console, etc. Even a simple System.out.println() doesn't get printed from the doSaveEmployeeEdit() at all.
Below the <p:dialog> what I have at the time:
<h:form id="editEmployeeForm">
<p:dialog header="Angestellten ändern" id="employeeEditDialog" widgetVar="employeeEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" closeOnEscape="true">
<p:outputPanel id="employeeDataEdit" rendered="#{not empty employeeEditController.employee}">
<h:panelGrid columns="2">
<p:outputLabel for="usernameEdit" value="Benutzername: " />
<p:inputText id="usernameEdit" value="#{employeeEditController.employee.username}" disabled="true" />
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="6">
<p:outputLabel for="firstnameEdit" value="Vorname: " />
<p:inputText id="firstnameEdit" value="#{employeeEditController.employee.firstName}" />
<p:outputLabel for="lastnameEdit" value="Nachname: " />
<p:inputText id="lastnameEdit" value="#{employeeEditController.employee.lastName}" />
<p:outputLabel for="birthdayEdit" value="Geburtsdatum: " />
<p:inputMask mask="99/99/9999" id="birthdayEdit" value="#{employeeEditController.employee.birthday}" />
<p:outputLabel for="locationEdit" value="Wohnort: " />
<p:inputText id="locationEdit" value="#{employeeEditController.employee.location}" />
<p:outputLabel for="streetEdit" value="Straße: " />
<p:inputText id="streetEdit" value="#{employeeEditController.employee.streetName}" />
<p:outputLabel for="postcodeEdit" value="Postleitzahl: " />
<p:inputMask id="postcodeEdit" mask="9999?9" slotChar=" " value="#{employeeEditController.employee.postcode}" />
<p:outputLabel for="phonenumberEdit" value="Telefonnummer: " />
<p:inputMask id="phonenumberEdit" mask="9?99999999999" slotChar=" " maxlength="12" value="#{employeeEditController.employee.phoneNumber}" />
<p:outputLabel for="emailEdit" value="Email: " />
<p:inputText id="emailEdit" validatorMessage="Ungültiges Email-Format!" value="#{employeeEditController.employee.email}">
<f:validateRegex pattern="^$|^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*#[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
</p:inputText>
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="6">
<p:outputLabel for="familyStatus" value="Familienstatus: " />
<p:selectOneMenu id="familyStatus" value="#{employeeEditController.employee.familyStatus}" style="width:150px">
<f:selectItem itemLabel="Wähle Familienstatus" itemValue="#{employeeEditController.employee.familyStatus}" />
<f:selectItems value="#{enumController.familyStatus}" />
</p:selectOneMenu>
<p:outputLabel for="Religion" value="Religion: " />
<p:selectOneMenu id="Religion" value="#{employeeEditController.employee.religion}" style="width:150px">
<f:selectItem itemLabel="Wähle Religion" itemValue="#{employeeEditController.employee.religion}" />
<f:selectItems value="#{enumController.religions}" />
</p:selectOneMenu>
<p:outputLabel for="Role" value="Rolle: " />
<p:selectOneMenu id="Role" value="#{employeeEditController.employee.workRole}" style="width:150px">
<f:selectItem itemLabel="Wähle Arbeitsrolle" itemValue="#{employeeEditController.employee.workRole}" />
<f:selectItems value="#{enumController.workRoles}" />
</p:selectOneMenu>
</h:panelGrid>
<p:separator/>
<h:panelGrid columns="3">
<p:commandButton value="Speichern" action="#{employeeEditController.doSaveEmployeeEdit()}" />
<p:commandButton value="Neu laden" action="#{employeeEditController.doReloadEmployee()}" />
<p:commandButton value="Abbruch" onclick="PF('employeeEditDialog').hide()" />
</h:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
What can be the reason that html or whatever still do the validation and don't call the doSaveEmployeeEdit()?
UPDATE:
I made a new xhtml-file with same outputs - no validation anymore. But my controller method doesn't get called.
My children.xhtml:
<h:body>
<body class="theme-blue sidebar-mini sidebar-collapse">
<div class="wrapper">
<div class="content-wrapper" style="min-height: 1126px;">
<section class="content">
<div class="box">
<div class="box-body">
<h:form id="childForm">
<p:dataTable id="childTable" var="child" value="#{childController.children}">
<p:column headerText="Vorname">
<h:outputText value="#{child.firstName}" />
</p:column>
<p:column headerText="Nachname">
<h:outputText value="#{child.lastName}" />
</p:column>
<p:column headerText="Geburtsdatum">
<h:outputText value="#{child.birthday}" />
</p:column>
<p:column style="width:32px;text-align: center">
<p:commandButton update=":childForm:childEdit" oncomplete="PF('childEditDialog').show()" icon="ui-icon-note" title="Bearbeiten">
<f:setPropertyActionListener value="#{child}" target="#{childEditController.childEdit}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="Kind bearbeiten" widgetVar="childEditDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false">
<p:messages autoUpdate="true" />
<p:outputPanel id="childEdit" style="text-align:center;">
<p:panelGrid columns="2" rendered="#{not empty childEditController.childEdit}" columnClasses="label,value">
<p:outputLabel id="primParent" value="primäres Elternteil:" />
<p:inputText for="primParent" value="#{childEditController.childEdit.primaryParent.id}" disabled="true" />
<p:outputLabel id="firstName" value="Vorname:" />
<p:inputText for="firstName" value="#{childEditController.childEdit.firstName}" />
<p:outputLabel id="lastName" value="Nachname:" />
<p:inputText for="lastName" value="#{childEditController.childEdit.lastName}" />
<p:outputLabel id="birthDay" value="Geburtsdatum:" />
<p:inputText for="birthDay" value="#{childEditController.childEdit.birthday}" />
<p:outputLabel id="emgNum" value="Notfallkontakt:" />
<p:inputText for="emgNum" value="#{childEditController.childEdit.emergencyNumber}" />
<p:outputLabel id="imgName" value="Bildname:" />
<p:inputText for="imgName" value="#{childEditController.childEdit.imgName}" />
<p:outputLabel for="gender" value="Geschlecht: " />
<p:inputText id="gender" value="#{childEditController.childEdit.gender}" disabled="true" />
<p:separator />
<h:panelGrid columns="3">
<p:commandButton value="Speichern" action="#{childEditController.doSaveChild}" update=":childForm:childTable" />
<p:commandButton value="Abbruch" onclick="PF('childEditDialog').hide()" immediate="true" />
</h:panelGrid>
</p:panelGrid>
</p:outputPanel>
</p:dialog>
</h:form>
</div>
</div>
</section>
</div>
</div>
</body>
</h:body>
My childEditController:
#Component
#Scope("request")
public class ChildEditController {
#Autowired
private ChildService childService;
private Child childEdit;
public Child getChildEdit() {
return childEdit;
}
public void setChildEdit(Child childEdit) {
this.childEdit = childEdit;
}
public void doSaveChild(){
childEdit = childService.saveChild(childEdit);
childEdit = null;
}
}
Hello guys i have a problem updating some components, i am using JSF, Primefaces 5.3, Hibernate.
i Have this tab that contains a datatable: tab 1 and i have this other tab tab 2 what i want to do is when i change Farmaceutica column in tab 2 and click Guardar Cambios i want to update the datatable of the tab 1. I can update the datatabase and when i logout and login again the change is there but i want the change without logout.
This is my admin.xhtml:
<h:form id="frm">
<p:growl id="growl" life="3500" sticky="false" showDetail="true" />
<div class="navbar color-bar"></div>
<div class="container-fluid">
<div class="row">
<div class="col-md-7">
<div class="row">
<div class="col-md-12">
<p:tabView id="tabs">
<p:tab title="Estado asignaciones">
<p:panel id="panelEstado">
<h:form id="formDta">
<p:dataTable
value="#{estadoAsignaciones.listaEstadoAsignaciones}"
var="data" paginator="true" rowKey="#{data.idAuditor}"
rows="10" selectionMode="single"
selection="#{estadoAsignaciones.estadoAsignaciones}">
<p:ajax event="rowSelect"
listener="#{estadoAsignaciones.onRowSelect()}"
onstart="PF('blockUIWidget').show()"
oncomplete="PF('overPnl').show()" update="frm" />
<p:column headerText="Auditor">
<h:outputLabel
value="#{data.nombreAuditor} #{data.apellidoAuditor}" />
</p:column>
<p:column headerText="Farmacéutica">
<h:outputLabel value="#{data.farmaceuticaAsignada}" />
</p:column>
<p:column headerText="Progreso">
<p:progressBar value="#{data.porcentaje}"
labelTemplate="{value}%" id="avanceBar" style="width:80%" />
</p:column>
</p:dataTable>
</h:form>
</p:panel>
<p:overlayPanel id="panelOver" widgetVar="overPnl"
showEffect="fade" hideEffect="fade" dismissable="false"
showCloseIcon="true">
<p:panel id="avance" header="Avance auditoria"
class="space robotome">
<p:progressBar id="avanceBar"
value="#{estadoAsignaciones.porcentajeValue}"
style="width:100%" labelTemplate="{value}%" />
</p:panel>
<p:panel id="tiempo" header="Tiempo" class="space robotome">
<h:outputLabel
value="Fecha inicio: #{estadoAsignaciones.fecha}" />
<br />
<h:outputLabel
value="Fecha Actual: #{estadoAsignaciones.fechaActual}" />
<br />
<h:outputLabel
value="Hora inicio: #{estadoAsignaciones.hora}" />
<br />
<h:outputLabel
value="Tiempo transcurrido: #{estadoAsignaciones.calHoraDif} horas" />
</p:panel>
<p:panel id="auditor" header="Auditor" class="robotome">
<p:outputLabel
value="Nombres: #{estadoAsignaciones.getEstadoAsignaciones().nombreAuditor}" />
<br />
<p:outputLabel
value="Apellidos: #{estadoAsignaciones.getEstadoAsignaciones().apellidoAuditor}" />
</p:panel>
</p:overlayPanel>
<p:blockUI block="frm" widgetVar="blockUIWidget">
<p:graphicImage name="imgs/loading.gif" width="50" height="50" />
</p:blockUI>
</p:tab>
<p:tab title="Asignaciones">
<p:dataTable id="dtA"
value="#{asignacionesBean.seleccionAuditores}" var="auditor"
paginator="true" rows="5">
<p:column headerText="Auditor">
<h:outputText value="#{auditor.nombreAuditor}" />
</p:column>
<p:column headerText="Farmaceutica">
<p:selectOneMenu value="#{auditor.idFarmaceutica}">
<f:selectItem itemLabel="#{data.farmaceutica}"
noSelectionOption="true" itemDisabled="true" itemValue="" />
<f:selectItems
value="#{asignacionesBean.mapSeleccionFarmaceuticas}" />
</p:selectOneMenu>
</p:column>
<p:column>
<p:commandButton value="Guardar cambios" update=":frm"
actionListener="#{asignacionesBean.guardarRespuestaAsignaciones(auditor)}"
process="#this"
onclick="PF('blockUIWidgetAsignaciones').hide()"
onsuccess="PF('blockUIWidgetAsignaciones').show()" />
</p:column>
</p:dataTable>
I appreciate your help.
I could not understant why you are using form inside form. Delete all forms except the main one.
In your first tab, add id to your datatable. and put prependId=false to your panel grid as below.
<p:panel id="panelEstado" prependId="false">
<p:dataTable id="firstTable" value="#{estadoAsignaciones.listaEstadoAsignaciones}"
var="data" paginator="true" rowKey="#{data.idAuditor}"
rows="10" selectionMode="single" selection="#{estadoAsignaciones.estadoAsignaciones}">
Then in Farmaceutica column in tab 2 change code like below
<p:selectOneMenu value="#{auditor.idFarmaceutica}">
<f:selectItem itemLabel="#{data.farmaceutica}" noSelectionOption="true" itemDisabled="true" itemValue="" />
<f:selectItems value="#{asignacionesBean.mapSeleccionFarmaceuticas}" />
<p:ajax event="valueChange" update=":firstTable"/>
</p:selectOneMenu>
in Guardar Cambios change your code to this one.
<p:commandButton value="Guardar cambios" update=":firstTable" actionListener="#{asignacionesBean.guardarRespuestaAsignaciones(auditor)}" process="#this"
onclick="PF('blockUIWidgetAsignaciones').hide()" onsuccess="PF('blockUIWidgetAsignaciones').show()" />
i don't know why i get previous data when i use dialog that i call it from datatable, when i open the dialog and leave required field empty and press edit when i close the dialog and open another row i notice that the old data is appear in the fields
here's my code
<h:form id="content" prependId="false">
<c:set target="#{facilityMB}" property="facilityType" value="Recreation"/>
<h:panelGrid class="ipmagix-mainFrom" cellpadding="0" cellspacing="0" columns="1">
<h:panelGroup layout="block" class="ipmagix-breadcrumb">
<ul class="breadcrumb">
<li>Home <span class="divider">/</span></li>
<li>Services <span class="divider">/</span></li>
<li class="active">Recreation Promotion</li>
</ul>
</h:panelGroup>
<h:panelGroup layout="block" class="panel panel-primary">
<h:panelGroup layout="block" class="panel-heading">
<i class="icon-white icon-list"></i>
<i></i>
<h:outputText value="#{bundle.facilityRecreationList}"/>
</h:panelGroup>
<h:panelGroup layout="block" class="panel-body">
<p:messages id="messagesForList" showDetail="false" autoUpdate="false" closable="true"/>
<h:panelGroup layout="block" class="ipmagix-list-width" id="facilityListForm">
<ui:include src="facility-view.xhtml"/>
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
<h:panelGroup layout="block" class="panel panel-primary">
<h:panelGroup layout="block" class="panel-heading">
<i class="icon-white icon-plus"></i>
<i></i>
<h:outputText value="#{bundle.facilityRecreationAdd}" />
</h:panelGroup>
<h:panelGroup layout="block" class="panel-body">
<p:messages id="messages" showDetail="false" autoUpdate="false" closable="true"/>
<h:panelGroup layout="block" class="ipmagix-form-width form-horizontal" id="facilityAddForm">
<div class="control-group">
<h:outputLabel for="facilityName" class="control-label" value="#{bundle.name}"></h:outputLabel>
<div class="controls">
<p:inputText value="#{facilityMB.facilityName}" id="facilityName" maxlength="40" required="true" requiredMessage="#{validation.emptyName}" />
<p:watermark value="#{bundle.name}" for="facilityName"/>
</div>
</div>
<div class="control-group">
<h:outputLabel for="language" class="control-label" value="#{bundle.language}"></h:outputLabel>
<div class="controls">
<p:selectOneMenu id="language" value="#{facilityMB.languageId}">
<f:selectItems value="#{facilityMB.languageList}" var="lang" itemValue="#{lang.languageID}" itemLabel="#{lang.languageName}" />
</p:selectOneMenu>
</div>
</div>
<div class="control-group">
<h:outputLabel for="facilityDesc" class="control-label" value="#{bundle.description}"></h:outputLabel>
<div class="controls">
<p:inputTextarea value="#{facilityMB.facilityDesc}" id="facilityDesc" maxlength="100" style="width: 80%" autoResize="false" rows="3" required="true" requiredMessage="#{validation.emptyDescription}" />
<p:watermark value="#{bundle.description}" for="facilityDesc"/>
</div>
</div>
<h:panelGroup layout="block" id="uploader" class="control-group">
<h:outputLabel class="control-label" value="#{bundle.imageURL}"></h:outputLabel>
<div class="controls">
<p:fileUpload fileUploadListener="#{facilityMB.handleFileUpload}" mode="advanced"
update="uploader, messages" auto="true" allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
</div>
</h:panelGroup>
<div class="control-group well well-small">
<p:commandButton id="saveFacility" value="#{bundle.save}" styleClass="btn btn-mini btn-primary" icon="ui-icon-plus" action="#{facilityMB.saveFacility()}"
oncomplete="filter();" update ="facilityAddForm, facilityListForm, messages">
</p:commandButton>
</div>
</h:panelGroup>
</h:panelGroup>
</h:panelGroup>
</h:panelGrid>
<h:panelGroup layout="block" id="uiBlock">
<p:blockUI block="facilityListForm" trigger="saveFacility" >
LOADING<br />
<p:graphicImage value="#{resource['images:ajax-loader.gif']}"/>
</p:blockUI>
<p:blockUI block="facilityAddForm" trigger="saveFacility" >
LOADING<br />
<p:graphicImage value="#{resource['images:ajax-loader.gif']}"/>
</p:blockUI>
</h:panelGroup>
</h:form>
<h:form id="dialogForm" prependId="false">
<p:dialog id="dialog" modal="true" width="80%" resizable="false" header="Edit Special Promotion" widgetVar="dlg" dynamic="true">
<p:ajax event="close" update=":content:facilityListForm" />
<h:panelGroup layout="block" id="dialogContent">
<ui:include src="facility-edit.xhtml"/>
</h:panelGroup>
</p:dialog>
</h:form>
</ui:define>
and this is view page is be included
<p:dataTable widgetVar="tableVar" id="facilityDataTable" scrollWidth="100%" value="#{facilityMB.facilityList}" var="facility" paginator="true" editable="true" emptyMessage="#{bundle.emptyData}" rows="5" filteredValue="#{facilityMB.facilityFilterList}" >
<p:column headerText="Image" width="100">
<p:lightBox height="100">
<h:outputLink value="#">
<img src="#{facility.imageURL}" width="100" height="100"/>
</h:outputLink>
<f:facet name="inline">
<img src="#{facility.imageURL}" width="500" height="500"/>
</f:facet>
</p:lightBox>
</p:column>
<p:column headerText="#{bundle.name}" sortBy="#{facility.facilityName}" filterBy="#{facility.facilityName}" rendered="#{facilityMB.facilityType != 'Special Promotion'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText id="ink" value="#{facility.facilityName}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{facility.facilityName}" maxlength="40" required="true" requiredMessage="The name is not valid"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column width="5%" headerText="#{bundle.language}" sortBy="#{facility.languageID.languageName}" filterBy="#{facility.languageID.languageName}">
<h:outputText value="#{facility.languageID.languageName}"/>
</p:column>
<p:column headerText="#{bundle.description}" sortBy="#{facility.facilityDescription}" filterBy="#{facility.facilityDescription}" rendered="#{facilityMB.facilityType != 'Special Promotion'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText value="#{facility.facilityDescription}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{facility.facilityDescription}" maxlength="100" required="true" requiredMessage="The description is not valid"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column width="2%">
<p:commandLink styleClass="ui-icon ui-icon-trash" immediate="true"
oncomplete="filter()" action="#{facilityMB.deleteFacility(facility)}" update=":content:facilityDataTable, :content:messagesForList">
</p:commandLink>
</p:column>
<p:column width="4%">
<p:commandButton id="basic" value="Edit" immediate="true" action="#{facilityMB.prepareEdit(facility)}" oncomplete="dlg.show();filter();" update=":dialogForm:dialogContent" >
<f:setPropertyActionListener target="#{facilityMB.selectedFacility}" value="#{facility}"/>
</p:commandButton>
</p:column>
</p:dataTable>
Do not keep p:dialog inside h:form, instead keep h:form inside p:dialog.
Then you can update the h:form or any h:panelGroup inside p:dialog.
If you want to do it from Javascript use loadContents() function on p:dialog's widgetWar object.
For Example:
<h:form id="form1">
<p:commandButton update=":form2" oncomplete="myDialogWidget.loadContents()"/>
</h:form>
<p:dialog widgetWar="myDialogWidget" appendToBody="true">
<h:form id="form2">
....
</h:form>
</p:dialog>
Use update=":dialogForm" on edit command button. So whenever you open dialogbox, previous data will get refreshed.
how're you?
Maybe a newbie question now. Now I have one input and a "submit" button inside a form. When I click in submit, this doesn't call any method, this just opens a <p:dialog>. When this dialog is opened, the variable in input wasn't setted, so another input I have in doesn't show anything.
See the images to understand:
After click in "submit" (Adicionar):
This second image must show exactly the same value of the first input, but as you can see this just shows a empty input.
Now let's go to my code.
Here's my JSF:
<h:form id="inserirDisciplina">
<h:inputText styleClass="form-control" id="disciplina" value="#{cursoMBean.nome}"
valueChangeListener="#{cursoMBean.atualizarListagemPesquisa}">
// atualizarListagemPesquisa just update the arraylist to be shown in dataTable
<f:ajax event="keyup" render=":meuForm:minhaTabela" />
</h:inputText>
<h:commandButton value="Adicionar" styleClass="btn btn-md btn-success">
<p:ajax event="click" update=":meuForm:display" render=":meuForm:dialog" oncomplete="PF('insert').show();" onerror="alert('erro');" />
</h:commandButton>
<p:dialog id="dialog" header="Inserir Curso" widgetVar="insert" resizable="false" modal="true" width="600" height="500" hideEffect="clip" closeOnEscape="true" focus="enviar">
<h:panelGrid id="display" styleClass="col-lg-10 center">
<label for="nome">Nome:</label>
<p:inputText styleClass="form-control adicionar" id="nome" value="#{cursoMBean.nome}" />
</h:panelGrid>
...
MBean:
private String nome;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
Edit (new View):
<h:form id="inserirDisciplina">
<div class="form-group">
<div class="col-md-10">
<h:inputText styleClass="form-control" id="disciplina" value="#{cursoMBean.nome}" valueChangeListener="#{cursoMBean.atualizarListagemPesquisa}">
<f:ajax event="keyup" render=":meuForm:minhaTabela" />
</h:inputText>
</div>
<div class="col-md-2">
<h:commandButton value="Adicionar" styleClass="btn btn-md btn-success" process="disciplina" partialSubmit="true">
<p:ajax event="click" update=":meuForm:display" render=":meuForm:dialog" partialSubmit="true" process="disciplina" oncomplete="PF('insert').show();" onerror="alert('erro');" />
</h:commandButton>
</div>
</div>
</h:form>
<p:messages autoUpdate="true" />
<p:dialog id="dialog" header="Inserir Curso" widgetVar="insert"
resizable="false" modal="true" width="600" height="500"
hideEffect="clip" closeOnEscape="true">
<h:form>
<h:panelGrid id="display" styleClass="col-lg-10 center" style="margin-top: 10px; margin-bottom: 15px;">
<label for="nome">Nome:</label>
<p:inputText styleClass="form-control adicionar" id="nome" value="#{cursoMBean.nome}">
</p:inputText>
</h:panelGrid>
<h:panelGrid styleClass="col-lg-10 center">
<p:columnGroup>
<label for="disciplinas">Disciplinas do Curso:</label>
<h:selectManyCheckbox style="margin-bottom: 40px;" id="disciplinas" value="#{cursoMBean.listaDisciplinasDoCurso}" converter="omnifaces.SelectItemsConverter">
<f:selectItems value="#{cursoMBean.listaTodasDisciplinas}" var="disciplina" itemValue="#{disciplina}" itemLabel="#{disciplina.nome}" />
</h:selectManyCheckbox>
</p:columnGroup>
</h:panelGrid>
<h:panelGrid styleClass="col-lg-10 center">
<p:columnGroup>
<h:commandButton id="enviar" styleClass="btn btn-lg btn-success pull-right" value="Adicionar" action="#{cursoMBean.cadastrar}">
<f:ajax event="click" execute="#form" onevent="insert.hide()" render=":meuForm:minhaTabela" listener="#{cursoMBean.cadastrar}" />
</h:commandButton>
</p:columnGroup>
</h:panelGrid>
</h:form>
</p:dialog>
What I'm doing wrong?
Try the following code for the button:
<p:commandButton value="Adicionar" styleClass="btn btn-md btn-success"
process="disciplina" partialSubmit="true" update=":inserirDisciplina:display"
oncomplete="insert.show();" onerror="alert('erro');">
</p:commandButton>
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>