Page goes blank after second time component is clicked - jsf

(Sorry If bad english)
I got a page that displays a datatable and the records can be deleted, but I have a condition that if its ID kind it's the only one left it can't be delete. So when this happens I want to display a message in a <p:growl /> component, this happens okay, but if I click the delete button again, the page goes blank and it can't be refreshed or anything, I have to login again.
xhtml:
<p:dataTable id="respProdDT" widgetVar="respProdDT" var="resProd" value="#{caleFactBean.lstResponsablesProductos}"
reflow="true" styleClass="products-table" scrollable="true" scrollWidth="99%"
paginator="true" rows="10" paginatorPosition="bottom" >
<f:facet name="header">
<div align="center">
<h:outputText value="Responsables por Producto" style="font-size: large"/>
</div>
</f:facet>
<p:column headerText="Producto">
<h:outputText value="#{resProd.grupoProducto}" />
</p:column>
<p:column headerText="Rol Autorizador">
<h:outputText value="#{resProd.rolResponsable}" />
</p:column>
<p:column headerText="Tipo Autorizacion">
<h:outputText value="Nivel #{resProd.idNivel}" />
</p:column>
<p:column headerText="Estado Autorizacion">
<h:outputText value="#{resProd.estadoSolicitud}" rendered="#{resProd.isText()}"/>
<p:selectOneMenu value="#{resProd.idEstadoSolicitud}" rendered="#{resProd.isComboBox()}">
<f:selectItem var="car" itemLabel="Select one" itemValue="" />
<f:selectItems value="#{caleFactBean.combo}"/>
</p:selectOneMenu>
</p:column>
<p:column headerText="Fecha Inicio">
<h:outputText value="#{resProd.fechaInicio}" >
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Fecha Fin">
<h:outputText value="#{resProd.fechaFin}" >
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column headerText="Accion">
<p:commandLink id="btnEditarRespProd"
rendered="#{resProd.isEditable()}"
styleClass="ui-icon-document"
oncomplete="PF('dlgEditarRespProd').show();"
update="acordionPanels:frmEditarRespProd"
action="#{caleFactBean.mapearRespProd()}">
<p:tooltip for="btnEditarRespProd" value="Editar" />
<f:setPropertyActionListener value="#{resProd}"
target="#{caleFactBean.respProdAEditar}" />
<p:graphicImage style="width:30px;"
value="/resources/static/images/edit-icon.png" />
</p:commandLink>
<p:commandLink id="btnBorrarRespProd" styleClass="ui-icon-document"
rendered="#{resProd.isRemovable()}"
oncomplete="PF('dlgEliminarRespProd').show();" update="#form">
<p:tooltip for="btnBorrarRespProd" value="Eliminar" />
<f:setPropertyActionListener value="#{resProd}"
target="#{caleFactBean.respProdAEliminar}" />
<p:graphicImage style="width:30px;"
value="/resources/static/images/borrar-icon.png" />
</p:commandLink>
</p:column>
</p:dataTable>
<h:form id="frmEliminarRespProd">
<p:dialog header="¿Eliminar responsable producto?" id="dlgEliminarRespProd" widgetVar="dlgEliminarRespProd" modal="true" resizable="false" closable="false">
<center>
<h:outputLabel value="¿Eliminar registro?" />
<br/><br/>
<p:commandButton value="Cancelar" onclick="PF('frmEliminarRespProd').hide();" />
<p:commandButton value="Aceptar" action="#{caleFactBean.eliminarRespProd}" onclick="PF('frmEliminarRespProd').hide();" style="margin-left: 10px;"/>
</center>
</p:dialog>
</h:form>
Method to delete:
public void eliminarRespProd() throws Exception {
logger.info("respProdAEliminar: " + respProdAEliminar);
//boolean hasMoreThanOne = false;
int countRespProdNivel = 0;
try {
for (ResponsableProdVo respProd : lstResponsablesProductos ) {
if(respProdAEliminar.getIdGrupoProducto() == respProd.getIdGrupoProducto())
countRespProdNivel++;
if(countRespProdNivel > 1) {
break;
}
}
if(countRespProdNivel > 1) {
responsablesProductoService.eliminarRespProd(respProdAEliminar);
FacesContext.getCurrentInstance().getExternalContext().redirect("factnueva-flow");
} else {
//TODO: mensaje "El registro no se puede eliminar al ser el único responsable del producto"
// FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR al eliminar","El registro no se puede eliminar al ser el único responsable del producto");
// FacesContext.getCurrentInstance().addMessage("respProdMssg", message);
// this.mensaje = "El registro no se puede eliminar al ser el único responsable del producto";
// RequestContext.getCurrentInstance().execute("PF('dlgMensajes').show();");
}
} catch (Exception e) {
logger.error("Ocurrio un error al eliminar el registro de Responsables Producto. " + e.getLocalizedMessage());
throw e;
}
}
Any ideas why this could happen?

