Update a <p:datatable with <p:commandButton on diferentes Layouts - ajax

I've been trying to update a table of data via AJAX with a CommanButton, and tried with many answers here but none of them has worked, that more has come not update the table until when the tab is closed and opened again. My code is this:
<h:body >
<p:layout fullPage="true" >
<p:layoutUnit position="west" size="300" header="Criterios de busqueda" resizable="true" closable="true" collapsible="true" >
<h:form id="form2">
<h:panelGrid columns="1" cellpadding="5">
<h:outputText value="Gestión" />
<p:selectManyMenu id="basic" value="#{busquedaController.selectVisita}" style="width: 200px;">
<f:selectItem itemLabel="Vacio" itemValue="vacio" />
<f:selectItem itemLabel="Entrevista" itemValue="Option1" />
<f:selectItem itemLabel="Inscripción" itemValue="Option2" />
<f:selectItem itemLabel="Cotización" itemValue="Option3" />
<f:selectItem itemLabel="Orden de Pedido" itemValue="Option4" />
<f:selectItem itemLabel="Facturación" itemValue="Option5" />
<f:selectItem itemLabel="Entrega de Pedido" itemValue="Option6" />
<f:selectItem itemLabel="Cobro" itemValue="Option7" />
<f:selectItem itemLabel="Garantia" itemValue="Option8" />
<f:selectItem itemLabel="Cambio" itemValue="Option9" />
<f:selectItem itemLabel="Productos por Cotizaciones" itemValue="Option10" />
<f:selectItem itemLabel="Productos por Orden de pedido" itemValue="Option11" />
<f:selectItem itemLabel="Productos por Facturaciones" itemValue="Option12" />
<f:selectItem itemLabel="Productos por Entrega de Pedido" itemValue="Option13" />
<f:selectItem itemLabel="Productos por Cobro" itemValue="Option14" />
<f:selectItem itemLabel="Productos por Garantia" itemValue="Option15" />
<f:selectItem itemLabel="Productos por Cambio" itemValue="Option16" />
</p:selectManyMenu>
<h:outputLabel for="idcliente" value="Id Cliente:"/>
<p:inputText id="idcliente" label="idadmins" value="#{busquedaController.cliente}"/>
<h:outputLabel for="idvendedor" value="Id Vendedor:"/>
<p:inputText id="idvendedor" label="idadmins" value="#{busquedaController.vendedor}"/>
<h:outputLabel for="consulta" value="Id Producto:"/>
<p:inputText value="#{busquedaController.pConsulta}" id="consulta" label="consulta" />
<h:outputLabel value="Desde:"/>
<p:calendar required="true" effect="drop" id="startDate" value="#{busquedaController.desde}" pattern="dd/MM/yy" requiredMessage="El campo Desde es obligatorio">
</p:calendar>
<h:outputLabel for="" value="Hasta:"/>
<p:calendar required="true" effect="drop" id="endDate" value="#{busquedaController.hasta}" pattern="dd/MM/yy" requiredMessage="El campo Hasta es obligatorio" >
</p:calendar>
<p:commandButton value="Buscar" action="#{busquedaController.update_result()}" update=":entrevista" >
</p:commandButton>
<p:messages />
</h:panelGrid>
</h:form>
</p:layoutUnit>
<p:layoutUnit position="center" header="Resultados" >
<p:panel style=" width: 100%" id="panel">
<p:dataTable value="#{busquedaController.result}" id="entrevista" var="item">
<p:column>
<f:facet name="header">
<h:outputText value="Id de la entrevista"/>
</f:facet>
<h:outputText value="#{item.identrevista}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Id del cliente"/>
</f:facet>
<h:outputText value="#{item.idcliente}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="id del vendedor"/>
</f:facet>
<h:outputText value="#{item.idvendedor}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Fecha"/>
</f:facet>
<h:outputText value="#{item.fecha}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Posicion"/>
</f:facet>
<h:outputText value="#{item.posicion}"/>
</p:column>
</p:dataTable>
</p:panel>
</p:layoutUnit>
</p:layout>
</h:body>
when I use :panel:entrevista i get a error , the page doesn't find the panel, so I just tried with :entrevista and is working but not mmdiate. When I use ajax="false", is working but ofcourse that update whole page. I just need update that part of the page.
Can anyone help me?

Related

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

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 ...

Primefaces selectOneRadio(RadioButton) update panelGrid within Dialog

i m trying to update a panelgrid form selectOneRadio within a dialog.
Every time i chose on of the two options the whole panelGrid collapse and a NPE is thorw without any details.
My Sourcecode:
<h:form id="form_tmpVst">
<p:dialog id="dialog_tmpVst" header="Temporäre Verkaufsstelle" widgetVar="dialog_tmpVst" modal="true" resizable="false" showEffect="clip">
<p:selectOneRadio id="radio_placeOnMap" value="#{mapBean.placedByAddress}" layout="custom">
<f:selectItem itemLabel="Karte" itemValue="#{false}" />
<f:selectItem itemLabel="Adresse" itemValue="#{true}" />
<p:ajax update="panel_tmpVst" />
<!-- <p:ajax #process="#this" update="#this panelTempVst" /> -->
</p:selectOneRadio>
<p:panelGrid id="panel_tmpVst">
<p:row>
<p:column colspan="2">
<p:outputLabel value="Platzierung: " />
</p:column>
</p:row>
<p:row>
<p:column>
<p:radioButton id="radio_tmpVstPlaceByAddress" for="radio_placeOnMap" itemIndex="0" />
<p:outputLabel value="Karte" for="radio_tmpVstPlaceByAddress" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:radioButton id="radio_tmpVstPlaceByMap" for="radio_placeOnMap" itemIndex="1" />
<p:outputLabel value="Adresse" for="radio_tmpVstPlaceByMap" />
</p:column>
<p:column>
<p:inputTextarea id="txtarea_address" rows="5" cols="30" counter="txtarea_counter" maxlength="200" counterTemplate="{0} Zeichen übrig."
autoResize="false" value="test data __öäüöäöüöäö" required="#{mapBean.placedByAddress}" disabled=" #{!mapBean.placedByAddress}"
style="resize: none;" />
<br />
<h:outputText id="txtarea_counter" style="font-size: .5em;" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel value="Name:" for="txt_tmpname" />
</p:column>
<p:column>
<p:inputText id="txt_tmpname" value="#{mapBean.tmpVstName}" required="true" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel value="BST:" for="txt_bsttmp" />
</p:column>
<p:column>
<p:inputText id="txt_bsttmp" value="#{mapBean.tmpDistrict}" required="true" />
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel value="VST:" for="txt_vsttmp" />
</p:column>
<p:column>
<p:inputText id="txt_vsttmp" value="#{mapBean.tmpVstNumber}" required="true" />
</p:column>
</p:row>
</p:panelGrid>
<br />
<p:commandButton value="Hinzufügen" id="btn_addTmpVst" action="#{mapBean.addTempVst()}" type="submit" ajax="true"
update=":dataTableForm:markerListDataTable, :mapForm:map, :growl" oncomplete="PF('dialog_tmpVst').hide();" />
</p:dialog>
</h:form>
Before:
After radio-button klick:
Many Thanks in advence
This is normal, basiclly you're updating the h:panelGrid which contains the p:radioButtons without a notice to the owner (p:selectOneRadio).
To solve this update the p:selectOneRadio alongside the h:panelGrid, that way the rendering would work as expected:
<p:ajax update="panel_tmpVst radio_placeOnMap" />

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

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