Primefaces <p:calendar> event="dateSelect" is not working - ajax

Whatever I try, the listener="#{aufwandDayEditController.initAufwaendeJeTag}" of the event="dateSelect" in the is never called.
Here the facelet:
<h:head>
<title>Aufwand je Tag erfassen</title>
<h:outputStylesheet name="css/style.css" />
</h:head>
<h:body>
<h:form id="form">
<ui:include src="/common/menu.xhtml"/>
<p:panel id="panel" header="Aufwand je Tag" style="width: 800px">
<p:panelGrid id="attribute" columns="2">
<p:outputLabel for="mitarbeiter" value="Mitarbeiter:"/>
<p:selectOneMenu id="mitarbeiter"
value="#{aufwandDayEditController.mitarbeiter}"
editable="false"
effect="fade"
converter="#{mitarbeiterConverter}"
required="true"
requiredMessage="Mitarbeiter muss angegeben werden!">
<f:selectItems value="#{aufwandDayEditController.mitarbeiterSelectItems}"/>
<p:ajax listener="#{aufwandDayEditController.initAufwaendeJeTag}"
update="aufwaende"/>
<p:ajax update="addRow"/>
</p:selectOneMenu>
<p:outputLabel for="tag"
value="Tag:"/>
<p:calendar id="tag"
value="#{aufwandDayEditController.tag}"
required="true"
requiredMessage="Tag muss angegeben werden!"
locale="de"
navigator="true"
yearRange="c-10:c+10">
<p:ajax event="dateSelect"
listener="#{aufwandDayEditController.initAufwaendeJeTag}"
update="aufwaende"/>
<p:ajax event="dateSelect"
update="addRow"/>
</p:calendar>
<p:outputLabel value="Aufwände:"
for="aufwaende"/>
<p:dataTable id="aufwaende"
var="aufwand"
value="#{aufwandDayEditController.aufwaendeJeTag}"
sortBy="#{aufwand.aktivitaet}"
rendered="#{aufwandDayEditController.aufwaendeJeTag != null}"
editable="true"
editMode="row"
resizableColumns="true">
<f:facet name="header">Aufwände</f:facet>
<p:ajax event="rowEdit"
listener="#{aufwandDayEditController.onRowEdit}"
update=":form:message"/>
<p:ajax event="rowEditCancel"
listener="#{aufwandDayEditController.onRowEditCancel}"
update=":form:message"/>
<p:column headerText="Aktivität" style="vertical-align: middle;" resizable="true">
<p:cellEditor>
<f:facet name ="output">
<h:outputText value="#{aufwand.aktivitaet.toString()}"/>
</f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{aufwand.aktivitaet}"
editable="false"
effect="fade"
converter="#{aktivitaetConverter}"
required="true"
requiredMessage="Projektaktivität muss angegeben werden!"
style="width:70%; line-height: 85%; text-align: left">
<f:selectItems value="#{aufwandDayEditController.aktivitaetSelectItems}"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Aufwand [pH]" style="vertical-align: middle;" resizable="true">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{aufwand.menge}"/>
</f:facet>
<f:facet name="input">
<p:inputText id="menge"
value="#{aufwand.menge}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column resizable="true">
<p:rowEditor />
</p:column>
</p:dataTable>
<p:outputLabel/>
<p:commandButton id="addRow"
icon="add"
title="Neue Zeile"
value="Neue Zeile"
actionListener="#{aufwandDayEditController.onAddRow}"
update="aufwaende"
disabled="#{aufwandDayEditController.mitarbeiter == null or aufwandDayEditController.tag == null}"/>
</p:panelGrid>
<p:growl id="message" showDetail="true" showSummary="false"/>
</p:panel>
<p:commandLink value="Zurück"
immediate="true"
action="#{aufwandDayEditController.back()}"/>
</h:form>
</h:body>
</html>
And here the interesting part of the associated controller:
public void initAufwaendeJeTag(Object dummy) {
initAufwaendeJeTag();
}
public void initAufwaendeJeTag() {
if (mitarbeiter != null && tag != null) {
aufwaendeJeTag = aufwandFacade.findByDay(mitarbeiter, tag);
}
else {
aufwaendeJeTag = new LinkedList<>();
}
}
Please note that the listener without the parameter is called perfectly from component id="mitarbeiter" but the neither of them is called from component id="tag". is working correctly as value="#{aufwandDayEditController.tag}" is updated ...
Checked this with debugger ...
Any help available?
I'm using PrimeFaces 5.1, NetBeans 8.0.1, ...