Related

Primefaces dialog doesn't close when action is completed [duplicate]

This question already has answers here:
Keep p:dialog open when a validation error occurs after submit
(6 answers)
Closed 6 years ago.
i have a dialog with two input fields and a commandButton, to add an object. If the user leaves a blank field a message growl is shown and the dialog stays open. But if the user completes all the fields and press the commandButton the object is added but the dialog doesn't close.
View.xhtml
<h:form id="allIncidenciasAux">
<div id="divBotonCrear">
<p:commandButton value="Añadir Incidencia" type="button" onclick="PF('dlg1').show();"/>
</div> <br/>
<p:tabView>
<p:tab title="All">
<ui:repeat value="#{incidenciaBean.allIncidencias}" var="aux" >
<p:panel id="basic" header="#{aux.titulo}" style="margin-bottom:20px" toggleable="true" collapsed="true" styleClass="#{ aux.solucionado eq 'false' ? 'incNS' : null}">
<h:panelGrid columns="2">
<h:panelGrid style="background-color: #B6C2DE; padding: 10px;">
<h:panelGrid columns="2">
<h:outputText value="Fecha de publicacion: " style="font-weight: bold"/>
<h:outputText value="#{aux.fecha_publicacion}"/>
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputText value="Autor: " style="font-weight: bold"/>
<h:outputText value="#{aux.nombreCompleto}"/>
</h:panelGrid>
<h:panelGrid columns="2">
<h:outputText value="Solucionado: " style="font-weight: bold"/>
<h:outputText value="#{aux.solucionado ? 'Si' : 'No'}"/>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid>
<h:outputText value="Descripción: " style="font-weight: bold"/>
<h:outputText value="#{aux.descripcion}"/>
</h:panelGrid>
</h:panelGrid> <br/>
</p:panel>
</ui:repeat>
</p:tab>
</p:tabView>
<p:growl id="growl" showDetail="true" sticky="false" life="8000"/>
</h:form>
<h:form id="dialogAddIncidencia">
<p:dialog id="newIncDialogo" header="Nueva Incidencia" widgetVar="dlg1" minHeight="40" resizable="false">
<p:ajax event="close" listener="#{incidenciaBean.handleClose}" update=":dialogAddIncidencia"/>
<p:outputLabel value="Título"/> <br/>
<p:inputTextarea id="tituloEdit" value="#{incidenciaBean.titulo}" rows="2" cols="50" counter="displayTA" maxlength="50" counterTemplate="{0} caracteres restantes" autoResize="true" required="true" requiredMessage="Título necesario"/> <br/>
<p:outputLabel id="displayTA"/> <br/> <br/>
<p:outputLabel value="Descripción: "/> <br/>
<p:inputTextarea id="descripcion" value="#{incidenciaBean.descripcion}" rows="10" cols="50" counter="displayDA" maxlength="200" counterTemplate="{0} caracteres restantes" autoResize="true" required="true" requiredMessage="Descripción necesaria"/> <br/>
<p:outputLabel id="displayDA"/> <br/> <br/>
<p:commandButton value="Guardar Incidencia" action="#{incidenciaBean.insertIncidencia()}" oncomplete="if (#{incidenciaBean.camposNoVacios()}) dlg1.hide()" update=":allIncidenciasAux :allIncidenciasAux:growl"/>
<p:messages for="titulo"/>
<p:messages for="descripcion"/>
</p:dialog>
</h:form>
Methods of incidenciaBean.java
public void insertIncidencia(){
HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
UsuarioBean usuarioHttp = (UsuarioBean) httpSession.getAttribute("usuarioSession");
this.idComunidad = usuarioHttp.idComunidad;
this.idUsuario = usuarioHttp.getIdUsuario();
this.solucionado = false;
this.fecha_solucion = null;
DateFormat dateFormat = new SimpleDateFormat("DD-MM-YYYY");
Date date = new Date();
this.fecha_publicacion = dateFormat.format(date);
if(ejb_incidencia.existIncidenciaTitulo(this.titulo, this.descripcion)){
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error:",
"Ya existe una incidencia con el mismo título y descripción."
+ "Por favor, compruebe que no se trata de la misma incidencia."));
} else{
ejb_incidencia.realizaRegistroIncidencia(this);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Info:",
"La incidencia se ha registrado correctamente"));
initialStatusIncidencia();
}
}
public boolean camposNoVacios(){
return !(this.titulo == null || this.descripcion == null);
}
public void initialStatusIncidencia(){
this.titulo = null;
this.descripcion = null;
}
public void handleClose (CloseEvent event){
initialStatusIncidencia();
}
You are correct in using oncomplete; however, I don't think your if (#{incidenciaBean.camposNoVacios()}) statement ever evaluates true. The dialouge only hides if camposNoVacios() returns ture(if bothtitulo and descripcion aren't null). In insertIncidencia()'s else statement (which I assume is the success case) you set them to null with initialStatusIncidencia().
So your program sets titulo and descripcion, checks that they aren't null in insertIncidencia(), and then sets them to null before checking to see if they aren't null with camposNoVacios().

