Error Validation of a Dialog InputText Primefaces jsf - validation

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>

Related

Select many checkbox ajax update view on second event

I'm trying to filter a datatable on categories using a select selectManyCheckbox.
The idea is that when a checkbox is clicked, the datatable values are updated.
Now the problem is that the values are updated after selecting a checkbox twice, but this results in a datable with incorret values.
Here is my xhtml page.
<p:layout id="dossierLayout" widgetVar="dossierLayout">
<p:layoutUnit id="categoriesLayoutUnit" position="west"
header="#{msg['dossier.page.layoutWest.header']}">
<p:selectManyCheckbox id="dossierCategories" value="#{dossierBean.dossierFileCategoriesFilter}"
layout="pageDirection" columns="1" converter="dossierCategorieConverter" immediate="true">
<f:selectItems value="#{dossierBean.dossierFileCategorieList}" var="dossierCategorie"
itemLabel="#{dossierCategorie.categorieDescription}"
itemValue="#{dossierCategorie}"/>
<p:ajax listener="#{dossierBean.filterfiles}" update="dossierForm:dossierFiles" />
</p:selectManyCheckbox>
</p:layoutUnit>
<p:layoutUnit id="dossierFilesLayoutUnit" position="center">
<p:dataTable id="dossierFiles" value="#{dossierBean.filteredFiles}" widgetVar="dossierFiles" filteredValue="#{dossierBean.filteredFiles}" var="dossierFile">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="#{msg['dossier.page.datatable.globalSearch.label']}"/>
<p:inputText id="dossierNameFilterInput" value="#{dossierBean.dossierNameFilter}"/>
<p:watermark id="dossierNameFilterInputWaterMark" for="dossierNameFilterInput" value="#{msg['dossier.page.layoutWest.header.watermark']}"/>
</p:outputPanel>
<p:commandButton id="dossierNameFilterSearch" value="#{msg['cmn.search']}" actionListener="#{dossierBean.filterFilesByName}" update="dossierFiles"/>
<p:commandButton id="dossierNameFilerSearchEmpty" value="#{msg['cmn.clear']}" actionListener="#{dossierBean.clearFilterName}" update="dossierFiles"/>
</f:facet>
<p:column id="dossierFileName" filterBy="#{dossierFile.nameDocument}" filterStyle="display: none;" filterMatchMode="contains" headerText="#{msg['dossier.page.datatable.columheader.Name']}">
<h:outputText styleClass="#{dossierFile.dossierFileIcon.docType}"/>
<h:outputText value="#{dossierFile.nameDocument}"/>
</p:column>
<p:column id="dossierFileLastChanged" headerText="#{msg['dossier.page.datatable.columheader.Date']}">
<h:outputText value="#{dossierFile.dateLastChange}"/>
</p:column>
<p:column id="dossierFileUser" headerText="#{msg['dossier.page.datatable.columheader.User']}">
<h:outputText value="#{dossierFile.user}"/>
</p:column>
<p:column id="dossierFileCategorie" headerText="#{msg['dossier.page.datatable.columheader.Categorie']}">
<h:outputText value="#{dossierFile.categorie.categorieDescription}"/>
</p:column>
<p:column id="dossierFileLocation" headerText="#{msg['dossier.page.datatable.columheader.Location']}">
<h:outputText value="#{dossierFile.nameFolder}"/>
</p:column>
</p:dataTable>
</p:layoutUnit>
</p:layout>

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

How to update other components when rowsPerPage or page changes in <p:dataTable>