Oh, found it out ... it seems, that a consumes an event so that only one (in my case the 2nd one) responds to it.
The solution is that I have to alter the update="" attribute ...

Related

Updating Primefaces datatable summary row using Ajax

How can I update a primefaces datatable summary row after submitting a form (dialog)?
The datatable is already updated correctly after some CRUD operation, but the summary row doesn't. I'm using p:remoteCommand to update the summary row when filtering the datatable and it works fine.
The List.xhtml:
<h:form id="TreinamentosListForm">
<p:panel header="#{treinaBundle.ListTreinamentosTitle}" >
<p:remoteCommand name="updateFooterSumCountId" update="datalist:footerSumCountId" />
<p:dataTable id="datalist"
filteredValue="#{treinamentosController.filteredTreinamentos}"
value="#{treinamentosController.items}"
var="item"
rowKey="#{item.id}"
paginator="true"
selectionMode="single"
selection="#{treinamentosController.selected}">
<p:ajax event="filter" process="#form" update="#this" listener="#{treinamentosController.onFilter}" oncomplete="updateFooterSumCountId()" />
<p:ajax event="rowSelect" update=":TreinamentosListForm:createButton :TreinamentosListForm:viewButton :TreinamentosListForm:editButton :TreinamentosListForm:deleteButton :TreinamentosListForm:TreinamentosDataTableContextMenu" listener="#{treinamentosController.resetParents}"/>
<p:ajax event="rowUnselect" update=":TreinamentosListForm:createButton :TreinamentosListForm:viewButton :TreinamentosListForm:editButton :TreinamentosListForm:deleteButton :TreinamentosListForm:TreinamentosDataTableContextMenu" listener="#{treinamentosController.resetParents}"/>
<p:ajax event="rowDblselect" onsuccess="document.getElementById('TreinamentosListForm:viewButton').click();"/>
<p:column sortBy="#{item.id}" filterBy="#{item.id}" style="text-align: right">
<f:facet name="header">
<h:outputText value="#{treinaBundle.ListTreinamentosTitle_id}"/>
</f:facet>
<h:outputText value="#{item.id}"/>
</p:column>
<p:columnGroup id="totalGroup" rendered="true" type="footer" >
<p:row>
<p:column style="text-align:right">
<f:facet name="footer">
<!-- the summary row: -->
<h:outputText id="footerSumCountId" value="#{treinamentosController.sumCountId}" />
</f:facet>
</p:column>
</p:row>
</p:columnGroup>
</p:dataTable>
<f:facet name="header">
<p:commandButton id="createButton" icon="ui-icon-plus" value="#{treinaBundle.Create}" actionListener="#{treinamentosController.prepareCreate}" update=":TreinamentosCreateForm" oncomplete="PF('TreinamentosCreateDialog').show()"/>
<p:commandButton id="viewButton" icon="ui-icon-search" value="#{treinaBundle.View}" update=":TreinamentosViewForm" oncomplete="PF('TreinamentosViewDialog').show()" disabled="#{empty treinamentosController.selected}"/>
<p:commandButton id="editButton" icon="ui-icon-pencil" value="#{treinaBundle.Edit}" update=":TreinamentosEditForm" oncomplete="PF('TreinamentosEditDialog').show()" disabled="#{empty treinamentosController.selected}"/>
<p:commandButton id="deleteButton" icon="ui-icon-trash" value="#{treinaBundle.Delete}" actionListener="#{treinamentosController.delete}" update=":growl,datalist" disabled="#{empty treinamentosController.selected}">
<p:confirm header="#{treinaBundle.ConfirmationHeader}" message="#{treinaBundle.ConfirmDeleteMessage}" icon="ui-icon-alert"/>
</p:commandButton>
</f:facet>
</p:panel>
<ui:include src="/WEB-INF/include/confirmation.xhtml"/>
</h:form>
The Create.xhtml:
<p:dialog id="TreinamentosCreateDlg" widgetVar="TreinamentosCreateDialog" modal="true" resizable="false" appendTo="#(body)" header="#{treinaBundle.CreateTreinamentosTitle}" closeOnEscape="true" >
<h:form id="TreinamentosCreateForm">
<h:panelGroup id="display" rendered="#{treinamentosController.selected != null}">
<p:panelGrid columns="2" columnClasses="column">
<p:outputLabel value="#{treinaBundle.CreateTreinamentosLabel_id}" for="id" />
<p:outputLabel id="id" value="Value automatically generated from database." title="#{treinaBundle.CreateTreinamentosTitle_id}" />
</p:panelGrid>
<p:commandButton actionListener="#{treinamentosController.saveNew}" value="#{treinaBundle.Save}" update="#all,display,:TreinamentosListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,PF('TreinamentosCreateDialog'));">
<p:confirm header="#{treinaBundle.ConfirmationHeader}" message="#{treinaBundle.ConfirmCreateMessage}" icon="ui-icon-alert"/>
</p:commandButton>
<p:commandButton value="#{treinaBundle.Cancel}" onclick="PF('TreinamentosCreateDialog').hide()"/>
</h:panelGroup>
</h:form>
</p:dialog>
Thanks in advance.
After reading the Primefaces 5 documentation, what I did was to invoke (in the Create.xhtml) the Primefaces filter method, referencing through the widgetVar defined in the target datatable (in List.xhtml). Doing so, it triggers my p:remoteCommand, which in its turn, triggers the update for the summary row:
<p:commandButton actionListener="#{treinamentosController.saveNew}" value="#{treinaBundle.Save}" update="#this,display,:TreinamentosListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,PF('TreinamentosCreateDialog'),PF('treinamentosTable').filter());" >
<p:confirm header="#{treinaBundle.ConfirmationHeader}" message="#{treinaBundle.ConfirmCreateMessage}" icon="ui-icon-alert"/>
</p:commandButton>
If someone has a more elegant solution, please share. I had not time

