I have a problem with a h:commandLink placed in a column in p:dataTable. The action method is not called. I'm using primefaces 2.21 and jsf 2.0.
the code like this:
<ui:define name="center">
<h:form id="form1">
<p:dataTable id="userDataTable"
value="#{adminstratorBean.periodicalUsers}" var="user"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
Ajax Pagination
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{user.id}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{user.name}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Password" />
</f:facet>
<h:outputText value="#{user.password}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Sex" />
</f:facet>
<h:outputText value="#{user.sex}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email" />
</f:facet>
<h:outputText value="#{user.mail}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Phone" />
</f:facet>
<h:outputText value="#{user.phone}"></h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Birthday" />
</f:facet>
<h:outputText value="#{user.birthday}">
<f:convertDateTime type="date"></f:convertDateTime>
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Delete" />
</f:facet>
<h:commandLink value="#{msgs.delete}"
actionListener="#{adminstratorBean.deleteUser(user)}">
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
package wls.bean;
import java.io.Serializable;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;
import org.primefaces.component.datatable.DataTable;
import wls.entity.*;
import wls.myEJB.*;
#ManagedBean
#SessionScoped
public class AdminstratorBean implements Serializable{
#EJB
CommonEJBLocal commonEJB;
#EJB
AdminstratorEJBLocal adminstratorEJB;
List<PeriodicalUser> periodicalUsers;
//Logic Method
public List<PeriodicalUser> getPeriodicalUsers() {
periodicalUsers = adminstratorEJB.listPeriodicalUser();
return periodicalUsers;
}
public String deleteUser(PeriodicalUser selectedUser) {
System.out.println("DEledsfkjsdlkfjldkfjldsk");
System.out.println(selectedUser.getName());
adminstratorEJB.deletePeriodicalUser(selectedUser.getId());
return null;
}
Use action instead of actionListener:
<h:commandLink value="#{msgs.delete}"
action="#{adminstratorBean.deleteUser(user)}">
</h:commandLink>
The actionListener can't be invoked with an argument and is intended to use before business logic gets executed (in your action method).
you should use
< p:commandLink>
instead of
< h:commandLink>
when inside
< p:dataTable>.
Related
I want to open a dataTable list when I click to selectBooleanButton. There is an ajax listener in selectBooleanButton but it is not entering the method on debug node. Here are the codes.
<h:form id="form">
<p:growl id="growl" showDetail="true" sticky="true" />
<h:outputText value="" />
<h3>#{res['ko.yetkiVerme.yetkiVerme.title']}</h3>
<p:dataTable id="uyeListe" var="uy" rowKey="#{uy.kullaniciadi}"
value="#{yetkiVermeBean.uyelerList}" paginator="true" rows="5"
rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
selection="#{yetkiVermeBean.selectedEntity}" selectionMode="single">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.title']}" />
</f:facet>
<p:column filterBy="#{uy.kullaniciadi}" sortBy="#{uy.kullaniciadi}"
filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.userName']}" />
</f:facet>
<h:outputText value="#{uy.kullaniciadi}" />
</p:column>
<p:column filterBy="#{uy.ad}" sortBy="#{uy.ad}"
filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.name']}" />
</f:facet>
<h:outputText value="#{uy.ad}" />
</p:column>
<p:column filterBy="#{uy.soyad}" sortBy="#{uy.soyad}"
filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.surName']}" />
</f:facet>
<h:outputText value="#{uy.soyad}" />
</p:column>
</p:dataTable>
<p:spacer height="20" />
<p:selectBooleanButton id="viewYetkilerButton"
offLabel="#{res['ko.yetkiVerme.uyeListe.unshowAuthorize']}"
value="#{!yetkiVermeBean.isRendered}"
onIcon="#{res['ko.plusIcon']}" offIcon="#{res['ko.minusIcon']}"
onLabel="#{res['ko.yetkiVerme.uyeListe.showAuthorize']}">
<p:ajax listener="#{yetkiVermeBean.checkSelectionforYetkiVer}"
update="viewYetkilerButton"/>
</p:selectBooleanButton>
<p:outputPanel id="listePanel">
<p:dataTable id="uyeListe2" var="uy" rowKey="#{uy.kullaniciadi}"
rendered="#{yetkiVermeBean.isRendered}"
value="#{yetkiVermeBean.uyelerList}" paginator="true" rows="5"
rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
selectionMode="single">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.title']}" />
</f:facet>
<p:column filterBy="#{uy.kullaniciadi}"
sortBy="#{uy.kullaniciadi}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.userName']}" />
</f:facet>
<h:outputText value="#{uy.kullaniciadi}" />
</p:column>
<p:column filterBy="#{uy.ad}" sortBy="#{uy.ad}"
filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="#{res['ko.yetkiVerme.uyeListe.name']}" />
</f:facet>
<h:outputText value="#{uy.ad}" />
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
</ui:define>
And this is my ajax method.
public void checkSelectionforYetkiVer() {
RequestContext context = RequestContext.getCurrentInstance();
isRendered = Boolean.TRUE;
context.update("form:listePanel");
}
What is in leave out?
I have a dataTable for Phone something like :
<p:dataTable value="#{billingInfoBean.billingProfile.payer.phones}" var="phone" id="payerPhoneTable">
<p:column>
<f:facet name="header">
<h:outputText value="Type" />
</f:facet>
<p:selectOneMenu value="#{phone.type}">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{backOfficeLookupClient.allPhoneTypes}" />
</p:selectOneMenu>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Area Code" />
</f:facet>
<h:inputText value="#{phone.areaCode}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Exchange" />
</f:facet>
<h:inputText value="#{phone.exchange}" size="3" maxlength="3" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Local" />
</f:facet>
<h:inputText value="#{phone.local}" size="4" maxlength="4" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Extension" />
</f:facet>
<h:inputText value="#{phone.extension}" size="5" maxlength="5" />
</p:column>
</p:dataTable>
I am trying to use custom validation using the object Phone. I need to call a Phone Validation service which takes these column values as inputs. Can I make use of <f:validator> here in this case?, If yes, how ?
You could attach to the dataTable a validator listener
<f:event type="postValidate" listener="#{bean.customValidation}"/>
And validate the phone object in your bean
public void customValidation(ComponentSystemEvent event) {
...
}
Then iterate through all dataTable childrens and validate each one.
Here ther's a good tutorial to start with.
This omnifaces tag solved my problem :
http://showcase.omnifaces.org/validators/validateMultiple
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>
So, I have a dataTable on my page that shows some basic information and a row expansion to show the extra information. I'm trying to create a button/context menu to show a dialog so the user could edit the informations on the table (basic and extra, all in a form) but I'm having trouble in getting this data from the table. When I click the button to show the dialog, it only shows the information of the first row, and not the row I selected. Any ideas? Thank you. Code follows below.
<p:dataTable id="socios" var="socio" value="#{sociosBean.socios}" rowKey="#{socio.id}"
selection="#{sociosBean.socioEscolhido}" selectionMode="single" paginator="true"
widgetVar="socios" emptyMessage="Nenhum socio encontrado " filteredValue="#{sociosBean.socioFiltro}"
rows="10" paginatorAlwaysVisible="false">
<p:menuitem value ="Editar" update="socios" icon ="ui-icon-search"
oncomplete="editar.show();">
<f:setPropertyActionListener target="#{sociosBean.socioEditar}" value="#{socio}"/>
</p:menuitem>
<p:menuitem value="Excluir" update="socios" icon="ui-icon-close" onclick="excluir.show();"/>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Socios" />
</p:outputPanel>
</f:facet>
<p:column style="width:2%">
<p:rowToggler />
</p:column>
<p:column headerText="ID" filterMatchMode="startsWith" id="id" filterBy="#{socio.id}">
<h:outputText value="#{socio.id}" />
</p:column>
<p:column headerText="Nome" filterBy="#{socio.nome}" filterMatchMode="startsWith" id="colunaNome" >
<h:outputText value="#{socio.nome}"/>
</p:column>
<p:column headerText="Sexo" style="width: 4%">
<h:outputText value="#{socio.sexo}"/>
</p:column>
<p:column headerText="Data de Nascimento">
<h:outputText value="#{socio.dataNascimento}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Cargo">
<h:outputText value="#{socio.cargo}"/>
</p:column>
<p:column headerText="Status">
<p:selectBooleanButton value="#{socio.ativo}" offLabel="Inativo" onLabel="Ativo" disabled="true"/>
</p:column>
<p:column headerText="Editar">
<p:commandButton icon="ui-icon-search" oncomplete="editar.show();">
<f:setPropertyActionListener target="#{sociosBean.socioEditar}" value="#{socio}"/>
</p:commandButton>
</p:column>
<p:rowExpansion>
<p:panelGrid id ="informacao" columns="2" style="width:400px; alignment-baseline: middle" >
<f:facet name="header">
#{socio.nome}
</f:facet>
<h:outputText value="ID"/>
<h:outputText value ="#{socio.id}"/>
<h:outputText value="Data de Nascimento"/>
<h:outputText value="#{socio.dataNascimento}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
<h:outputText value="Nome do Pai"/>
<h:outputText value ="#{socio.nomePai}"/>
<h:outputText value="Nome da Mãe"/>
<h:outputText value ="#{socio.nomeMae}"/>
<h:outputText value="Cargo"/>
<h:outputText value ="#{socio.cargo}"/>
<h:outputText value="Telefone"/>
<h:outputText value ="#{socio.telefone}"/>
<h:outputText value="Ano de Admissão"/>
<h:outputText value ="#{socio.anoAdmissao}"/>
<h:outputText value ="Endereço"/>
<h:outputText value ="#{socio.endereco}"/>
</p:panelGrid>
</p:rowExpansion>
</p:dataTable>
<p:button href="AID.xhtml" value="Voltar"/>
<p:confirmDialog id="excluirSocio" message="Excluir sócio?"
header="Aviso" severity="alert" widgetVar="excluir">
<p:commandButton id="confirm" value="Sim" update="mensagem, socios" oncomplete="excluir.hide();"
actionListener="#{sociosBean.excluirSocio()}" icon="ui-icon-check"/>
<p:commandButton id="decline" value="Não" onclick="excluir.hide();" type="button" icon="ui-icon-close" />
</p:confirmDialog>
<p:dialog id="editarSocio" widgetVar="editar">
<p:panelGrid id="cadastro" columns="2">
<f:facet name="header">Editar Sócio</f:facet>
<p:outputLabel for="nome" value="Nome:"/>
<p:inputText id="nome" required ="true" value ="#{sociosBean.socioEditar.nome}"/>
<p:outputLabel for="s" value="Sexo:"/>
<p:selectOneRadio id="s" value="#{sociosBean.socioEditar.sexo}">
<f:selectItem itemValue="m" itemLabel="Masculino"/>
<f:selectItem itemValue="f" itemLabel="Feminino"/>
</p:selectOneRadio>
<p:outputLabel for ="serie" value="Série:"/>
<p:selectOneMenu id="serie" value="#{sociosBean.socioEditar.serie}">
<f:selectItem itemLabel="3º Ensino Médio" itemValue="3EM" />
<f:selectItem itemLabel="2º Ensino Médio" itemValue="2EM" />
<f:selectItem itemLabel="1º Ensino Médio" itemValue="1EM" />
<f:selectItem itemLabel="8º Ensino Fundamental" itemValue="8EF" />
<f:selectItem itemLabel="7º Ensino Fundamental" itemValue="7EF" />
<f:selectItem itemLabel="6º Ensino Fundamental" itemValue="6EF" />
<f:selectItem itemLabel="5º Ensino Fundamental" itemValue="5EF" />
</p:selectOneMenu>
<p:outputLabel for ="endereco" value ="Endereço:"/>
<p:inputText id ="endereco" maxlength="60" value="#{sociosBean.socioEscolhido.endereco}"/>
<p:outputLabel for ="telefone" value ="Telefone:"/>
<p:inputMask id="telefone" value="#{sociosBean.socioEscolhido.telefone}" mask="(99)9999-9999"/>
<p:outputLabel for ="nomePai" value ="Nome do Pai:"/>
<p:inputText id ="nomePai" maxlength="45" value="#{sociosBean.socioEscolhido.nomePai}"/>
<p:outputLabel for ="nomeMae" value ="Nome da Mãe:"/>
<p:inputText id ="nomeMae" maxlength="45" value="#{sociosBean.socioEscolhido.nomeMae}"/>
<p:outputLabel for ="dataNascimento" value ="Data de nascimento: "/>
<p:calendar id="dataNascimento" value="#{sociosBean.socioEscolhido.dataNascimento}" required="true" navigator ="true" locale ="pt" pattern="dd/MM/yyyy"/>
<p:outputLabel for ="cargo" value ="Cargo:"/>
<p:inputText id ="cargo" maxlength="25" value="#{sociosBean.socioEscolhido.cargo}"/>
<p:outputLabel for ="anoAdmissao" value ="Ano Admissão:"/>
<p:inputMask id ="anoAdmissao" maxlength="4" mask="9999" value="#{sociosBean.socioEscolhido.anoAdmissao}"/>
<f:facet name="footer">
<p:commandButton id="btnEditar" value="Editar" actionListener="#{sociosBean.editarSocio()}"/>
</f:facet>
</p:panelGrid>
</p:dialog>
</h:form>
Bean:
package com.beans;
import com.dao.SociosDAO;
import java.util.ArrayList;
import model.hibernate.Socios;
import java.util.Date;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
#ManagedBean
#SessionScoped
/**
*
* #author João Pedro Sacheti
*/
public class SociosBean {
private String nome;
private String serie;
private char sexo;
private String endereco;
private String nomePai;
private String nomeMae;
private Date dataNascimento;
private String cargo;
private Integer anoAdmissao;
private boolean ativo;
private String telefone;
private List<Socios> socioFiltro;
private ArrayList<Socios> socios;
private Socios socioEscolhido;
private Socios socioEditar;
//getters and setters
public SociosBean() {
this.socios = new ArrayList<Socios>();
this.socioEditar = new Socios();
}
I would guess that the problem is that you are not updating the content of the dialog when you show it. So you would have to add update="editarSocio:cadastro" to the commandButton you use to show the dialog.
But be aware that the id you will have to enter depends on the structure of the XHTML, which I dont know.
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.