I would like to update a component showing data related to the info displayed in the current page of a primefaces dataTable but I couldn't find any info about intercepting ajax events like
onRowsPerPageChange or onPageChanged.
Is there any way to do that?
Using primefaces 3.0.M3 and Glassfish 3.1
Here is my table. The component I want to update is another dataTable inside the footer of the first one:
<p:dataTable id="timbrature_dt"
value="#{timbratureMBean.dataModel}"
paginator="true"
rows="12"
lazy="true"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="6,12,24"
currentPageReportTemplate="#{msgs.pagina} {currentPage} #{msgs.of} {totalPages}"
var="tdett"
widgetVar="ttable"
selection="#{timbratureMBean.selezione}"
selectionMode="single">
<p:ajax event="rowSelect" listener="#{timbratureMBean.onRowSelect}"
update="display :timbrature_dt:giustificativi_dt"
oncomplete="timbDialog.show()" />
<f:facet name="header">
<h:panelGrid columns="1" columnClasses="columnclass-noborders">
<p:outputPanel>
<h:outputText value="#{msgs.dal}: " />
<p:calendar value="#{timbratureMBean.daData}"
pattern="dd/MM/yyyy"
locale="it"
showButtonPanel="true"
navigator="true"
mindate="01/01/2003"
maxdate="#{timbratureMBean.oggi}">
<p:ajax event="dateSelect" listener="#{timbratureMBean.dataChangeListener}"
update="timbrature_dt :timbrature_dt:giustificativi_dt" />
</p:calendar>
<h:outputText value=" #{msgs.al}: " />
<p:calendar value="#{timbratureMBean.aData}"
pattern="dd/MM/yyyy"
locale="it"
showButtonPanel="true"
navigator="true"
mindate="01/01/2003"
maxdate="#{timbratureMBean.oggi}">
<p:ajax event="dateSelect" listener="#{timbratureMBean.dataChangeListener}"
update="timbrature_dt :timbrature_dt:giustificativi_dt" />
</p:calendar>
</p:outputPanel>
<h:outputText value="#{msgs.timbrature}"/>
</h:panelGrid>
</f:facet>
<p:column>
<f:facet name="header">
#{msgs.data_comp}
</f:facet>
<amp:outputData value="#{tdett.sDtComp}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.data_reale}
</f:facet>
<amp:outputData value="#{tdett.sDtTimb}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.terminale}
</f:facet>
<h:outputText value="#{tdett.nrTer}"/>
</p:column>
<p:column filterBy="#{tdett.eU}" filterOptions="#{timbratureMBean.euOptionList}">
<f:facet name="header">
#{msgs.verso}
</f:facet>
<h:panelGroup>
<h:outputText value="#{msgs.entrata}" rendered="#{tdett.eU == 'E'}"/>
<h:outputText value="#{msgs.uscita}" rendered="#{tdett.eU == 'U'}"/>
</h:panelGroup>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.ora_valida}
</f:facet>
<h:outputText value="#{tdett.oraValida}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.ora_reale}
</f:facet>
<h:outputText value="#{tdett.oraReale}"/>
</p:column>
<f:facet name="footer">
<p:dataTable id="giustificativi_dt"
value="#{timbratureMBean.dataList}"
var="gius"
widgetVar="gtable">
<f:facet name="header">
<h:panelGrid columns="1" columnClasses="columnclass-noborders">
<h:outputText value="#{msgs.giustificativi}"/>
</h:panelGrid>
</f:facet>
<p:column>
<f:facet name="header">
#{msgs.voce}
</f:facet>
<h:outputText value="#{gius.voce}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.dal}
</f:facet>
<amp:outputData value="#{gius.sDtIGius}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.al}
</f:facet>
<amp:outputData value="#{gius.sDtFGius}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.nr_giorni}
</f:facet>
<h:outputText value="#{gius.nrGiorni}"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.ora_inizio}
</f:facet>
<amp:outputNvl value="#{gius.oraIGius}" nullval="-"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.ora_fine}
</f:facet>
<amp:outputNvl value="#{gius.oraFGius}" nullval="-"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.nr_ore}
</f:facet>
<amp:outputNvl value="#{gius.nrOre}" nullval="-"/>
</p:column>
<p:column>
<f:facet name="header">
#{msgs.nr_minuti}
</f:facet>
<amp:outputNvl value="#{gius.nrMinuti}" nullval="-"/>
</p:column>
</p:dataTable>
</f:facet>
</p:dataTable>
<p:dialog header="Info" widgetVar="timbDialog" resizable="false"
width="200" showEffect="clip" hideEffect="clip">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Data:" style="font-weight: bold"/>
<amp:outputData value="#{timbratureMBean.selezione.sDtComp}" />
<h:outputText value="Pausa pranzo ridotta: " style="font-weight: bold"/>
<h:outputText value="#{timbratureMBean.gestPausaPranzo}" />
<h:outputText value="Timbratura non allineata: " style="font-weight: bold"/>
<h:outputText value="#{timbratureMBean.timbNonAllineate}" />
</h:panelGrid>
</p:dialog>
Hou,
there is an event for changing a page, see here
http://cagataycivici.wordpress.com/2011/06/10/datatable-hooks/
<p:datatable paginator="true" rows="10" value="#{bean.items}" var="item">
<p:ajax event="page" listener="#{bean.onPaginate}" update="othercomponents" oncomplete="alert('done')"... />
...
though I am still looking for an event for onChangeRows
but, my current problem is only storing user choices, in fact that page event solves storing both on what page I am and how many rows are selected. If onPaginate implements in this way:
public void onPaginate(PageEvent event){
logger.info("I am on page:"+event.getPage());
logger.info("Rows per page set:"+((org.primefaces.component.datatable.DataTable)event.getSource()).getRows());
}
You can see what page you are on and how many rows are selected. And this event is triggered both when you change a page or change how many rows shown.
My solution is using Primefaces 5.2.x.
I found a pretty easy way to implement this, one of the problems I had with udik's solution was that when the onPaginate() method was called, it didn't have the newest selected value.
So here's what I did to make sure you always had the latest value and could save/load it to the database or a cookie or something (we save to a cookie).
<p:dataTable
.....
paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
currentPageReportTemplate="Total records: {totalRecords}, showing page {currentPage} of {totalPages}"
rowsPerPageTemplate="25,50,100"
rows="#{controller.rowsPerPage}"
.....
>
.....
<p:ajax event="page" oncomplete="rowsPerPageUpdate()" />
.....
</p:dataTable>
<p:remoteCommand name="rowsPerPageUpdate" actionListener="#{controller.onPaginate}" />
and then our controller looks like this:
#Dependent
#Named
public class TableController implements Serializable {
private String rowsPerPage = "25"; //default value
.....
public void onPaginate() {
//save to the cookie
}
.....
}
Basically the magic happens in the remoteCommand, which will fire after the ajax event to insure that controller.rowsPerPage has been properly updated.

primefaces datatable filtering

I use the car example from primefaces site, but it works only one time and do not refresh values after onkeyup event. Can somebody help me?:) TOM
Code which I use(from tutorial):
<p:dataTable var="car" value="#{tableBean.carsSmall}"
emptyMessage="No cars found with given criteria"
widgetVar="carsTable">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:" />
<p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column filterBy="#{car.model}"
headerText="Model" footerText="contains"
filterMatchMode="contains">
<h:outputText value="#{car.model}" />
</p:column>
<p:column filterBy="#{car.year}"
headerText="Year" footerText="startsWith">
<h:outputText value="#{car.year}" />
</p:column>
<p:column filterBy="#{car.manufacturer}"
headerText="Manufacturer" footerText="exact"
filterOptions="#{tableBean.manufacturerOptions}"
filterMatchMode="exact">
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column filterBy="#{car.color}"
headerText="Color" footerText="endsWith" filterMatchMode="endsWith">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
</h:form>
and TableBean exactly like this in tut

Resources