Error with p:commandbutton validating form

I have a form with two p: commandbutton to user request system, both buttons perform the same action, because it has a p: accordeonpanel both buttons the user requested to post the information from the beginning or end of the page . The first button is properly validating the two components I am indicating, but the second button at the bottom of the page to do so is what makes me clean fields and p: selectOneMenu, as if making a "reset". Any idea of the problem? Here is the code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template=" ./../../../WEB-INF/templates/main_template.xhtml" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<ui:define name="left">
<ui:include src="#{bundle.LeftMenuSite}">
</ui:include>
</ui:define>
<ui:define name="content_altern">
<h3>#{bundle.SitSrtInfoTitle}</h3>
<h:form id="gralForm" prependId="false">
<p:commandButton ajax="true" style="float:right;" id="insertDataSRT0" process="#this,accPanel:mainInfoRF,accPanel:panelGridMap" update="accPanel:mainInfoRF accPanel:panelGridMap" action="#{sitSrtInfoController.create}" value="#{bundle.SendData}" icon="ui-icon ui-icon-disk"/>
<br/><br/>
<p:accordionPanel activeIndex="1" multiple="true" id="accPanel">
<p:tab title="#{bundle.AccTabSrtList}" id="tabSRTList">
<ui:include src="/admin/sites/sitSrtInfo/List.xhtml"/>
</p:tab>
<p:tab title="#{bundle.AccTabSrtInfo}" id="tabInfo">
<p:messages globalOnly="true" ></p:messages>
<p:panelGrid id="panelGridMap" columns="4">
<h:outputLabel value="#{bundle.SitSrtInfoLabel_siteId}" />
<p:inputText id="siteId" value="#{sRTGMapController.srtgMap.srtCode}" required="true" />
<h:outputLabel value="#{bundle.SitSrtInfoLabel_latitude}" style="text-align: right" />
<p:inputText id="latitude" value="#{sRTGMapController.srtgMap.latitude}" required="true" style="width:100px" />
<h:outputLabel value="#{bundle.SitSrtInfoLabel_longitude}" style="width:50px" />
<p:inputText id="longitude" value="#{sRTGMapController.srtgMap.longitude}" required="true" style="width:100px" />
<h:outputLabel value="#{bundle.SitSrtInfoLabel_srRadius}" />
<p:inputText id="srRadius" value="#{sRTGMapController.srtgMap.radius}" required="true" />
<h:outputLabel value=" " style="width:50px" />
<h:outputLabel value=" " style="width:50px" />
<p:commandButton process="panelGridMap" value="#{bundle.ViewPosition}" oncomplete="if (!args.validationFailed) dlg.show()" action="#{sRTGMapController.createModel}" update="dlg panelGridMap" icon="ui-icon-pin-s" />
</p:panelGrid>
<p:dialog id="dlg" widgetVar="dlg" modal="false" styleClass="div-left" >
<p:gmap id="myMap" center="#{sRTGMapController.center}" fitBounds="false" zoom="18" type="HYBRID"
styleClass="viewGMap" model="#{sRTGMapController.circleModel}" />
</p:dialog>
<p:panelGrid id="mainInfoRF">
<p:row>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_dateReq}" /></p:column>
<p:column>
<p:calendar id="dateReq" value="#{sitSrtInfoController.selected.dateReq}" navigator="true" required="true" readonlyInput="true" >
<f:convertDateTime pattern="dd/MM/yyyy" />
</p:calendar>
</p:column>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_priority}" />
</p:column>
<p:column>
<p:selectOneMenu id="priority" value="#{sitSrtInfoController.selected.priority}" required="true" >
<f:selectItems value="#{staticCatsController.priority.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_typeSite}" />
</p:column>
<p:column>
<p:selectOneMenu id="typeSite" value="#{sitSrtInfoController.selected.typeSite}" required="true" >
<f:selectItems value="#{staticCatsController.typeSite.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu>
</p:column>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_region}" />
</p:column>
<p:column>
<p:selectOneMenu id="region" value="#{sitSrtInfoController.selected.region}" required="true" >
<f:selectItems value="#{staticCatsController.region.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_cluster}" />
</p:column>
<p:column>
<p:inputText id="cluster" value="#{sitSrtInfoController.selected.cluster}" required="true" />
</p:column>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_year}"/>
</p:column>
<p:column>
<p:inputText id="year" value="#{sitSrtInfoController.selected.year}" required="true" />
</p:column>
</p:row>
<p:row>
<p:column>
<h:outputLabel value="#{bundle.SitSrtInfoLabel_srVersion}" /></p:column>
<p:column> <p:inputText id="srVersion" value="#{sitSrtInfoController.selected.srVersion}" required="true" /></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_datum}" /></p:column>
<p:column> <p:selectOneMenu id="datum" value="#{sitSrtInfoController.selected.datum}" required="true" >
<f:selectItems value="#{staticCatsController.datum.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_morphology}"/> </p:column>
<p:column><p:selectOneMenu id="morphology" value="#{sitSrtInfoController.selected.morphology}" required="true" >
<f:selectItems value="#{staticCatsController.morphology.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_colDesign}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="colDesign" value="#{sitSrtInfoController.selected.colDesign}" required="true" /></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_ownerId}" /></p:column>
<p:column> <p:selectOneMenu id="ownerId" value="#{sitSrtInfoController.selected.ownerId}" required="true" >
<f:selectItems value="#{staticCatsController.owner.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}"/>
</p:selectOneMenu></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_oveDesign}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="oveDesign" value="#{sitSrtInfoController.selected.oveDesign}" required="true" /></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_existSiteIdCms}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="existSiteIdCms" value="#{sitSrtInfoController.selected.existSiteIdCms}" required="true" /></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_existSiteName}" /></p:column>
<p:column> <p:inputText id="existSiteName" value="#{sitSrtInfoController.selected.existSiteName}" required="true" /></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_hubSite}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="hubSite" value="#{sitSrtInfoController.selected.hubSite}" required="true" /></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_fiberMw}" /></p:column>
<p:column> <p:selectOneMenu id="fiberMw" value="#{sitSrtInfoController.selected.fiberMw}" required="true" >
<f:selectItems value="#{staticCatsController.fiberMW.entrySet()}" var="entry"
itemValue="#{entry.key}" itemLabel="#{entry.value}" />
</p:selectOneMenu></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_mwRepeater}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="mwRepeater" value="#{sitSrtInfoController.selected.mwRepeater}" required="true" /></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_generatedBy}" /></p:column>
<p:column> <p:inputText id="generatedBy" value="#{sitSrtInfoController.selected.generatedBy}" required="true" /></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_receivedBy}" /></p:column>
<p:column> <p:inputText id="receivedBy" value="#{sitSrtInfoController.selected.receivedBy}" required="true" /></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_statusReg}" /></p:column>
<p:column> <p:selectBooleanCheckbox id="statusReg" value="#{secCompaniesController.selected.statusReg}" required="true" /></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_country}" /></p:column>
<p:column> <p:selectOneMenu id="countryId" value="#{geoCitiesController.countrySelected}" required="true" >
<f:selectItems value="#{geoCountriesController.itemsAvailableSelectOne}"/>
<p:ajax listener="#{geoCitiesController.statesByCountryId}" update="stateId" />
</p:selectOneMenu></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_state}" /></p:column>
<p:column> <p:selectOneMenu id="stateId" value="#{geoCitiesController.stateSelected}" required="true" >
<f:selectItem itemLabel="#{bundle.SelectState}" itemValue=""/>
<f:selectItems value="#{geoCitiesController.statesAvailable}"/>
<p:ajax listener="#{geoCitiesController.citiesByStateId()}" update="cityId" />
</p:selectOneMenu></p:column>
</p:row>
<p:row>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_city}" /></p:column>
<p:column> <p:selectOneMenu id="cityId" value="#{sitSrtInfoController.selected.city}" required="true" >
<f:selectItem itemLabel="#{bundle.SelectCity}" itemValue=""/>
<f:selectItems value="#{geoCitiesController.citiesAvailable}"/>
</p:selectOneMenu></p:column>
<p:column> <h:outputLabel value="#{bundle.SitSrtInfoLabel_market}"/></p:column>
<p:column> <p:selectOneMenu id="market" value="#{sitSrtInfoController.selected.market}" required="true" >
<f:selectItems value="#{geoMarketsController.itemsAvailableSelectOne}"/>
</p:selectOneMenu></p:column>
</p:row>
<p:row>
<p:column colspan="1">
<h:outputLabel value="#{bundle.SitSrtInfoLabel_comments}" />
</p:column>
<p:column colspan="3">
<p:inputTextarea value="#{sitSrtInfoController.selected.comments}" id="comments" rows="6" cols="45" maxlength="400" autoResize="false" required="true"/>
</p:column>
</p:row>
</p:panelGrid>
<br/>
</p:tab>
<p:tab title="#{bundle.AccTabSrtRF}" id="tabRFSRT">
<ui:include src="/admin/sites/sitSrtRf/Create.xhtml"/>
</p:tab>
<p:tab title="#{bundle.AccTabSrtTrans}" id="tabTransSRT">
<ui:include src="/admin/sites/sitSrtTrans/Create.xhtml"/>
</p:tab>
</p:accordionPanel>
<br/><br/>
<p:commandButton ajax="true" style="float:right;" id="insertDataSRT1" process="#this,accPanel:mainInfoRF,accPanel:panelGridMap" update="accPanel:panelGridMap accPanel:mainInfoRF" action="#{sitSrtInfoController.create}" value="#{bundle.SendData}" icon="ui-icon ui-icon-disk"/>
</h:form>
</ui:define>
<ui:define name="content_middle">
</ui:define>
If I understand correctly, you want the reset button, reset does everything.
So if I understand well enough that you do the reset button that calls a bean where it reset all the pulsed variable after this does the update of the #form