not updated, dattable PrimeFaces filter within a dialog

open the dialog with this button
<p:commandButton value="Abrir fiscales" update=":tabs:formDlgFiscales"
rendered="#{gestionNecBean.flgOperacion ne 3 and loginBean.getOpcionFormularioAcceso('botonAgregarFiscal')}"
disabled="#{loginBean.getValOpcForm('botonAgregarFiscal')}"
icon="ui-icon-plus"
process="#this"
actionListener="#{gestionNecBean.inicializarFiscales()}" />
my method inicializarFiscales(), open dialog.
public void inicializarFiscales() {
//setLstFiscalesView(null);//elimino el objeto anterior
setBtnBuscarFiscales(true);
NecFiscalesViewLn necFiscalesViewLn;
try {//lstFiscalesView
setObjNecFiscalesView(new NecFiscalesView());
setObjContactoPromocion(new ContactoPromocion());
getObjContactoPromocion().setContactoPromocionPK(new ContactoPromocionPK());
getObjContactoPromocion().getContactoPromocionPK().setTipContacto(Constantes.TIPO_CONTACTO_FISCAL);
// setLstFiscalesView(null);no es este ya lo habia probado
setObjContacto(new Contacto());
txtDni = true;
txtTelefonoFijo = true;
txtNombres = true;
txtTelefonoMovil = true;
txtApellidoPaterno = true;
txtCorreo = true;
txtApellidoMaterno = true;
rbActivo = true;
txtUnidad = true;
txtFecRetiro = true;
txtCargo = true;
txtFecAcredita = true;
txtMunicipalidad = true;
txtDireccion = true;
necFiscalesViewLn = new NecFiscalesViewLn();
// lstFiscalesView = necFiscalesViewLn.getViewNecFiscales(objNucleoCentral);
//y con estto lleno el datatable
// ok dejame verlo un toque
this.setLstFiscalesView(necFiscalesViewLn.getViewNecFiscales(objNucleoCentral));
RequestContext.getCurrentInstance().execute("dlgNecFiscales2.show()");
} catch (Exception e) {
} finally {
necFiscalesViewLn = null;
}
}
my dialog is:
<p:dialog id="dlgNecFiscales" widgetVar="dlgNecFiscales2" modal="true" appendToBody="true"
header="Datos del Fiscal a nivel distrital" closeOnEscape="true" resizable="false" width="800px">
<p:ajax event="close" listener="#{gestionNecBean.restablecerListaFiscales()}"
/>
<h:form id="formDlgFiscales" >
<p:messages id="messages" showDetail="false" autoUpdate="false" closable="true" showSummary="true" severity="error"/>
<p:outputPanel style="display: block;" id="pnlNucleoEjecutor">
<div align="right">
<p:commandButton value="Nuevo" type="button" icon="ui-icon-plus"
styleClass="ui-priority-primary">
<p:ajax event="click" listener="#{gestionNecBean.nuevoFiscal(1)}"
update=":tabs:formDlgFiscales"></p:ajax>
</p:commandButton>
<p:commandButton value="Limpiar" type="button" icon="ui-icon-refresh"
styleClass="ui-priority-primary">
<p:ajax event="click" listener="#{gestionNecBean.limpiarFiscal}"
update=":tabs:formDlgFiscales:txtDireccionF,txtDNIF,txtTelefonoFijoF,txtNombresF,txtTelefonoMovilF,txtApellidoPF,email,txtApellidoMF,soEstadoF,txtUnidadF,txtFecRetiro,txtCargoF,txtFechaAcreF,txtMuniF,txtDocAcreditaF,txtNumeroResolucF"></p:ajax>
</p:commandButton>
</div>
<p:dataTable id="listaFiscales" var="varFiscales"
value="#{gestionNecBean.lstFiscalesView}"
rowKey="#{varFiscales.id}"
rows="5" paginator="true"
rowsPerPageTemplate="5,10,20"
paginatorPosition="bottom"
sortMode="multiple"
currentPageReportTemplate="Total de Registros: {totalRecords}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} "
emptyMessage="#{myBundle.NoRecord}">
<p:column headerText="Acciones" width="10%" style="text-align: center;">
<div style="white-space: nowrap">
<p:commandLink id="editar">
<p:graphicImage alt="Editar" width="10" value="resources/imagenes/edicion.png" />Editar
<p:ajax event="click" listener="#{gestionNecBean.editarFiscales(varFiscales, 2)}"
update=":tabs:formDlgFiscales"></p:ajax>
</p:commandLink>
</div>
</p:column>
<p:column headerText="DNI" width="10%"
filterBy="#{varFiscales.txtDocumento}"
filterMatchMode="contains"
sortBy="txtDocumento">
<h:outputText value="#{varFiscales.txtDocumento}" />
</p:column>
<p:column headerText="Apellido Paterno" width="20%"
filterBy="#{varFiscales.txtApellidoPaterno}"
filterMatchMode="contains"
sortBy="txtDocumento">
<h:outputText value="#{varFiscales.txtApellidoPaterno}" />
</p:column>
<p:column headerText="Apellido Materno" width="20%"
filterBy="#{varFiscales.txtApellidoMaterno}"
filterMatchMode="contains"
sortBy="txtDocumento">
<h:outputText value="#{varFiscales.txtApellidoMaterno}" />
</p:column>
<p:column headerText="Nombres" width="20%"
filterBy="#{varFiscales.txtNombre}"
filterMatchMode="contains"
sortBy="txtDocumento">
<h:outputText value="#{varFiscales.txtNombre}" />
</p:column>
</p:dataTable>
.
.
.
when I look at the datatable me looking good. and when I close and open the dialog values ​​remain.
I want the normal values, normal carge display datatable.
not update the datatable when I open the dialog, the search gets stuck
which component is 'tabs' in your update p:ajax part ? I believe starting from :formname is enough so try using
update=":formDlgFiscales:listaFiscales" or simply update=":formDlgFiscales" should update every thing inside it

