Primefaces pagination (lazydatamodel) load method - jsf

I´ve a couple issues with a page I´m working on.
I have two sections: frmConf and frmData.
The first one has some parameters I use for searching purposes.
The second one has a DataTable defined as lazy and algo I have it´s corresponding backing wich extends LazyDatamodel.
In the mentioned DataTable in section 2 I have a column with a commandLink which creates a PDF document for the selected row in the DataTable.
The problem I´m facing is it works just fine the first time I load the page:
It calls the load (#override) method from LazyDatamodel and presents the first 10 records of the query results from the DB.
Then, when I click on the commandLink column it shows the "save as" dialog for the corresponding PDF just fine and I can proceed to download the file.
But then, for some reason wich I don´t yet understand, if I click another row´s PDF commandLink it goes and calls the referred load method a requeries the DB assuming I´m trying to do some pagination and it doesn´t even generate the required PDF.
What I´m trying to achieve is just load the page for every pagination case and not for any unrelated event like clicking the PDF button for the selected row.
Why is it reloading and requerying (even though it shows the same results as the indexes for pagination haven´t change) the entire page content after the first (correct)PDF generation?
It´s my guess something happens after the first PDF generation (it leaves the page with some "reload required" state.
I´m leaving the markup from the page as well as the corresponding backing bean PDF generation method.
Please I´d really appreciate if someone could help me with this.
Thanks!
JSF markup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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">
<ui:composition template="/templates/cimaTemplate.xhtml">
<ui:define name="tituloPagina">
<h:outputText value="Consulta Documentos" />
</ui:define>
<ui:define name="tituloFormulario">
<h:outputText value="Documentos" styleClass="titulo" />
</ui:define>
<ui:define name="contenido">
<style>
.style1 {
text-align: right;
}
.style3 {
text-align: left;
}
.style2 {
text-align: center;
background: blue;
color: white;
font-weight: bold;
}
.colEstadoStyle {
td:nth-child(1)
width: 20px;
}
.imageClass {
display: block;
background-image: url('/imagenes/pdf.png') no-repeat 100%;
}
</style>
<h:form id="frmConf" styleClass="form" >
<p:growl id="growl" showDetail="true" sticky="true" />
<p:panel id="datosEmisorPanel">
<p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" />
<p:panelGrid style="margin: 0 auto;" id="panelG">
<p:row>
<p:column>
<p:panelGrid>
<p:row>
<p:column style="text-align: center;" colspan="2">
<strong><h:outputLabel styleClass="label" value="Seleccionar Archivo" /></strong>
<p:selectManyCheckbox style="text-align: center;"
value="#{cabDocumentoMB.selectedOptionsEmail}">
<f:selectItem itemValue="PDF" itemLabel="PDF" />
<f:selectItem itemValue="XML" itemLabel="XML" />
</p:selectManyCheckbox>
</p:column>
</p:row> <p:row>
<p:column colspan="2">
<strong><h:outputLabel styleClass="label"
value="E-Mails" /></strong>
<br></br>
<h:inputTextarea value="#{cabDocumentoMB.correos}"
cols="40" />
<br></br>
</p:column>
</p:row> <p:row>
<p:column colspan="2">
<strong><h:outputLabel styleClass="style1"
value="Formato: email1#email.com,email2#email.com" /></strong>
</p:column>
</p:row> <p:row>
<p:column rowspan="2">
<p:commandButton icon="ui-icon-mail-closed"
value=" Envio normal" id="bto_enviarEmail"
oncomplete="bloquearPagina.hide()"
onstart="bloquearPagina.show()"
action="#{cabDocumentoMB.EnviarCorreos('Normal')}"
update="growl">
</p:commandButton>
<p:blockUI block="frmConf" widgetVar="bloquearPagina">
Enviando correo...<br />
<p:graphicImage value="/imagenes/ajax-loader.gif" />
</p:blockUI>
<p:blockUI block="frmConf" widgetVar="bloquearReproceso">
Reprocesando...<br />
<p:graphicImage value="/imagenes/ajax-loader.gif" />
</p:blockUI>
</p:column>
<p:column rowspan="2">
<p:commandButton value=" Envio ZIP" icon="ui-icon-tag"
action="#{cabDocumentoMB.EnviarCorreos('ZIP')}"
oncomplete="bloquearPagina.hide()"
onstart="bloquearPagina.show()" update="growl">
</p:commandButton>
<br />
</p:column>
</p:row> </p:panelGrid>
</p:column>
<p:column colspan="0">
<p:panelGrid> <p:row>
<p:column colspan="1" styleClass="style1">
<strong><h:outputLabel styleClass="label" size="30"
value="Cédula/RUC/Pasaporte" /></strong>
</p:column>
<p:column colspan="1" styleClass="style3">
<h:inputText styleClass="text" style="font-weight: bold;"
value="#{cabDocumentoMB.ruc}" />
</p:column>
</p:row> <p:row>
<p:column colspan="1" styleClass="style1">
<strong><h:outputLabel styleClass="label" size="30"
value="Nombres:" /></strong>
</p:column>
<p:column colspan="1" styleClass="style3">
<h:inputText styleClass="text" style="font-weight: bold;"
value="#{cabDocumentoMB.razonSocial}" />
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Número del Documento:" /></strong>
</p:column>
<p:column styleClass="style3">
<h:inputText value="#{cabDocumentoMB.numDocumento}"
size="30" title="Número del Documento" placeHolder="TBD"/>
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Tipo de Documento:" /></strong>
</p:column>
<p:column styleClass="style3">
<p:selectOneMenu
value="#{cabDocumentoMB.seleccionTipo}">
<f:selectItems value="#{cabDocumentoMB.tipo}" />
</p:selectOneMenu>
</p:column>
</p:row> <p:row>
<p:column styleClass="style1">
<strong><h:outputLabel styleClass="label"
value="Estados:" /></strong>
</p:column>
<p:column styleClass="style3">
<p:selectOneMenu
value="#{cabDocumentoMB.seleccionTipoEstado}">
<f:selectItems value="#{cabDocumentoMB.tipoEstados}" />
</p:selectOneMenu>
</p:column>
</p:row> <p:row>
<p:column>
<strong><h:outputLabel styleClass="label"
value="Fecha Inicial:" /></strong>
<br></br>
<p:calendar id="txt_inicial"
value="#{cabDocumentoMB.fechaInicio}"
pattern="yyyy-MM-dd" mask="true" mode="popup" showOn="button"
readonlyInput="true">
<f:convertDateTime type="date" dateStyle="short"
pattern="yyyy-MM-dd" />
</p:calendar>
</p:column>
<p:column>
<strong><h:outputLabel styleClass="label"
value="Fecha Final:" /></strong>
<br></br>
<p:calendar id="txt_final"
value="#{cabDocumentoMB.fechaFinal}"
pattern="yyyy-MM-dd" mask="true" mode="popup" showOn="button"
readonlyInput="true">
<f:convertDateTime type="date" dateStyle="short"
pattern="yyyy-MM-dd" />
</p:calendar>
</p:column>
</p:row> <p:row>
<p:column style="text-align: center;">
<p:commandButton value=" Busqueda " icon="ui-icon-search"
title="Buscar Filtrado"
action="#{cabDocumentoMB.findDocumentos()}"
update=":frmData:listaDocumentos,:frmConf:datosEmisorPanel">
</p:commandButton>
</p:column>
<p:column>
<p:commandButton value="Reprocesar documentos "
icon="ui-icon-tag"
action="#{CabDocumentoMB.reprocesarDocumentos()}"
disabled="#{CabDocumentoMB.botonReprocesarActivo}"
update=":frmData:listaDocumentos,:frmConf:datosEmisorPanel">
</p:commandButton>
<br />
</p:column>
</p:row> </p:panelGrid>
</p:column>
</p:row>
</p:panelGrid>
</p:panel>
</h:form>
<h:form id="frmData" styleClass="form">
<p:panel id="datosDetalle22" >
<h:panelGroup id="listaDocumentos">
<p:dataTable id="lazyDataTable"
var="documento"
value="#{cabDocumentoMB.allDocumentos}"
paginator="true" rows="10" rowsPerPageTemplate="10,50,100"
selection="#{cabDocumentoMB.seleccionDocu}"
update=":frmData:listaDocumentos"
lazy="true">
<f:facet name="header">
Consulta de Documentos
</f:facet>
<p:column headerText="Identificación" style="width:10% ; font-size:11px" >
<h:outputText value="#{documento.identificacionComprador}" style="font-size:11px;" />
</p:column>
<p:column headerText="Razón Social" style="width:25% ; font-size:11px">
<h:outputText value="#{documento.razonSocialComprador}" style="font-size:11px;" />
</p:column>
<p:column headerText="Comprobante" style="width:10% ; font-size:11px">
<h:outputText value="#{documento.codigoDocumento}" style="font-size:11px;" />
</p:column>
<p:column headerText="Número" style="width:10% ; font-size:11px">
<h:outputText value="#{documento.id.serie}" style="font-size:11px;" />
</p:column>
<p:column headerText="Importe total" style="width:7% ; text-align:right ; font-size:11px">
<h:outputText value="#{documento.importeTotal}" style="font-size:11px;" />
</p:column>
<p:column headerText="Fecha Emisión" style="width:7% ; text-align:center ; font-size:11px">
<h:outputText value="#{documento.fechaEmision}" style="font-size:11px;" />
</p:column>
<p:column headerText="Ambiente"
style="width:10% ; text-align:center ; font-size:11px">
<h:outputText value="#{documento.id.ambiente}" style="font-size:11px;" />
</p:column>
<p:column headerText="Estado" style="width:20% ; font-size:11px">
<p:row>
<p:column>
<h:outputText value="#{documento.estadoTransaccion}" style="font-size:11px;" />
</p:column>
<p:column>
<p:commandButton update=":frmData:display" oncomplete="detalleEstadoDiag.show()" icon="ui-icon-search" style="float:right;">
<f:setPropertyActionListener
target="#{cabDocumentoMB.seleccionDocumentos}"
value="#{documento}"
/>
</p:commandButton>
</p:column>
</p:row>
</p:column>
<p:column headerText="PDF" style="font-size:11px" >
<p:commandLink action="#{cabDocumentoMB.pdf(documento,'')}"
ajax="false"
disabled="#{CabDocumentoMB.desactivaBotonPDF}"
update=":frmData:datosDetalle22">
<p:graphicImage value="/imagenes/pdf.png" ></p:graphicImage>
<f:setPropertyActionListener
target="#{cabDocumentoMB.documentos}"
value="#{documentos}" >
</f:setPropertyActionListener>
</p:commandLink>
</p:column>
<p:column headerText="XML" style="font-size:11px" >
<p:commandLink
action="#{cabDocumentoMB.xml(documento)}"
ajax="false"
update=":frmData:datosDetalle22"
disabled="#{CabDocumentoMB.desactivaBotonXML}">
<p:graphicImage value="/imagenes/xml.png"></p:graphicImage>
<f:setPropertyActionListener
target="#{cabDocumentoMB.documentos}"
value="#{documentos}">
</f:setPropertyActionListener>
</p:commandLink>
</p:column>
<p:column selectionMode="multiple"/>
</p:dataTable>
<p:dialog header="Detalle de estado" widgetVar="detalleEstadoDiag" resizable="false" width="400" showEffect="explode" hideEffect="explode" style="font-size:11px" >
<h:panelGrid id="display" columns="2" cellpadding="4">
<div align="left" style="font-size:11px;"><h:outputText value="Descripción: " style="font-weight:bold" /></div>
<h:outputText value="#{cabDocumentoMB.seleccionDocumentos.msjError}" />
</h:panelGrid>
</p:dialog>
</h:panelGroup>
</p:panel>
<p:panel id="datosExcel" style="align=center">
<h:commandLink>
<p:graphicImage value="/imagenes/excel.png" />
<p:dataExporter type="xls"
postProcessor="#{manager.postProcessXLS}" target="myData"
fileName="myexcel" />
</h:commandLink>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</html>
Backing: (PDF Method)
...
JRBeanCollectionDataSource beanCollectionDataSource = new JRBeanCollectionDataSource(detallesAdiciones);
String reportPath = pathReports.get(doc.getId().getCodigoDocumento());
JasperPrint jasperPrint = null;
try {
jasperPrint = JasperFillManager.fillReport(reportPath, obtenerMapaParametrosReportes(obtenerParametrosInfoTriobutaria(doc), obtenerInfoFactura(lstFactDetAdictDocumento,doc)), beanCollectionDataSource);
} catch (JRException e) {
e.printStackTrace();
}
HttpServletResponse httpServletResponse = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
httpServletResponse.addHeader("Content-disposition", "attachment; filename="+name);
ServletOutputStream servletOutputStream = null;
try {
servletOutputStream = httpServletResponse.getOutputStream();
} catch (IOException e) {
e.printStackTrace();
}
try {
JasperExportManager.exportReportToPdfStream(jasperPrint, servletOutputStream);
} catch (JRException e) {
e.printStackTrace();
}
FacesContext.getCurrentInstance().responseComplete();

Related

Multiple JSF progressBar inside same component

I´m trying to show the progress of several batch processes using a progressbar for each one of them. The problem is that only one progressbar is been sent to server side (the last one). Here is the code...
I made a RequestScoped Named bean for the progress beacause I read that for multiple progressBar it is needed a bean instance for each one of the progressbars, but that do not resolve my problem.
I'm using Primefaces 6.1 with JSF 2.2.
Any ideas? Thanks!
<h:form id="formExecutions">
<p:dataGrid id="jobs" value="#{jobExecutorController.jobExecutions}" var="job" rows="5" paginator="true" emptyMessage="#{MessageResources['text.noRecordsFound']}"
paginatorPosition="bottom" columns="1" layout="grid">
<f:facet name="header">
#{MessageResources['text.batchProcesses']}
</f:facet>
<p:outputPanel layout="block" >
<p:panelGrid cellpadding="5" styleClass="vf-panelGrid">
<p:row style="width:100%">
<p:column>
<p:outputLabel for="executionId" value="#{MessageResources['text.executionId']}:" style="font-weight:bold"/>
</p:column>
<p:column>
<h:outputText id="executionId" value="#{job.executionId}" />
</p:column>
<p:column>
<p:outputLabel for="name" value="#{MessageResources['text.name']}:" style="font-weight:bold"/>
</p:column>
<p:column style="width:10%">
<h:outputText id="name" value="#{job.name}"/>
</p:column>
<p:column style="width:50%" rowspan="2">
<p:progressBar id="progressBar" widgetVar="progressBar" ajax="true" value="#{progressController.progress(job)}" labelTemplate="{value}%" styleClass="animated" style="height: 20px; line-height: 20px;" global="false" interval="3000">
<p:ajax event="complete" listener="#{progressController.onCompleteJob(job)}" update="messageDisplay" process="#this"/>
<p:ajax update="jobInfo"/>
</p:progressBar>
</p:column>
<p:column style="width:4%" />
<p:column rowspan="2" style="text-align:right">
<p:commandButton id="restart" onclick="PF('confirmRestartJob').show()" styleClass="coloured-icons-batch restart-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="restart" value="#{MessageResources['text.restartJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="stop" onclick="PF('confirmStopJob').show()" styleClass="coloured-icons-batch stop-image-icon blink"
disabled="#{not job.enableStop}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="stop" value="#{MessageResources['text.stopJobExecution']}" position="top"></p:tooltip>
<p:spacer width="10" />
<p:commandButton id="abandon" onclick="PF('confirmAbandonJob').show()" styleClass="coloured-icons-batch abandon-image-icon blink"
disabled="#{not job.enableRestartAbandon}" immediate="true" title="">
<f:setPropertyActionListener value="#{job.executionId}" target="#{jobExecutorController.executionIdSelected}" />
<f:setPropertyActionListener value="#{job.name}" target="#{jobExecutorController.executionNameSelected}" />
</p:commandButton>
<p:tooltip for="abandon" value="#{MessageResources['text.abandonJobExecution']}" position="top"></p:tooltip>
</p:column>
</p:row>
</p:panelGrid>
<h:panelGroup id="jobInfo" >
<p:panelGrid columns="4" cellpadding="5" styleClass="vf-panelGrid">
<p:outputLabel for="creationDate" value="#{MessageResources['text.creationDate']}:" style="font-weight:bold"/>
<h:outputText id="creationDate" value="#{job.formattedDate(job.createdDate)}" />
<p:outputLabel for="startDate" value="#{MessageResources['text.dateStartProcess']}:" style="font-weight:bold"/>
<h:outputText id="startDate" value="#{job.formattedDate(job.startedDate)}" />
<p:outputLabel for="lastUpdate" value="#{MessageResources['text.lastUpdate']}:" style="font-weight:bold"/>
<h:outputText id="lastUpdate" value="#{job.formattedDate(job.lastUpdate)}" />
<p:outputLabel for="toProcess" value="#{MessageResources['text.itemsToProcess']}:" style="font-weight:bold"/>
<h:outputText id="toProcess" value="#{job.itemsToProcess}" />
<p:outputLabel for="endDate" value="#{MessageResources['text.ended']}:" style="font-weight:bold"/>
<h:outputText id="endDate" value="#{job.formattedDate(job.endedDate)}" />
<p:outputLabel for="processed" value="#{MessageResources['text.itemsProcessed']}:" style="font-weight:bold"/>
<h:outputText id="processed" value="#{job.itemsProcessed}" />
<p:outputLabel for="status" value="#{MessageResources['text.state']}:" style="font-weight:bold"/>
<h:outputText id="status" value="#{job.status}" />
</p:panelGrid>
</h:panelGroup>
</p:outputPanel>
<p:spacer width="5"/>
<p:separator />
<p:spacer width="5"/>
</p:dataGrid>
My RequestScope backing bean...
#Named("progressController")
#RequestScoped
public class ProgressController
{
#EJB
private EJBJobRepositoryLocal ejbJobRepository;
public Long progress(DMJob jobExecution) throws VfCmsSqlException
{
if (jobExecution.getStatus().equals(BatchStatus.STARTED.name())) {
jobExecution.setProgress(ejbJobRepository.getJobProgress(jobExecution.getExecutionId()));
}
PrimeUtil.get().update("formExecutions:jobInfo");
return jobExecution.getProgress();
}
public void onCompleteJob(DMJob jobExecution)
{
Object[] parameters = {jobExecution.getName(), jobExecution.getExecutionId()};
Messages.displayInfoMessage("text.jobComplete", parameters);
}
}
Ok. The problem is that the PrimeFaces().start() method is not been executed over all the components generated by JSF. So, what I did is a javascript function which is executed when the page is fully loaded. In my case the components that I needed to initialize are several progress bar. My components are inside a data scroller which is inside a form, that's why I concat those id's. The 'i' is the index of each of the rendered progress bar in the page.
<script type="text/javascript">
$(window).load(function() {
startProgress();
});
function startProgress(){
var pid = document.getElementsByClassName('ui-progressbar');
var pidLength = pid.length;
for (var i = 0; i < pidLength; i++) {
var id = "formExecutions:scroller:".concat(i).concat(":progressBar");
PrimeFaces.getWidgetById(id).start();
}
}
</script>
And that was all!

Refresh dialog in primefaces

I am building an application where it is necessary to register a user, more precisely a picture for a user besides his name, username and some other information, when the registration window is show, a default user image is load, then when they select a new image the default image dissapear and the selected one is displayed on the window, and a new button is displayed as well, this button allows the user to remove the selected picture, so the default image must be display again, but I still can't display again the default picture in case de button is clicked to return to the default picture and remove the selected one
View where users are listed and the modal window is displayed
<?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">
<html 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:composition template="/sesionAdmin/_admintmp.xhtml">
<ui:define name="body">
<h:head>
<h:outputScript library="js" name ="Calendario.js"/>
</h:head>
<h:body>
<h:form>
<p:commandButton id="createButton" value="Registrar usuario"
onclick="PF('UsuarioCreateDialog').show()">
</p:commandButton>
</h:form>
<p:separator/>
<h:form id="UsuarioListForm">
<p:panelGrid columns="2" styleClass="panelgrid">
<p:outputLabel style="font-weight: bold;" value="Buscar usuario:" />
<p:inputText placeholder="Digite nombres, apellidos, nombre de usuario o email"
style="width: 350px;" value="#{usuarioController.datoBusqueda}" >
<p:ajax event="keyup" update="datalist" listener="#{usuarioController.buscarUsuario()}" />
</p:inputText>
</p:panelGrid>
<p:dataTable id="datalist" value="#{usuarioController.items}" var="item"
paginator="true" widgetVar="tablaUsuarios"
rows="10"
rowsPerPageTemplate="10,20"
>
<f:facet name="header">
</f:facet>
<p:column >
<f:facet name="header">
<h:outputText value="Nombres"/>
</f:facet>
<h:outputText value="#{item.usunombres}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="Apellidos"/>
</f:facet>
<h:outputText value="#{item.usuapellidos}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="Nombre de usuario"/>
</f:facet>
<h:outputText value="#{item.usunombreusuario}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Email"/>
</f:facet>
<h:outputText value="#{item.usuemail}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Cargo"/>
</f:facet>
<h:outputText value="#{item.carid.carnombre}"/>
</p:column>
<p:column width="70" style="text-align: center">
<f:facet name="header">
<h:outputText value="Foto" />
</f:facet>
<p:graphicImage id="imgUsuario" value="#{usuarioController.imagenFlujo}" width="50" height="50" >
<f:param name="id" value="#{item.usuid}" />
</p:graphicImage>
</p:column>
<p:column style="width: 90px">
<f:facet name="header">
<p:outputLabel value="Acciones"/>
</f:facet>
<p:commandButton id="viewButton" icon="ui-icon-search" action="#{usuarioController.seleccionarUsuarioVer(item)}" update=":UsuarioViewForm, :formfotoView" oncomplete="PF('UsuarioViewDialog').show()" />
<p:commandButton id="editButton" icon="ui-icon-pencil" action="#{usuarioController.seleccionarUsuarioEditar(item)}" update=":UsuarioEditForm, :formEditarfoto" oncomplete="PF('UsuarioEditDialog').show()" />
</p:column>
</p:dataTable>
</h:form>
<ui:include src="RegistrarUsuario.xhtml"/>
<ui:include src="EditarUsuario.xhtml"/>
<ui:include src="VerInfoUsuario.xhtml"/>
<p:dialog header="Información" modal="true" position="center" widgetVar="mensajeRegistroExitoso" closable="false">
<p:messages style="font-size: 15px;" showDetail="true" autoUpdate="true"/>
<h:form>
<p:commandButton value="Aceptar" style="font-weight: normal;"
onclick="PF('mensajeRegistroExitoso').hide()"/>
</h:form>
</p:dialog>
</h:body>
</ui:define>
</ui:composition>
</html>
User dialog window
<?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">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition>
<p:dialog id="UsuarioCreateDlg" widgetVar="UsuarioCreateDialog" modal="true" resizable="false"
appendTo="#(body)" header="Registrar usuario">
<h:outputStylesheet name="css/appearUploadFile.css" />
<p:ajax event="close" listener="#{usuarioController.cancelarRegistroUsuario()}"/>
<p:outputLabel style="float: right;" value="  Campos obligatorios" />
<p:outputLabel style="float: right; font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
<br/>
<!--h:form id="formfoto" enctype="multipart/form-data"-->
<center>
<p:outputLabel style="font-weight:bold;" value="Foto de perfil" />
</center>
<center>
<br/>
<p:graphicImage rendered="#{usuarioController.miImagen ==null}"
style="height:100px; width:100px;"
value="#{usuarioController.imagenDefecto}"/>
<p:graphicImage rendered="#{usuarioController.miImagen !=null}"
id="img"
style="height:100px; width:100px;"
value="#{usuarioController.miImagen}"
cache="false"/>
<p:fileUpload mode="advanced" auto="true" fileUploadListener="#{usuarioController.convertirImagenABytes}"
allowTypes="/(\.|\/)(jpe?g|png)$/" sizeLimit="10000000" invalidFileMessage="El archivo no está en el formato válido"
required="true"
update="#form" multiple="false" label="Subir imagen">
</p:fileUpload>
<h:commandLink rendered="#{usuarioController.miImagen !=null}"
value="Imagen por defecto"
actionListener="#{usuarioController.establecerFotoPorDefecto()}"
>
<f:ajax execute="#all" render="#form"/>
<p:ajax update="UsuarioCreateDlg"/>
</h:commandLink>
</center>
<br/>
<!--/h:form-->
<h:form id="UsuarioCreateForm">
<p:panelGrid styleClass="panelgrid" id="panel2">
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Nombres:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usunombres" value="#{usuarioController.selected.usunombres}"
title="#{bundleAdmin.CreateUsuarioTitle_usunombres}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampo75Caracteres"/>
<p:ajax event="keyup" update="msgCaracteresNombre"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Apellidos:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usuapellidos" value="#{usuarioController.selected.usuapellidos}"
title="#{bundleAdmin.CreateUsuarioTitle_usuapellidos}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampo75Caracteres"/>
<p:ajax event="keyup" update="msgCaracteresApellido"/>
</p:inputText>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresNombre" for="usunombres"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresApellido" for="usuapellidos"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Genero:" />
</p:column>
<p:column>
<p:selectOneRadio value="#{usuarioController.selected.usugenero}">
<f:selectItem itemLabel="Masculino" itemValue="M" />
<f:selectItem itemLabel="Femenino" itemValue="F" />
</p:selectOneRadio>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Fecha de nacimiento:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:calendar id="usufechanacimiento"
placeholder="dd/mm/aaaa" pattern="dd/MM/yyyy"
value="#{usuarioController.selected.usufechanacimiento}"
title="#{bundleAdmin.EditUsuarioTitle_usufechanacimiento}"
required="true"
readonlyInput="true"
requiredMessage="Campo obligatorio"
showOn="button"
navigator = "true"
locale="es"
maxdate="#{usuarioController.fechaHoy}">
<p:ajax event="keyup" update="msgUsuFechaNacimiento"/>
<p:ajax event="dateSelect" update="msgUsuFechaNacimiento"/> </p:calendar>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message id="msgUsuFechaNacimiento" for="usufechanacimiento"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Email:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usuemail" value="#{usuarioController.selected.usuemail}"
title="#{bundleAdmin.CreateUsuarioTitle_usuemail}"
required="true" requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampoCorreoElectronico"/>
<p:ajax event="keyup" update="msgCaracteresEMail"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Cargo:" />
</p:column>
<p:column>
<p:selectOneMenu id="carid" value="#{usuarioController.cargo}" >
<f:selectItems value="#{cargoController.itemsAvailableSelectOne}"
var="caridItem"
itemValue="#{caridItem}"
itemLabel="#{caridItem.carnombre}"
/>
<f:validator validatorId="ValidarCamposSeleccionar"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresEMail" for="usuemail"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message for="carid"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Tipo de usuario:" />
</p:column>
<p:column>
<p:selectOneMenu id="grupoId" value="#{usuarioController.grupo.gruid}" >
<p:ajax event="change" update="grupoId"/>
<f:selectItems value="#{grupoController.itemsAvailableSelectOne}"
var="grupo"
itemValue="#{grupo.gruid}"
itemLabel="#{grupo.grudescripcion}"
>
</f:selectItems>
<f:validator validatorId="ValidarCamposSeleccionar"/>
</p:selectOneMenu>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message for="grupoId"/>
</p:column>
</p:row>
<p:row>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Nombre de usuario:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:inputText id="usunombreusuario" value="#{usuarioController.selected.usunombreusuario}"
title="#{bundleAdmin.CreateUsuarioTitle_usunombreusuario}" required="true"
requiredMessage="Campo obligatorio">
<f:validator validatorId="ValidarCampoNombreUsuario"/>
<p:ajax event="keyup" update="msgCaracteresNombreUsuario"/>
</p:inputText>
</p:column>
<p:column>
<p:outputLabel style="font-weight:bold;" value="Contraseña:" />
<p:outputLabel style="font-style: italic; font-size: 16px; text-align: left; color: red;" value="* " />
</p:column>
<p:column>
<p:password id="usucontrasena" value="#{usuarioController.selected.usucontrasena}"
title="#{bundleAdmin.CreateUsuarioTitle_usucontrasena}"
required="true" requiredMessage="Campo obligatorio"/>
</p:column>
</p:row>
<p:row>
<p:column>
</p:column>
<p:column>
<p:message id="msgCaracteresNombreUsuario" for="usunombreusuario"/>
</p:column>
<p:column>
</p:column>
<p:column>
<p:message for="usucontrasena"/>
</p:column>
</p:row>
</p:panelGrid>
<p:separator/>
<center>
<p:commandButton action="#{usuarioController.registrarUsuario()}"
value="Registrar" update=":UsuarioListForm:datalist, panel2"
/>
</center>
</h:form>
</p:dialog>
</ui:composition>
</html>
User controller
public class UsuarioController implements Serializable {
#EJB
private com.unicauca.coordinacionpis.sessionbean.UsuarioFacade ejbUsuario;
#EJB
private UsuariogrupoFacade ejbUsuarioGrupo;
private List<Usuario> items = null;
private Cargo cargo;
private Grupo grupo;
private List<Usuario> filtroBusqueda;
private boolean campoFoto;
private boolean campoContrasena;
private String contrasena;
private String datoBusqueda;
private Usuario usuario;
private UploadedFile file;
private SimpleDateFormat formatoFecha;
private byte[] imagen;
private DefaultStreamedContent miImagen;
private UploadedFile uploadedFile;
public StreamedContent getImagenDefecto(){
return Utilidades.getImagenPorDefecto("foto");
}
public StreamedContent getImagen(Usuario usuario) {
RequestContext requestContext = RequestContext.getCurrentInstance();
FacesContext context = FacesContext.getCurrentInstance();
String id = context.getExternalContext().getRequestParameterMap().get("idUsu");
if (usuario.getUsufoto() == null) {
return Utilidades.getImagenPorDefecto("foto");
} else {
return new DefaultStreamedContent(new ByteArrayInputStream(usuario.getUsufoto()));
}
}
public void establecerFotoPorDefecto()
{
System.out.println("Hallo");
this.miImagen = null;
RequestContext requestContext = RequestContext.getCurrentInstance();
//requestContext.execute("PF('UsuarioCreateDialog').hide()");
//requestContext.execute("PF('UsuarioCreateDialog').show()");
//this.imagenPorDefecto();
}
public DefaultStreamedContent getMiImagen() {
convertirBytesAImagen();
/*if(miImagen==null)
miImagen = Utilidades.getImagenPorDefecto("foto");*/
return miImagen;
}
public void convertirBytesAImagen()
{
if(imagen != null)
{
InputStream is = new ByteArrayInputStream((byte[]) imagen);
miImagen = new DefaultStreamedContent(is, "image/png");
}
}
}
The method I am calling to set the default picture is establecerFotoPorDefecto()

How to render same list in multiple datatables in primefaces

I'm using primefaces and I want to populate two datatables with same list.
When I select any one of the books, two panels are shown. The first one shows the details of the book and the author(s). The authors being displayed in the first panel is an editable datatable. I also want to display the same datatable in the second panel. But as you can see it says "No records found". How do I achieve it?
My jsf page is as below:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/Layout.xhtml">
<ui:define name="content">
<f:view>
<h:form id="form">
<p:growl id="msgs" showDetail="true"/>
<p:dataTable value="#{webBooks.entries}" var="book" id="bookList"
styleClass="order-table"
rows="3" paginator="true" editMode="true" editable="true">
<div>
<f:facet name="header">
<p:outputLabel value="Books List"/>
</f:facet>
</div>
<p:columnGroup type="header">
<p:row>
<p:column style="width:10px"/>
<p:column headerText="Id" style="width:30px"/>
<p:column headerText="Book Title" style="width:200px"/>
<p:column headerText="Price" style="width:30px"/>
</p:row>
</p:columnGroup>
<p:column>
<p:commandButton update=":form:bookDetail"
onclick="PF('bookDialog').show(), PF('authorDialog').show()"
title="View Book Detail"
icon="fa fa-info-circle">
<f:setPropertyActionListener value="#{book}" target="#{webBooks.selectedBook}"/>
</p:commandButton>
</p:column>
<p:column>
<p:outputLabel value="#{book.id}"/>
</p:column>
<p:column>
<p:outputLabel value="#{book.title}"/>
</p:column>
<p:column>
<p:outputLabel value="#{book.price}"/>
</p:column>
</p:dataTable>
<p:panelGrid columns="2">
<p:panel id="bookDetail"
header="Book Info"
closable="true"
toggleable="true"
widgetVar="bookDialog" visible="false" style="width:420px;height:250px;">
<p:panelGrid columns="2"
rendered="#{not empty webBooks.selectedBook}">
<h:outputLabel value="Id" />
<p:outputLabel value="#{webBooks.selectedBook.id}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.id}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Title"/>
<p:inputText value="#{webBooks.selectedBook.title}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.title}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Price"/>
<p:inputText value="#{webBooks.selectedBook.price}"
rendered="#{webBooks.selectedBook.editable}"/>
<p:outputLabel value="#{webBooks.selectedBook.price}"
rendered="#{not webBooks.selectedBook.editable}"/>
<p:outputLabel value="Author(s)" />
<p:dataTable value="#{webBooks.selectedBook.authoredBy}"
var="authoredBy"
id="authorList"
scrollable="true"
scrollHeight="70"
scrollWidth="300"
editable="true">
<p:ajax event="rowEdit" listener="#{webBooks.onAuthorEdit}" update=":form:msgs" />
<p:ajax event="rowEditCancel" listener="#{webBooks.onAuthorEditCancel}" update=":form:msgs" />
<p:columnGroup type="header">
<p:row>
<p:column style="width:30px" headerText="Id"/>
<p:column style="width:100px" headerText="Author Name"/>
</p:row>
</p:columnGroup>
<p:column>
<p:outputLabel value="#{authoredBy.id}"/>
</p:column>
<p:column>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{authoredBy.name}"/></f:facet>
<f:facet name="input"><p:inputText value="#{authoredBy.name}" style="width:100%" label="Author Name"/></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:panelGrid>
<p:commandButton value="Edit"
action="#{webBooks.edit(webBooks.selectedBook)}"
rendered="#{not webBooks.selectedBook.editable}"
update=":form:bookDetail"/>
<p:commandButton value="Save"
actionListener="#{webBooks.save(webBooks.selectedBook)}"
rendered="#{webBooks.selectedBook.editable}"
update="bookList"
process="#form"
id="save"
oncomplete="PF('bookDialog').close()"/>
<p:commandButton value="Cancel"
actionListener="#{webBooks.cancel(webBooks.selectedBook)}"
rendered="#{webBooks.selectedBook.editable}"
update=":form:bookDetail"/>
<p:commandButton value="Delete"
actionListener="#{webBooks.remove(webBooks.selectedBook)}"
onclick="return confirm('Are you sure?')"
id="remove"
update="bookList"
process="#form"
oncomplete="PF('bookDialog').close()"/>
</p:panel>
<p:panel header="Author Info"
widgetVar="authorDialog"
closable="true"
toggleable="true"
visible="false" style="width:420px;height:250px;">
<p:panelGrid columns="2">
<p:dataTable value="#{webBooks.selectedBook.authoredBy}"
var="authoredBy"
id="authorsList"
scrollable="true"
scrollHeight="150"
scrollWidth="300"
editable="true">
<p:ajax event="rowEdit" listener="#{webBooks.onAuthorEdit}" update=":form:msgs" />
<p:ajax event="rowEditCancel" listener="#{webBooks.onAuthorEditCancel}" update=":form:msgs" />
<p:columnGroup type="header">
<p:row>
<p:column style="width:30px" headerText="Id"/>
<p:column style="width:100px" headerText="Author Name"/>
</p:row>
</p:columnGroup>
<p:column>
<p:outputLabel value="#{authoredBy.id}"/>
</p:column>
<p:column>
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{authoredBy.name}"/></f:facet>
<f:facet name="input"><p:inputText value="#{authoredBy.name}" style="width:100%" label="Author Name"/></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:panelGrid>
</p:panel>
</p:panelGrid>
</h:form>
</f:view>
</ui:define>
You are only updating update=":form:bookDetail" in your "View Book Detail" button. Add an ID to the panel "Author Info" and update that as well:
<p:commandButton update=":form:bookDetail :form:authorDetail"
...>
...
</p:commandButton>
...
<p:panel id="authorDetail"
header="Author Info"
...>
...
</p:panel>
See also:
Can 'update' attribute update two components simultanously?

In JSF p:dialog not updating dataList

In dataList i'm displaying records and given edit and delete option,
While deleting i need to check my requirement depending on that i need to delete record,
But after delete DataList is not updating.
Could you please solve my problem...
<?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">
<html 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">
<h:head>
</h:head>
<h:body>
<ui:composition template="PageTemplate.html">
<ui:define name="content">
<h:form id="form"
style="width: 70% !important; margin: 100px 0px 0px 205px;">
<!-- <p:growl id="growl" showDetail="true" autoUpdate="true" sticky="false"/> -->
<!-- <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /> -->
<p:tabView id="TabView" style="height:450px;"
activeIndex="#{appraisalComponent.tabindex}">
<p:ajax event="tabChange"
listener="#{appraisalComponent.getSectionAllList}" update="#form" />
<p:tab id="tab1" title="Create Section">
<p:outputPanel id="createSectionIds">
<p:dataTable id="sectionList" paginator="true" rows="5"
value="#{appraisalComponent.sectionListEdit}" var="sections"
editable="true">
<p:ajax event="rowEdit"
listener="#{appraisalComponent.updateSection(sections)}"
update=":form:TabView:sectionList" />
<p:ajax event="rowEditCancel" update=":form:TabView:sectionList" />
<p:column>
<f:facet name="header">
<h:outputText value="Section Name" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{sections.secName}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{sections.secName}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:rowEditor />
<p:spacer width="20" height="0" />
<p:commandButton includeViewParams="true"
style="margin:-18px 0px 0px 20px;" title="Remove"
update=":form:TabView:createSectionIds"
process=":form:TabView:createSectionIds" icon="ui-icon-trash"
oncomplete="${appraisalComponent.sectionHaveQS(sections)} ? PF('confirmDialogDelete').show() : PF('confirmDialog').show()">
<f:setPropertyActionListener value="#{sections}"
target="#{appraisalComponent.selectedSec}" />
</p:commandButton>
<p:dialog header="Delete confirmation" appendToBody="true"
widgetVar="confirmDialogDelete" resizable="false" id="secDlg"
showEffect="fade" hideEffect="explode" modal="true">
Are you sure, you want to delete Employee:<h:outputText
value="#{appraisalComponent.selectedSec.secName}" />
<br></br>
<p:commandButton value="Yes Sure"
onclick="confirmDialogDelete.hide()"
action="#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}"
update=":form:TabView:createSectionIds"
process=":form:TabView:createSectionIds"
style=" margin-left: 34px;">
<p:collector value="#{appraisalComponent.selectedSec}"
removeFrom="#{appraisalComponent.sectionListEdit}" />
</p:commandButton>
<p:commandButton value="Not Yet"
onclick="confirmDialogDelete.hide()" type="button" />
</p:dialog>
<!-- <p:commandButton value="Remove" includeViewParams="true"
update=":form:TabView:createSectionIds"
process=":form:TabView:createSectionIds"
oncomplete="${appraisalComponent.sectionHaveQS(sections)} ? PF('confirmDialogDelete').show() : PF('confirmDialog').show()">
<f:setPropertyActionListener value="#{sections}"
target="#{appraisalComponent.selectedSec}" />
</p:commandButton>
<p:dialog header="Delete confirmation" appendTo="#(body)"
widgetVar="confirmDialogDelete" resizable="false"
showEffect="fade" hideEffect="explode" modal="true">
Are you sure, you want to delete Section:<h:outputText
value="#{appraisalComponent.selectedSec.secName}" />
<br></br>
<p:commandButton value="Yes Sure"
onclick="confirmDialogDelete.hide()"
action="#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}"
update=":form:TabView:createSectionIds"
process=":form:TabView:createSectionIds"
style=" margin-left: 34px;">
<p:collector value="#{appraisalComponent.selectedSec}"
removeFrom="#{appraisalComponent.sectionListEdit}" />
</p:commandButton>
<p:commandButton value="Not Yet"
onclick="confirmDialogDelete.hide()" />
</p:dialog>
-->
<p:dialog header="Delete confirmation" appendTo="#(body)"
widgetVar="confirmDialog" resizable="false" showEffect="fade"
hideEffect="explode" modal="true">
You need to delete questions which are belongs to this section...!<h:outputText
value="" />
<br></br>
<p:commandButton value="Ok" onclick="confirmDialog.hide()"
type="button" />
</p:dialog>
<!-- <p:commandButton value="Remove"
action="#{appraisalComponent.deleteSection(sections)}"
update=":form:TabView:createSectionIds"
process=":form:TabView:createSectionIds">
<p:collector value="#{sections}"
removeFrom="#{appraisalComponent.sectionListEdit}" />
</p:commandButton> -->
</p:column>
</p:dataTable>
</p:outputPanel>
</p:tab>
<p:tab id="tab2" title="Remarks List"
action="#{appraisalComponent.test}">
<p:outputPanel id="remarksIds">
<p:dataTable id="remarksList" paginator="true" rows="5"
value="#{appraisalComponent.remarksListEdit}" var="remarks"
editable="true">
<p:ajax event="rowEdit"
listener="#{appraisalComponent.updateRemarks(remarks)}"
update=":form:TabView:remarksList" />
<p:ajax event="rowEditCancel" update=":form:TabView:remarksList" />
<p:column>
<f:facet name="header">
<h:outputText value="Remarks Name" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{remarks.remName}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{remarks.remName}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Remarks Value" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{remarks.remValue}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{remarks.remValue}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:rowEditor />
<p:commandButton value="Remove"
action="#{appraisalComponent.deleteRemarks(remarks)}"
update=":form:TabView:remarksIds"
process=":form:TabView:remarksIds">
<p:collector value="#{remarks}"
removeFrom="#{appraisalComponent.remarksListEdit}" />
</p:commandButton>
</p:column>
</p:dataTable>
</p:outputPanel>
</p:tab>
<p:tab id="tab3" title="Priority List">
<p:outputPanel id="priorityIds">
<p:dataTable id="priorityList" paginator="true" rows="5"
value="#{appraisalComponent.priorityListEdit}" var="priority"
editable="true">
<p:ajax event="rowEdit"
listener="#{appraisalComponent.updatePriority(priority)}"
update=":form:TabView:priorityList" />
<p:ajax event="rowEditCancel"
update=":form:TabView:priorityList" />
<p:column>
<f:facet name="header">
<h:outputText value="Priority Name" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{priority.prName}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{priority.prName}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:rowEditor />
<p:commandButton value="Remove"
action="#{appraisalComponent.deletePriority(priority)}"
update=":form:TabView:priorityIds"
process=":form:TabView:priorityIds">
<p:collector value="#{priority}"
removeFrom="#{appraisalComponent.priorityListEdit}" />
</p:commandButton>
</p:column>
</p:dataTable>
</p:outputPanel>
</p:tab>
<p:tab id="tab4" title="List Of Section">
<p:dataTable id="dataTable" var="sections"
value="#{appraisalComponent.sectionListToAddQues}"
paginator="true" rows="5">
<p:column>
<f:facet name="header">
<h:outputText value="Section Name :" />
</f:facet>
<h:outputText value="#{sections.secName}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:commandLink value="Edit Questions"
action="#{appraisalComponent.editQuestions}">
<f:param name="sectionId" value="#{sections.secId}" />
</p:commandLink>
</p:column>
</p:dataTable>
<br></br>
</p:tab>
</p:tabView>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
What ever i given in top that is correct, but problem with java method.
to delete, i given one java method " action="#{appraisalComponent.deleteSection(appraisalComponent.selectedSec)}" "
In java that is returning one value like below
public String deleteSection (int secId) {
String temp ;
// some code
return temp;
}
But we should provide only void method like below
public void deleteSection (int secId) {
}
I changed this now my code working fine.
Any way thanks. :)

Problems updating a DataTable in primefaces

I am having trouble updating components in primefaces. Here is one example:
<h:form>
<p:panel style="width: 350px;" header="Partial Process">
<p:dataTable id="tablaPersonas" var="per" value="#{manejador.lista}">
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{per.nombre}" />
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Apellido" />
</f:facet>
<h:outputText value="#{per.apellido}" />
</p:column>
<p:column headerText="Editar" style="text-align: center;">
<p:commandButton value="Editar"/>
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton value="Abrir" onclick="widgetDlgAgregar.show();"/>
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250" height="150" closable="true">
<h:panelGrid id="gridAdd" columns="2">
<h:outputLabel value="Nombre:"/>
<p:inputText value="#{manejador.auxiliarAgregar.nombre}"/>
<h:outputLabel value="Apellido:"/>
<p:inputText value="#{manejador.auxiliarAgregar.apellido}"/>
<p:commandButton oncomplete="widgetDlgAgregar.hide();" update="tablaPersonas,gridAdd" value="Agregar" actionListener="#{manejador.agregarPersona}"/>
</h:panelGrid>
</p:dialog>
</h:form>
As you see, I click on a CommandButton called "Abrir" and a Dialog opens with "Agregar" as title. I fill in the input boxes and when I click the CommandButton "Agregar", the DataTable isn't updated. Why is this happening?
Oh sorry i think you forgot this update
try this it should work
<h:form prependId="false">
<p:panel style="width: 350px;" header="Partial Process">
<p:dataTable id="tablaPersonas" var="per"
value="#{manejador.lista}">
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Nombre" />
</f:facet>
<h:outputText value="#{per.nombre}" />
</p:column>
<p:column style="text-align: center;">
<f:facet name="header">
<h:outputText value="Apellido" />
</f:facet>
<h:outputText value="#{per.apellido}" />
</p:column>
<p:column headerText="Editar" style="text-align: center;">
<p:commandButton value="Editar" />
</p:column>
</p:dataTable>
</p:panel>
<p:commandButton value="Abrir" onclick="widgetDlgAgregar.show();" update="gridAdd" />
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250"
height="150" closable="true">
<h:panelGrid id="gridAdd" columns="2">
<h:outputLabel value="Nombre:" />
<p:inputText value="#{manejador.auxiliarAgregar.nombre}" />
<h:outputLabel value="Apellido:" />
<p:inputText value="#{manejador.auxiliarAgregar.apellido}" />
<p:commandButton oncomplete="widgetDlgAgregar.hide();"
update="tablaPersonas,gridAdd" value="Agregar"
actionListener="#{manejador.agregarPersona}" />
</h:panelGrid>
</p:dialog>
</h:form>
try to put your
<p:dialog header="Agregar" widgetVar="widgetDlgAgregar" width="250" height="150" closable="true">
outside the form and add prependId="false" to your form <h:form prependId="false" >

Resources