Error Validation of a Dialog InputText Primefaces jsf

I have a DataTable and edit a listing you have to open the Dialog component with the respective values ​​that sends the selected object from theDataTable, but cannot open. I have noticed that the function is REQUIRED = "true" and also that no error is displayed, the only solution that helped me erase the function is REQUIRED.
How do I to bring up the Dialog component without taking the REQUIRED function. An example of the code:
<p:tab id="tab_listar" title="#{msg.labelListar}">
<h:form id="form_mostrar_listado">
<p:dialog id="ModificarLugar" header="Modificar Datos" widgetVar="LugarDialogo2"
modal="false" resizable="false" hideEffect="bounce" showEffect="explode">
<h:panelGrid id="ModificarLugar1" columns="2" cellpadding="5">
<h:outputText value="#{msg.labelCodigo}"/>
<h:outputText value="#{BeanLugar.objLugarMod.cod_lugar}"/>
<h:outputText value="#{msg.labelNombre}"/>
<p:inputText value="#{BeanLugar.objLugarMod.nombre}" id="nombre_lu_mod"
required="true" requiredMessage="#{msg.labelNoVacio}"
validatorMessage="#{msg.labelNoValido}"> </p:inputText>
<h:outputText value="#{msg.labelUbicacion}"/>
<h:panelGroup>
<p:selectOneMenu value="#{BeanLugar.objLugarMod.objPais.cod_pais}"
required="true" id="cod_pais_mod" effect="fade"
requiredMessage="#{msg.labelNoVacio}"
validatorMessage="#{msg.labelNoValido}">
<f:selectItem itemLabel="#{msg.labelEligePais}" itemValue=""/>
<f:selectItems value="#{Pais.cargarComboPais}"/>
</p:selectOneMenu>
<h:message showDetail="false" showSummary="true" for="cod_pais_mod"/>
</h:panelGroup>
<p:commandButton value="Cancelar" actionListener="#{BeanLugar.doiniciarModLugar()}"
update=":LugarTabView:form_mostrar_listado" icon="ui-icon-triangl-1-w"
immediate="true"> </p:commandButton>
<p:commandButton id="btn_actualizar" value="#{msg.btnActualizar}"
update=":LugarTabView:form_mostrar_listado"
actionListener="#{BeanLugar.doActualizaLugar()}"> </p:commandButton>
</h:panelGrid>
</p:dialog>
<p:panel id="datListadoLugar">
<h:outputText value="#{msg.labelListado}"/>
<h:panelGrid columns="3" cellspacing="10" width="100">
<p:commandButton value="#{msg.btnNuevo}" update="form_mostrar_listado"
actionListener="#{BeanLugar.doiniciarListadoLugar()}"/>
<p:commandButton value="#{msg.btnListar}" update="form_mostrar_listado"
actionListener="#{BeanLugar.doListarLugar()}"/>
</h:panelGrid>
<h:panelGrid columns="2" rendered="#{BeanLugar.sizeLugar ne '0'}">
<h:outputText value="#{msg.labelCantidad}"/>
<h:outputText value="#{BeanLugar.arrLugar.size()}"/>
</h:panelGrid>
<h:panelGrid columns="1" rendered="#{BeanLugar.sizeLugar ne '0'}">
<p:dataTable id="resListadoLugar" value="#{BeanLugar.doListarLugar()}" var="ls"
paginator="true" rows="5" paginatorPosition="both" rowsPerPageTemplate="5,10,15">
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelLugar}"/>
</f:facet>
<h:outputText value="#{ls.nombre}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelUbicacion}"/>
</f:facet>
<h:outputText value="#{ls.objPais.nomb_pais}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelVer}"/>
</f:facet>
<p:commandLink title="Ver" action="#{BeanLugar.mostrarLugar(ls)}"
value="Ver" update=":LugarTabView:form_mostrar_listado:DetalleLugar"
oncomplete="LugarDialogo.show()"> </p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelEditar}"/>
</f:facet>
<p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
value="Editar"
update=":LugarTabView:form_mostrar_listado:ModificarLugar"
oncomplete="LugarDialogo2.show()"> </p:commandLink>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg.labelEliminar}"/>
</f:facet>
<p:commandLink title="Eliminar" action="#{BeanLugar.eliminarLugar(ls)}"
value="Eliminar"
update=":LugarTabView:form_mostrar_listado:EliminarLugar"
oncomplete="LugarDialogo3.show()"> </p:commandLink>
</p:column>
</p:dataTable>
</h:panelGrid>
</p:panel>
</h:form>
</p:tab>
You are processing all form so JSF tries yo validate all components with required true. You have to tell commandLink what you want to process, for example:
<p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
value="Editar"
update=":LugarTabView:form_mostrar_listado:ModificarLugar"
oncomplete="LugarDialogo2.show()"
process="resListadoLugar"> // or the path of the component you want to process
</p:commandLink>