Getting duplicate rows with row edit event in primefaces

I am Using Prime faces 3.5.8,I am getting duplicate rows with row edit event.I am getting my row count as fine but one record is showing twice instead of other.This I am getting when call my clintList to load.When I close dialog and open it it is fine,Even I checked my list It is getting right data,Thanks in Advance..
My BeanCode for edit,
public void onClientEdit(RowEditEvent event) {
try {
Client edtClient = (Client) event.getObject();
if (null == edtClient.getClientName()
|| edtClient.getClientName() == "") {
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR,
CommonStringUtil.getUIString("clintNameEmpty"),
CommonStringUtil.getUIString("clintNameEmpty")));
getAgencyClients();
return;
}
HibernateUtil.beginTransaction();
Agency tempAgency = agencyHome.findById(agency.getAgencyId());
Hibernate.initialize(tempAgency.getClients());
HibernateUtil.commitTransaction();
for (Client cl : (Set<Client>) tempAgency.getClients()) {
if (cl.getClientName().equalsIgnoreCase(
edtClient.getClientName().trim())) {
log.debug("Client Name Already exists");
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_WARN,
CommonStringUtil
.getUIString("clientNameExists"),
CommonStringUtil
.getUIString("clientNameExists")));
getAgencyClients();
return;
}
}
HibernateUtil.beginTransaction();
Client eClient = clientHome.findById(edtClient.getClientId());
eClient.setClientName(edtClient.getClientName());
clientHome.attachDirty(eClient);
clientName = null;
agencyHome.attachDirty(agency);
HibernateUtil.commitTransaction();
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_INFO, CommonStringUtil
.getUIString("clientNameEditSucc"), CommonStringUtil
.getUIString("clientNameEditSucc")));
} catch (Exception e) {
if (HibernateUtil.isTransactionActive())
HibernateUtil.rollbackTransaction();
log.error("Error Updating Client Name", e);
FacesContext.getCurrentInstance().addMessage(
null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, CommonStringUtil
.getUIString("clientNameEditFail"), CommonStringUtil
.getUIString("clientNameEditFail")));
}
}
My View Part
<p:dialog widgetVar="clientDialogue" modal="true" id="clientdilogId"
showHeader="false" style="padding:0;">
<h:form id="clientDlgForm">
<p:toolbar style="height:38px;">
<p:toolbarGroup align="left">
<h:outputText
value="Edit Client Messages: #{adminAgencyBean.agencyName}"
styleClass="dialog-header-Text" style="line-height:38px"></h:outputText>
</p:toolbarGroup>
<p:toolbarGroup align="right" style="margin-left:50px;">
<p:inputText value="#{adminAgencyBean.clientName}" id="clientName"
maxlength="45" />
<p:spacer width="5"></p:spacer>
<p:commandButton action="#{adminAgencyBean.createClient}"
icon="ui-icon-custom-arrow" iconPos="right" value="Create"
style="margin-left:5px;margin-right:20px;" update="#form" />
<p:commandLink value="X" onclick="clientDialogue.hide()"
style="text-decoration:none;margin-right:10px;" process="#none"></p:commandLink>
</p:toolbarGroup>
</p:toolbar>
<p:messages id="clientMsgs" />
<p:scrollPanel style="width:980px;height:400px;width:100%;"
mode="native">
<p:dataTable value="#{adminAgencyBean.clientList}" var="client"
sortBy="#{client.clientName}" sortOrder="ascending" editable="true"
id="ClientTable">
<p:ajax event="rowEdit" listener="#{adminAgencyBean.onClientEdit}"
update=":clientDlgForm:clientMsgs"/>
<p:ajax event="rowEditCancel" />
<p:column headerText="Client Name" sortBy="#{client.clientName}"
style="white-space:pre-line;width:130px;">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.clientName}" />
</f:facet>
<f:facet name="input">
<p:inputText id="editClientName" value="#{client.clientName}"
maxlength="45" style="width:90px"></p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit Client"
style="white-space:pre-line;width:80px;">
<p:rowEditor
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] lt 1}" />
<h:outputText value="#{commonmessages.NoEdit}"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] ge 1}" />
</p:column>
<p:column headerText="Remove Client"
style="width:85px;white-space:pre-line">
<p:commandButton value="Remove"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] lt 1}"
action="#{adminAgencyBean.deleteClient}" update="#form"
process="#none" styleClass="blue_button">
<f:setPropertyActionListener target="#{adminAgencyBean.clientId}"
value="#{client.clientId}"></f:setPropertyActionListener>
</p:commandButton>
<h:outputText value="#{commonmessages.nodelete}"
rendered="#{adminAgencyBean.clientTransactionMap[client.clientId] ge 1}" />
</p:column>
</p:dataTable>
</p:scrollPanel>
</h:form>
</p:dialog>