why does the p:dialog not submit values to bean

I have a small jsf/primefaces application with a datgrid that shows (order) items.
Now I want to add items during a dialog.
I open the dialog with a button click. - works
I want to submit the values from the dialog to the bean and update the datagrid.
If I use a default value (not from the dialog) it works. The item get shown in the datagrid and the dialog get closed. That means.
-addItem Function works
-update works
But if I want to add the values from the dialog I get a null Pointer Exception. So my values will not set in the bean.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<p:fieldset legend="Positionen" toggleable="true" toggleSpeed="500" styleClass="mbsFieldSet">
<h:form id="form_positions">
<p:growl id="messages" showDetail="true" />
<!-- Add position mask -->
<!-- Button to open the open position mask -->
<p:commandButton id="btOpenAddPositionMask" value="Position via Dialog" onclick="dlg.show();">
</p:commandButton>
<p:dataTable var="banfPosition" value="#{banfPositionBean.lsBanfPositions}"
id="tableBanfPositions" editable="true" >
<f:facet name="header">Positionen</f:facet>
<!-- AJAX Events for editing position values -->
<p:ajax event="rowEdit" listener="#{banfPositionBean.onEdit}"
update=":form_positions:messages"/>
<p:ajax event="rowEditCancel" listener="#{banfPositionBean.onCancel}"
update=":form_positions:tableBanfPositions" />
<p:column headerText="Menge" style="width:50px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.amount}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.amount}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Matr. / Lager-Nr." style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.stockNumber}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.stockNumber}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Artikel" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.article}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.article}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Preis/Einheit" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.price}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.price}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Gesamtpreis" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.sum}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.sum}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Etat-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.etat}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.etat}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Anlagen-Nr" style="width:125px">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{banfPosition.complex}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{banfPosition.complex}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Ändern" style="width:20px; text-align:center">
<p:rowEditor />
</p:column>
<p:column headerText="Löschen" style="width:20px; text-align:center" >
<p:commandButton id="deletePos" actionListener="#{banfPositionBean.deletePos(banfPosition)}"
update=":form_positions:tableBanfPositions" ajax="true" icon="ui-icon ui-icon-close" iconPos="center"
title="Löscht den Eintrag in dieser Zeile." />
</p:column>
</p:dataTable>
</h:form>
</p:fieldset>
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</p:dialog>
</ui:composition>
I try it with the h:form-Tag as it is shown on http://www.primefaces.org/showcase/ui/dialogForm.jsf But If I add this.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Artikel:" />
<p:selectOneMenu id="selectArticleForPosition"
value="#{banfPositionBean.selectedArticle}" var="art"
panelStyle="width:150px" style="width:260px" effect="fade"
filterMatchMode="starts" filter="true">
<f:selectItems value="#{dataBean.lsArticle}" var="article"
itemLabel="#{article.name}" itemValue="#{article}" />
<p:column>
#{art.id} - #{art.name}
</p:column>
</p:selectOneMenu>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();"
ajax="true" process="#all" type="submit">
</p:commandButton>
</h:form>
</p:dialog>
the page get reloaded but my bean will not be called either.
Do anyone have an idea what i am doing wrong?
Thanks for help.
-------------------------------------------
*EDIT*
-------------------------------------------
I try it with an p:inputText instead of an selectOneMenu an the bean gets called.
<p:dialog header="Neue Position hinzufügen" widgetVar="dlg"
resizable="false" appendToBody="true">
<h:form id="form_dialog">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel for="inputTxt" value="Artikel:" />
<p:inputText id="inputTxt" value="#{banfPositionBean.testStr}"></p:inputText>
</h:panelGrid>
<p:commandButton id="btAddPosition" value="Position einfügen"
actionListener="#{banfPositionBean.addPos()}"
update=":form_positions:tableBanfPositions" oncomplete="dlg.hide();">
</p:commandButton>
</h:form>
</p:dialog>
So I just need to find out why it will not work for the selectOneMenu.
First I don't know what is a type of property selectedArticle, I guess it is the same type as article (in itemValue) attribute. You should define converter or on the other hand you should bind value of selectOneMenu to be the same type as article.id, and set itemValue to #{article.id}.

ajax is not updating a component situated in another <ui:define

Hi i have a command link so when click it i action="#{projectAdminisrationMB.showGroups(userObj)}" a fieldset will be rendred <p:fieldset legend="Manage User Groups" id="manageUserGroupsFS" rendered="#{projectAdminisrationMB.manageUserGroupsFSFlag}">
when the fieldset was in the same <ui:define name="body"> everything works but when i put it in a separated ui:define it will not be rendered.
Here's the code :
<ui:define name="body">
<h:form id="manageProjeUFform">
<div class="right">
<p:growl id="growl" showDetail="true" sticky="true" />
<br/><br/><br/><br/>
<h:panelGrid columns="2" cellpadding="10">
<p:column>
<p:fieldset legend=" Users ">
<h:panelGrid columns="2" cellpadding="10">
<p:dataTable border="1" value="#{projectAdminisrationMB.projectUsersList}"
id="projectUserDt"
var="userObj"
rowKey="#{userObj.name}"
selection="#{projectAdminisrationMB.selectedExistingProjectUser}"
selectionMode="single"
rowIndexVar="rowIndex"
binding="#{table1}">
<p:column id="column1">
<f:facet name="header">
<h:outputText value="Login"></h:outputText>
</f:facet>
<h:outputText value="#{userObj.name}"/>
</p:column>
<p:column id="column2">
<f:facet name="header">
<h:outputText value="Entire Name"></h:outputText>
</f:facet>
<h:outputText value="#{userObj.lastName}"></h:outputText>
<h:outputText value="#{userObj.firstName}"></h:outputText>
</p:column>
<p:column id="column5">
<f:facet name="header">
<h:outputText value="Groups"></h:outputText>
</f:facet>
<p:commandLink id="manageUG" title="Manage User Groups" style="margin-right:5px" update=":rightContentform:manageUserGroupsFS" action="#{projectAdminisrationMB.showGroups(userObj)}" ajax="true">
<h:graphicImage value="../images/cssImg/manage-groups-icon.png" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow}" value="#{userObj}" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow.dbRowIndex}" value="#{table.rowIndex}" />
</p:commandLink>
</p:column>
<f:facet name="footer">
<p:commandButton id="addProjectUserdlg" value=" Add " onclick="dlg1.show()" />
<p:commandButton id="deleteProjectUserdlg" value=" Delete " onclick="confirmation.show()"/>
</f:facet>
</p:dataTable>
</h:panelGrid>
</p:fieldset>
</div>
</h:form>
</ui:define>
<h:panelGrid columns="3">
<h:panelGrid id="display" header="User Detail" columns="2" cellpadding="4">
<f:facet name="header">
<p:graphicImage value="/images/users/user.png"/>
</f:facet>
<h:outputText value="Login:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.lastName}" />
<h:outputText value="Name:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.lastName}" />
<h:outputText value="First Name:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.firstName}" />
<h:outputText value="Email:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.email}" />
<h:outputText value="Phone:" />
<h:outputText value="#{projectAdminisrationMB.selectedUserRow.phoneNumber}" />
</h:panelGrid>
<p:pickList id="pickList" value="#{projectAdminisrationMB.selectedUserGroups}" var="group"
itemLabel="#{group}" itemValue="#{group}" converter="groupConverter" >
<f:facet name="sourceCaption">Belong To</f:facet>
<f:facet name="targetCaption">Exclude From</f:facet>
<p:column style="width:25%">
<p:graphicImage value="/images/group/#{group.name}.gif" />
</p:column>
<p:column style="width:75%;">
#{group.name}
</p:column>
<p:ajax event="transfer" listener="#{projectAdminisrationMB.onTransferGroup}" update=":manageProjeUFform:growl" />
</p:pickList>
<p:commandButton id="saveGroupsBtn" value="Save" update=":manageProjeUFform:growl" actionListener="#{projectAdminisrationMB.saveUserGroupsModif}"/>
</h:panelGrid>
</p:fieldset>
</h:form>
</ui:define>
Any help will be appreciated .
here's the solution enjoy it :)
<p:commandLink id="manageUG" title="Manage User Groups" style="margin-right:5px"
update="#all" action="#{projectAdminisrationMB.showGroups(userObj)}" ajax="true">
<h:graphicImage value="../images/cssImg/manage-groups-icon.png" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow}" value="#{userObj}" />
<f:setPropertyActionListener target="#{projectAdminisrationMB.selectedUserRow.dbRowIndex}" value="#{table.rowIndex}" />
</p:commandLink>
i used #all to update the ui define section that's it

Resources