Primefaces Autocomplete itemSelect event is not fired

In my JSF application, Primefaces autocomplete itemSelect event is not fired. I double checked and it is inside a form element. I can not figure out why it is not fired.
I have listed code below.
<p:panelGrid columns="1" >
<p:outputLabel value="Medicine/Device" ></p:outputLabel>
<p:autoComplete forceSelection="true" id="acStock" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.stock}" converter="stockCon" completeMethod="#{pharmacySaleController.completeAvailableStocks}" var="i" itemLabel="#{i.itemBatch.item.name}" itemValue="#{i}" >
<p:column headerText="Item">
<h:outputLabel value="#{i.itemBatch.item.name}" ></h:outputLabel>
</p:column>
<p:column headerText="Rate">
<h:outputLabel value="#{i.itemBatch.retailsaleRate}" >
<f:convertNumber pattern="#,##0.00" ></f:convertNumber>
</h:outputLabel>
</p:column>
<p:column headerText="Stocks">
<h:outputLabel value="#{i.stock}" >
<f:convertNumber pattern="#,###" ></f:convertNumber>
</h:outputLabel>
</p:column>
<p:column headerText="Expiary">
<h:outputLabel value="#{i.itemBatch.dateOfExpire}" >
<f:convertDateTime pattern="MMM yyyy" ></f:convertDateTime>
</h:outputLabel>
</p:column>
<p:ajax event="query" update="lstSelectItems" ></p:ajax>
<p:ajax event="itemSelect" listener="#{pharmacySaleController.handleSelect}" update="txtRate txtQty txtVal" ></p:ajax>
</p:autoComplete>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Quentity" ></p:outputLabel>
<p:inputText id="txtQty" value="#{pharmacySaleController.billItem.pharmaceuticalBillItem.qty}" >
</p:inputText>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Rate" ></p:outputLabel>
<p:inputText id="txtRate" value="#{pharmacySaleController.billItem.rate}" >
</p:inputText>
</p:panelGrid>
<p:panelGrid columns="1" >
<p:outputLabel value="Value" ></p:outputLabel>
<p:inputText id="txtVal" value="#{pharmacySaleController.billItem.netValue}" >
</p:inputText>
</p:panelGrid>
<p:commandButton value="Add" action="#{pharmacySaleController.addBillItem()}" ></p:commandButton>
</p:panelGrid>
Controller
public void handleSelect(SelectEvent event){
calculateRates();
}
public void calculateRates() {
System.out.println("calculating rates");
if (bill == null) {
System.out.println("bill is null");
return;
}
if (billItem == null) {
System.out.println("billItem is null");
return;
}
if (billItem.getPharmaceuticalBillItem() == null) {
System.out.println("pharmaceutical bill item is null");
return;
}
if (billItem.getPharmaceuticalBillItem().getStock() == null) {
System.out.println("billItem.getPharmaceuticalBillItem().getStock() = " + billItem.getPharmaceuticalBillItem().getStock());
return;
}
System.out.println("cal error check finished");
//
System.out.println("billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate() = " + billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
billItem.setRate(billItem.getPharmaceuticalBillItem().getStock().getItemBatch().getRetailsaleRate());
billItem.setDiscountRate(calculateBillItemDiscountRate(billItem));
billItem.setNetRate(billItem.getRate() - billItem.getDiscountRate());
billItem.setGrossValue(billItem.getRate() * billItem.getQty());
billItem.setDiscount(billItem.getDiscountRate() * billItem.getQty());
billItem.setNetValue(billItem.getNetRate() * billItem.getQty());
}

Command link is not working on a form with datatable multiple selection - JSF

I'm having problem with a commamd link that adds a row in a datatable and refreshes it. It was working fine, but when I added another table with multiple selection on the same form, It stopped work. Is there some incompatibility between them?
I'm using PrimeFaces 3.4, Mojarra 2.1.6 and Glassfish 3
Here is my form:
<h2>Projeto para Credenciamento Equipe de Saúde da Família</h2>
<hr />
<h:form id="formCredenciamentoEsf" prependId="false">
<p:fieldset legend="Caracterização Geral">
<p:panelGrid id="microareas" columns="2" cellspacing="8">
<p:dataTable
value="#{credenciamentoEsfMB.credenciamentoESF.projeto.caracterizacaoTerritorialDemograficaList}"
var="carac" emptyMessage="Adicione uma microárea.">
<p:column
headerText="Microáreas que compõem a área de abrangência da ESF">
<p:inputText value="#{carac.microarea}" size="50" />
</p:column>
<p:column
headerText="População Estimada por Microárea (nº de pessoas)">
<p:inputText value="#{carac.populacaoEstimadaMicroarea}"
size="50" />
</p:column>
<p:column>
<p:commandLink
actionListener="#{credenciamentoEsfMB.removerCaracteristica}"
update=":formCredenciamentoEsf:microareas">
<f:setPropertyActionListener value="#{carac}"
target="#{credenciamentoEsfMB.caracteristicaSelecionada}" />
<h:outputText value="Remover " />
</p:commandLink>
</p:column>
</p:dataTable>
</p:panelGrid>
<h:panelGrid columns="2">
<p:commandLink actionListener="#{credenciamentoEsfMB.addCaracteristicaTerritorialDemografica}"
update=":formCredenciamentoEsf:microareas">
<h:outputText value="Adicionar Microárea" />
</p:commandLink>
<h:outputLabel/>
<h:outputLabel
value="População total coberta pela ESF (nº de pessoas):"></h:outputLabel>
<p:inputText id="populacaoCoberta"
value="#{credenciamentoEsfMB.credenciamentoESF.populacaoTotalCoberta}" />
<h:outputLabel
value="Caracterização da população a ser coberta pelas ações da ESF:" />
<p:dataTable
value="#{credenciamentoEsfMB.populacaoCobertaDataModel}" var="pop"
id="dtCaracteristicaPopulacaoCoberta"
selection="#{credenciamentoEsfMB.populacaoCobertaSelecionadas}" >
<p:column selectionMode="multiple" />
<p:column headerText="População a ser atendida">
<h:outputLabel
value="#{pop.caracteristicaPopulacaoCoberta.descricao}" />
</p:column>
<p:column headerText="Nº de pessoas">
<p:inputText value="#{pop.numPessoas}" />
</p:column>
</p:dataTable>
</h:panelGrid>
</p:fieldset>
</h:form>
</ui:define>
The link "Adicionar Microárea" didn't work when I put the last datatable with multiple selection.
Here is my Managed bean:
#ManagedBean
#ViewScoped
public class CredenciamentoEsfMB {
....
public PopulacaoCobertaDataModel getPopulacaoCobertaDataModel() {
List<CaracteristicaPopulacaoCoberta> caracteristicas = caracteristicaPopulacaoCobertaEjb.buscarTodos();
populacaoCobertaEsf = new ArrayList<PopulacaoCobertaESFESB>();
for (CaracteristicaPopulacaoCoberta caracteristicaPopulacaoCoberta : caracteristicas) {
PopulacaoCobertaESFESB p = new PopulacaoCobertaESFESB();
p.setCaracteristicaPopulacaoCoberta(caracteristicaPopulacaoCoberta);
p.setCredenciamentoESFESB(credenciamentoESF);
populacaoCobertaEsf.add(p);
}
this.populacaoCobertaDataModel = new PopulacaoCobertaDataModel(this.populacaoCobertaEsf);
return this.populacaoCobertaDataModel;
}
public void removerCaracteristica() {
credenciamentoESF.getProjeto()
.getCaracterizacaoTerritorialDemograficaList().remove(caracteristicaSelecionada);
}
public void addCaracteristicaTerritorialDemografica(ActionEvent e) {
System.out.println("Adicionando microarea");
credenciamentoESF.getProjeto()
.getCaracterizacaoTerritorialDemograficaList()
.add(new CaracterizacaoTerritorialDemografica());
}
}
Does anyone know what is going on?

Resources