How to reRender specific row in richfaces 4 - jsf-2

I am trying to reRender a specific row of a subtable within a datatable. I am using richfaces 4.2 final and jsf 2 running on JBoss AS 7.1 CR1b. From what I could find there are 2 ways to reRender a row, either use #rows() or table:row, but I couldn't get either working. I'm not sure if its even possible to do it with a subTable, or how to do it.
The id's of the cells in the generated source look like this: id="tableForm:timesheetTable:0:subTable:0:j_idt55"
Here is my table code:
<h:form id="tableForm" >
<rich:dataTable var="day" value="#{timesheetHome.days}" id="timesheetTable" rowKeyVar="rowKey">
<f:facet name="header">
<rich:columnGroup>
<rich:column>
<h:outputText value="Ticket Nbr" />
</rich:column>
<rich:column>
<h:outputText value="Assigned By" />
</rich:column>
<rich:column style="width:60px;">
<h:outputText value="Status" />
</rich:column>
<rich:column>
<h:outputText value="Hours"/>
</rich:column>
<rich:column>
<h:outputText value="Description" />
</rich:column>
<rich:column>
<h:outputText value="Details"/>
</rich:column>
<rich:column>
<h:outputText value="Non-Billable"/>
</rich:column>
<rich:column>
</rich:column>
<rich:column>
</rich:column>
<rich:column>
</rich:column>
</rich:columnGroup>
</f:facet>
<rich:column colspan="10" style="background-color:#eee;">
<h:outputText value="#{day.name}"/>
</rich:column>
<rich:collapsibleSubTable var="item" value="#{day.items}" rowKeyVar="rowNum" id="subTable">
<rich:column>
<h:outputText value="#{item.ticketNumber}" />
</rich:column>
<rich:column>
<h:outputText value="#{item.reportTo}" />
</rich:column>
<rich:column>
<h:outputText value="#{item.status}"/>
</rich:column>
<rich:column>
<h:outputText value="#{item.hours}" />
</rich:column>
<rich:column>
<h:outputText value="#{item.task}" />
</rich:column>
<rich:column>
<h:outputText value="#{item.notes}" />
</rich:column>
<rich:column>
<h:selectBooleanCheckbox value="#{item.nonBillable}" disabled="true"/>
</rich:column>
<rich:column>
<a:outputPanel>
<h:graphicImage value="/resources/img/check.png" onclick="completed(#{item.id});"/>
<rich:tooltip showDelay="500" value="Change Status" layout="block" followMouse="false" />
</a:outputPanel>
</rich:column>
<rich:column>
<a:outputPanel>
<h:graphicImage value="/resources/img/edit.png" onclick="edit(#{item.id},#{rowKey},#{rowNum});"/>
<rich:tooltip showDelay="500" value="Edit" layout="block" followMouse="false" />
</a:outputPanel>
</rich:column>
<rich:column>
<a:outputPanel>
<h:graphicImage value="/resources/img/delete.png" onclick="remove(#{item.id});"/>
<rich:tooltip showDelay="500" value="Delete" layout="block" followMouse="false" />
</a:outputPanel>
</rich:column>
</rich:collapsibleSubTable>
<f:facet name="footer">
<rich:columnGroup>
<rich:column colspan="5">
<h:outputText value="Total hours: "/>
<h:outputText value="#{timesheetHome.weekHours}"/>
</rich:column>
<rich:column colspan="5">
<h:outputText value="Billable hours: "/>
<h:outputText value="#{timesheetHome.weekBillableHours}"/>
</rich:column>
</rich:columnGroup>
</f:facet>
</rich:dataTable>
</h:form>
and the button that is supposed to reRender the row:
<a:commandButton id="update"
value="Update"
action="#{timesheetHome.update}" rendered="#{timesheetHome.managed}" render="timesheetTable:#{timesheetHome.rowKey}:subTable:#{timesheetHome.rowNum} notify" oncomplete="if (!#{timesheetHome.error}){#{rich:component('popup')}.hide();}"/>
when the rowKey and rowNum are primitive type int, then nothing happens on the rerender. If i change them to type Integer in the backing bean, I get the following error:
WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--0.0.0.0-8080-5) String index out of range: 0: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:695) [:1.7.0_02]
at org.richfaces.context.IdParser.parse(IdParser.java:120) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ComponentIdResolver.addIdImmediately(ComponentIdResolver.java:196) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ComponentIdResolver.addId(ComponentIdResolver.java:231) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.renderkit.util.CoreRendererUtils.findComponentsFor(CoreRendererUtils.java:137) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.RenderComponentCallback.doVisit(RenderComponentCallback.java:86) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ExecuteComponentCallback.doVisit(ExecuteComponentCallback.java:47) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ComponentCallback.visit(ComponentCallback.java:94) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.BaseExtendedVisitContext.invokeVisitCallback(BaseExtendedVisitContext.java:321) [richfaces-core-impl-4.2.0.Final.jar:]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at javax.faces.component.UIForm.visitTree(UIForm.java:344) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorComponent(ExtendedPartialViewContextImpl.java:440) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ExtendedPartialViewContextImpl.visitActivatorAtExecute(ExtendedPartialViewContextImpl.java:310) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ExtendedPartialViewContextImpl.getExecuteIds(ExtendedPartialViewContextImpl.java:98) [richfaces-core-impl-4.2.0.Final.jar:]
at org.richfaces.context.ExtendedPartialViewContextImpl.isExecuteAll(ExtendedPartialViewContextImpl.java:148) [richfaces-core-impl-4.2.0.Final.jar:]
at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:929) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83) [jboss-seam.jar:]
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:]
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:]
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:]
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:]
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69) [jboss-seam.jar:]
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158) [jboss-seam.jar:]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:397) [jbossweb-7.0.7.Final.jar:]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.CR1b.jar:7.1.0.CR1b]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1b.jar:7.1.0.CR1b]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.7.Final.jar:]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.7.Final.jar:]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.7.Final.jar:]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.7.Final.jar:]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.7.Final.jar:]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_02]

Related

primefaces datatable row select not working after filtering or sorting

I have a problem with primefaces datatable which implements filtering and sorting and select rows (like complex datatable in primefaces showcases), when I sort or filter in datatable, SelectedElement resolve to null if I select a row, but if I choose a row without filtering or sorting, select event work perfectly.
My xhtml.
<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:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Liste des Prospects</title>
<style type="text/css">
</style>
</h:head>
<h:body>
<p:layout style="min-width:900px;min-height:400px;" id="layout" fullPage="true">
<p:layoutUnit size="50" position="north" ><ui:include src="/Menus.xhtml" /></p:layoutUnit>
<h:form id="form">
<p:layoutUnit position="center" size="230" resizable="false" closable="true" collapsible="true">
<p:layout>
<p:layoutUnit position="center">
<p:dataTable id="cars" scrollable="true" frozenColumns="4"
selection="#{prospectBean.selectedProspect}" selectionMode="single" stickyHeader="false" var="listd"
sortMode="single" widgetVar="ProspectTable" value="#{prospectBean.list}" rowKey="#{listd.idProspect}"
emptyMessage="Pas de prospects avec ces critères" rowSelectMode="single" filteredValue="#{prospectBean.filteredProspects}">
<p:ajax event="rowSelect" listener="#{prospectBean.onRowSelect}" update=":form:Agenda" />
<p:ajax event="rowUnselect" listener="#{prospectBean.onRowUnSelect()}"/>
<p:ajax event="filter" update=":form:cars" />
<f:facet name="header" >
<p:outputPanel >
<h:outputText style="width:150px;" value="Chercher dans tous les camps:" />
<p:inputText id="globalFilter" onkeyup="PF('ProspectTable').filter()" style="width:150px;" placeholder="Enter keyword"/>
<p:commandButton action="#{prospectBean.AjouterProspect()}" style="width:12%;float: left;height:8%" ajax="false" icon="ui-icon-circle-plus" />
</p:outputPanel>
</f:facet>
<p:column width="14" >
<p:commandButton action="#{prospectBean.ModifierProspect(listd)}" style="width:15px;height:15px" ajax="false" icon="ui-icon-pencil"/>
</p:column>
<p:column width="140" sortBy="#{listd.raisonsociale}" headerText="Raison Sociale" filterBy="#{listd.raisonsociale}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.raisonsociale}"/>
</p:column>
<p:column width="140" sortBy="#{listd.raisonsocialeabrg}" headerText="RS Abrégé" filterBy="#{listd.raisonsocialeabrg}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.raisonsocialeabrg}"/>
</p:column>
<p:column width="140" sortBy="#{listd.telephone}" headerText="Téléphone" filterBy="#{listd.telephone}" filterStyle="display:none">
<h:outputText value="#{listd.telephone}"/>
</p:column>
<p:column width="140" sortBy="#{listd.telephone2}" headerText="Téléphone 2" filterBy="#{listd.telephone2}" filterStyle="display:none">
<h:outputText value="#{listd.telephone2}"/>
</p:column>
<p:column width="140" sortBy="#{listd.fax}" headerText="Fax" filterBy="#{listd.fax}" filterStyle="display:none">
<h:outputText value="#{listd.fax}"/>
</p:column>
<p:column width="190" sortBy="#{listd.siteWeb}" headerText="Site Web" filterBy="#{listd.siteWeb}" filterStyle="display:none">
<h:outputText value="#{listd.siteWeb}"/>
</p:column>
<p:column width="190" sortBy="#{listd.email}" headerText="Email" filterBy="#{listd.email}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.email}"/>
</p:column>
<p:column width="140" sortBy="#{listd.ville}" headerText="Ville" filterBy="#{listd.ville}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.ville}"/>
</p:column>
<p:column width="140" sortBy="#{listd.pays}" headerText="Pays" filterBy="#{listd.pays}" filterMatchMode="contains" filterStyle="display:none" >
<h:outputText value="#{listd.pays}"/>
</p:column>
<p:column width="140" sortBy="#{listd.chiffreaffaire}" headerText="Chiffre d'affaire" filterBy="#{listd.chiffreaffaire}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.chiffreaffaire}"/>
</p:column>
<p:column width="140" sortBy="#{listd.activite}" headerText="Activite" filterBy="#{listd.activite}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.activite}"/>
</p:column>
<p:column width="140" sortBy="#{listd.secteur}" headerText="Secteur" filterBy="#{listd.secteur}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.secteur}"/>
</p:column>
<p:column width="140" sortBy="#{listd.statut.denomination}" headerText="Statut" filterBy="#{listd.statut.denomination}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText value="#{listd.statut.denomination}"/>
</p:column>
</p:dataTable>
</p:layoutUnit>
<p:layoutUnit position="south" size="322" resizable="false" closable="true" collapsible="true">
<p:dataTable id="Agenda" scrollable="false" filteredValue="#{AgendaBean.filteredAgenda}"
selectionMode="single" var="lista" sortMode="single"
widgetVar="AgendaTable" value="#{AgendaBean.list}" rowKey="#{lista.id}"
emptyMessage="Pas d'événement avec ces critères" >
<f:facet name="header" >
<p:outputPanel >
<h:outputText style="width:150px;" value="Chercher dans tous les camps:" />
<p:inputText id="globalFilter" onkeyup="PF('AgendaTable').filter()" style="width:150px;" placeholder="Enter keyword"/>
<p:commandButton action="#{AgendaBean.AjouterAgenda()}" rendered="#{prospectBean.checked}" style="width:12%;height:6%;float: left;" ajax="false" icon="ui-icon-circle-plus" />
</p:outputPanel>
</f:facet>
<p:column width="17" >
<p:commandButton action="#{AgendaBean.ModifierAgenda(lista)}" style="width:15px; height:17px" ajax="false" icon="ui-icon-pencil"/>
</p:column>
<p:column sortBy="#{lista.dateHeure}" width="170" headerText="Date Heure" filterBy="#{lista.dateHeure}" filterMatchMode="contains" filterStyle="display:none" >
<h:outputText id="id01" value="#{lista.dateHeure}"/>
</p:column>
<p:column sortBy="#{lista.natureevenement.libelle}" headerText="Nature" filterBy="#{lista.natureevenement.libelle}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText id="id11" value="#{lista.natureevenement.libelle}"/>
</p:column>
<p:column sortBy="#{lista.intervenant.nom}" headerText="Intervenant" filterBy="#{lista.intervenant.nom}" filterMatchMode="contains" filterStyle="display:none" >
<h:outputText id="id21" value="#{lista.intervenant.nom}"/>
</p:column>
<p:column sortBy="#{lista.statut.denomination}" headerText="Statut" filterBy="#{lista.statut.denomination}" filterMatchMode="contains" filterStyle="display:none" >
<h:outputText id="id31" value="#{lista.statut.denomination}"/>
</p:column>
<p:column sortBy="#{lista.duree}" width="70" headerText="Duree" filterBy="#{lista.duree}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText id="id41" value="#{lista.duree}"/>
</p:column>
<p:column sortBy="#{lista.lieu}" width="170" headerText="Lieu" filterBy="# {lista.lieu}" filterMatchMode="contains" filterStyle="display:none">
<h:outputText id="id61" value="#{lista.lieu}"/>
</p:column>
</p:dataTable>
</p:layoutUnit>
</p:layout>
</p:layoutUnit>
</h:form>
</p:layout>
</h:body>
</html>
MyBean
#ManagedBean(name="prospectBean")
#SessionScoped
public class ProspectBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
....
public void onRowSelect(SelectEvent se)
{
setProspect(getSelectedProspect());
agendabean.setProspect(getSelectedProspect());
checked=true;
try{
AgendaBean.AfficherAgendas(getProspect());
}catch(Exception e){e.printStackTrace();}
System.out.print("ca marche encore");
}
public void onRowUnSelect(SelectEvent se)
{
checked=false;
}
//agendabean.setProspect(getSelectedProspect()); resolve to null pointer exception
java.lang.NullPointerException
at Interface.AgendaBean.AfficherAgendas(AgendaBean.java:508)
at Interface.ProspectBean.onRowSelect(ProspectBean.java:775)

<p:datatable> partial process does not reflect changes immediately

I have a code like:
<p:dataTable style="padding-top: 5px" var="leaveDetails" value="#{userLeaveBean.leaveDetails}" id="leaveDataTable" editable="true">
<p:column headerText="Leave Starts on" width="230">
<p:calendar valueChangeListener="#{userLeaveBean.handleFromDateChanege}" value="#{leaveDetails.dtLeaveFromDate}" pattern="dd-MMM-yyyy" size="16" showOn="button" id="editFrom">
<p:ajax event="dateSelect"/>
</p:calendar>
<h:selectOneRadio value="#{leaveDetails.strStartTiming}" valueChangeListener="#{userLeaveBean.handleRadioFirstValueChange}">
<f:selectItem itemValue="morning" itemLabel="Morning"/>
<f:selectItem itemValue="afternoon" itemLabel="Afternoon" />
<p:ajax event="click"/>
</h:selectOneRadio>
</p:column>
<p:column headerText="Leave Ends on" width="230">
<p:calendar valueChangeListener="#{userLeaveBean.handleToDateChanege}" value="#{leaveDetails.dtLeaveToDate}" pattern="dd-MMM-yyyy" size="16" showOn="button" id="editTo">
<p:ajax event="dateSelect"/>
</p:calendar>
<h:selectOneRadio value="#{leaveDetails.strEndTiming}" valueChangeListener="#{userLeaveBean.handleRadioSecondValueChange}">
<f:selectItem itemValue="noon" itemLabel="Noon"/>
<f:selectItem itemValue="endofday" itemLabel="End Of Day"/>
<p:ajax event="click"/>
</h:selectOneRadio>
</p:column>
<p:column headerText="Days" width="40" id="total">
<h:outputText value="#{leaveDetails.totalLeaveDays}"/>
</p:column>
<p:column headerText="Creation" width="100">
<h:outputText value="#{leaveDetails.dtApplicationDate}">
<f:convertDateTime pattern="EEEE,dd-MMM-yyyy"/>
</h:outputText>
</p:column>
<p:column headerText="Status" width="100">
<h:outputText value="#{leaveDetails.strLeaveStatus}"/>
</p:column>
<p:column headerText="Edit" width="40" rendered="#{leaveDetails.strLeaveStatus == 'Canceled' or leaveDetails.strLeaveStatus == 'Availed'}">
<p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" disabled="true" update="leaveDataTable" immediate="true" partialSubmit="true">
<h:graphicImage url="resources/images/edit.JPG"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
<f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
<f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
<f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Edit" width="40" rendered="#{leaveDetails.strLeaveStatus != 'Canceled'}">
<p:commandLink actionListener="#{userLeaveBean.editAppliedLeave}" title="Edit" disabled="false" update="leaveDataTable" immediate="true" process="#this" >
<h:graphicImage url="resources/images/edit.JPG"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="editFirstHalf" value="#{leaveDetails.strStartTiming}"/>
<f:attribute name="editSecondHalf" value="#{leaveDetails.strEndTiming}"/>
<f:attribute name="editFrom" value="#{leaveDetails.dtLeaveFromDate}"/>
<f:attribute name="editTo" value="#{leaveDetails.dtLeaveToDate}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Cancel" width="60" rendered="#{leaveDetails.strLeaveStatus == 'Canceled' or leaveDetails.strLeaveStatus == 'Availed'}">
<p:commandLink actionListener="#{userLeaveBean.cancelForLeave}" title="Cancel Request" disabled="true" process="#this" update="leaveDataTable" immediate="false">
<h:graphicImage url="resources/images/cancel.gif"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
<p:column headerText="Cancel" width="60" rendered="#{leaveDetails.strLeaveStatus != 'Canceled'}">
<p:commandLink actionListener="#{userLeaveBean.cancelForLeave}" title="Cancel Request" disabled="false" process="#this" update="leaveDataTable" immediate="false" ajax="true">
<h:graphicImage url="resources/images/cancel.gif"/>
<f:attribute name="userId" value="#{employee.name}"/>
<f:attribute name="leaveId" value="#{leaveDetails.strLeaveId}"/>
</p:commandLink>
</p:column>
</p:dataTable>
This part of code is written in a <p:datatable>.That means Row operation of a <p:datatable>.On clicking the <p:commandLink> some execution is happened, and I want it to reflect on the <p:datatable> immediatley. But it does not happen.
If I refresh the page, then the changes reflects for the row of the <p:datatable>. How can I modify my code to reflect the changes immediately.
Working on JSF2.0, primefaces 3.4.2, Jboss As7.1.1final and JDK6.0.
Bean is in #ViewScoped.
Please suggest.
Thanks in advance.

Exposing composite component attribute to children

I have the necessity to load some data in a dataTable using lazy loading. Unfortunatelly, primefaces dataTable only suports lazy loading with pagination, but this is unacceptable to this project, so I created and tested some mechanisms to permit lazy loading in datatable using scroll (primefaces's liveScroll isn't lazy loading). Now I need to move these mechanisms to a composite component, so I decided to wrap primefaces dataTable:
<ui:component xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsf/composite"
xmlns:p="http://primefaces.prime.com.tr/ui">
<c:interface>
<c:attribute name="var" required="true" targets="tabela"/>
<c:attribute name="value" required="true" targets="tabela" type="java.util.List"/>
<c:attribute name="scrollable" targets="tabela"/>
<c:attribute name="liveScroll" required="false" default="false"/>
<c:attribute name="height" targets="tabela"/>
<c:attribute name="emptyMessage" targets="tabela" default="Nenhuma dado a ser exibido"/>
<c:attribute name="rows" targets="tabela"/>
<c:attribute name="action" method-signature="void method()" required="false"/>
</c:interface>
<c:implementation>
<div id="#{cc.clientId}">
<p:dataTable id="tabela" var="#{cc.attrs.var}" value="#{cc.attrs.value}"
scrollable="#{scrollable}" height="#{cc.attrs.height}"
emptyMessage="#{cc.attrs.emptyMessage}" rows="10">
<c:insertChildren/>
</p:dataTable>
<p:remoteCommand name="comandoAtualizarTabela" action="#{cc.attrs.action}" update="tabela" process="#none"/>
<script type="text/javascript">
if ("#{cc.attrs.liveScroll}") {
var idEscapadoPainelLista = PrimeFaces.escapeClientId("#{cc.clientId}");
jQuery(idEscapadoPainelLista).find(".ui-datatable-scrollable-body").scroll(function () {
if ((this.scrollTop == this.scrollHeight - this.clientHeight))
comandoAtualizarTabela();
});
}
</script>
</div>
</c:implementation>
</ui:component>
When I try to use this component, no data is showed in the rows cause of this exception:
[#|2012-07-12T09:34:10.010-0300|SEVERE|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=21;_ThreadName=Thread-10;|org.apache.myfaces.view.facelets.el.ContextAwarePropertyNotFoundException: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:79)
at org.primefaces.component.inputtext.InputTextRenderer.getConvertedValue(InputTextRenderer.java:113)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:647)
at javax.faces.component.UIInput.validate(UIInput.java:583)
at javax.faces.component.UIInput.processValidators(UIInput.java:273)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1317)
at javax.faces.component.UIData.process(UIData.java:1919)
at javax.faces.component.UIData.processColumnChildren(UIData.java:1904)
at javax.faces.component.UIData.processValidators(UIData.java:1761)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1317)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1317)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIForm.processValidators(UIForm.java:209)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1324)
at javax.faces.component.UIViewRoot._processValidatorsDefault(UIViewRoot.java:1350)
at javax.faces.component.UIViewRoot.access$500(UIViewRoot.java:74)
at javax.faces.component.UIViewRoot$ProcessValidatorPhaseProcessor.process(UIViewRoot.java:1443)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1306)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:793)
at org.apache.myfaces.lifecycle.ProcessValidationsExecutor.execute(ProcessValidationsExecutor.java:38)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at fr.xebia.servlet.filter.ExpiresFilter.doFilter(ExpiresFilter.java:1243)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:369)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:177)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.access.channel.ChannelProcessingFilter.doFilter(ChannelProcessingFilter.java:109)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.gr|#]
[#|2012-07-12T09:34:10.011-0300|SEVERE|glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=21;_ThreadName=Thread-10;|izzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:662)
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'bean' resolved to null
at com.sun.el.parser.AstValue.getTarget(AstValue.java:131)
at com.sun.el.parser.AstValue.getType(AstValue.java:76)
at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:195)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getType(ContextAwareTagValueExpression.java:75)
... 90 more|#]
ADDED
The application uses spring version 3.0.7. Once the application have more than 20 spring xml files, I'm showing just part of one spring file... This part configures the dialog I'm testing with the composite component:
<bean id="controladorPopupCadastroUnidade" class="com.hrgi.web.cadastro.controladores.popups.ControladorPopupCadastroUnidade" scope="request">
<property name="controladorArmazenamento" ref="controladorArmazenamentoUnidade"/>
<property name="conversorValor" ref="conversorUnidade"/>
<property name="modelo" ref="modeloPopupCadastroUnidade"/>
<property name="popupAlerta" ref="controladorPopupAlerta"/>
<property name="recuperadorValores" ref="unidadeDao"/>
<property name="popupConfirmacao" ref="controladorPopupConfirmacao"/>
</bean>
<bean id="modeloPopupCadastroUnidade" class="com.hrgi.web.ui.modelos.ModeloPopupCRUD" scope="session">
<property name="visivel" value="false"/>
<property name="mensagemSucesso" value="${gerais.lista.sucesso}" />
</bean>
<bean id="controladorArmazenamentoUnidade" class="com.hrgi.persistencia.controladores.ControladorArmazenamento" scope="request">
<property name="armazenador" ref="unidadeDao"/>
<property name="atualizador" ref="unidadeDao"/>
<property name="removedor" ref="unidadeDao"/>
<property name="conversor" ref="conversorUnidade"/>
</bean>
to help you see the problem, here is the dataTable part of xhtml file I'm trying use teh cc:
<h:panelGroup id="painelLista" layout="block" styleClass="clearfix">
<hrgi:dataTable var="bean" value="#{modeloPopupCadastroUnidade.lista}"
scrollable="true" height="145"
action="#{controladorPopupCadastroUnidade.atualizarValores}"
liveScroll="true" rows="10">
<p:column headerText="Nome" style="width: 23%">
<hrgi:cellEditor>
<f:facet name="saida">
<h:outputText value="#{bean.descricao}"/>
</f:facet>
<f:facet name="entrada">
<p:inputText value="#{bean.descricao}" maxlength="35" style="width: 90%"/>
</f:facet>
</hrgi:cellEditor>
</p:column>
<p:column headerText="Sigla">
<hrgi:cellEditor>
<f:facet name="saida">
<h:outputText value="#{bean.sigla}"/>
</f:facet>
<f:facet name="entrada">
<p:inputText value="#{bean.sigla}" maxlength="5"/>
</f:facet>
</hrgi:cellEditor>
</p:column>
<p:column headerText="Fator" sortBy="#{bean.fator}">
<hrgi:cellEditor>
<f:facet name="saida">
<h:outputText value="#{bean.fator}"/>
</f:facet>
<f:facet name="entrada">
<hrgi:spinner value="#{bean.fator}" dinheiro="false" fator="1" local="pt-BR" width="40"/>
</f:facet>
</hrgi:cellEditor>
</p:column>
<p:column headerText="Fracionado" sortBy="#{bean.fracionado}">
<hrgi:cellEditor>
<f:facet name="saida">
<h:outputText value="#{bean.fracionado eq true?'Sim':'Não'}"/>
</f:facet>
<f:facet name="entrada">
<h:selectBooleanCheckbox value="#{bean.fracionado}"/>
</f:facet>
</hrgi:cellEditor>
</p:column>
<p:column headerText="Unitário" sortBy="#{bean.unitario}">
<hrgi:cellEditor>
<f:facet name="saida">
<h:outputText value="#{bean.unitario eq true?'Sim':'Não'}"/>
</f:facet>
<f:facet name="entrada">
<h:selectBooleanCheckbox value="#{bean.unitario}"/>
</f:facet>
</hrgi:cellEditor>
</p:column>
<p:column>
<hrgi:rowEditor action="#{controladorPopupCadastroUnidade.editarValor(bean)}" update="alerta" indice="#{bean.indice}"/>
<p:commandLink title="#{msgGerais['gerais.excluir']}" action="#{controladorPopupCadastroUnidade.removerValor(bean)}" update="painelLista alerta confirmacao" immediate="true">
<h:graphicImage library="img" name="remover.png"/>
</p:commandLink>
</p:column>
</hrgi:dataTable>
</h:panelGroup>
Probably the problem is that var property can't be used outside composite component... Is there a way I can expose this attribute externally? How can I solve it?

primefaces commandbutton actionlistener not called

I am using primefaces 3.0 and jsf 2.0.
I have prepared client master which add client using wizard and at the same time reflected in datatable. Then I have updated edit utility in datatable. Then I have added delete button in datatable and try call delete method of bean.
But when I click on delete button wizard validation for adding client is executed.
So I have created another file ClientEditdatatable.xhtml and included in clientmaster.xhtmlbut same result remain.
Now I want to add delete utility in datatable. I have tried many tricks to do it.
I just want to pass client id through action listener,get deleted and refresh datatable but command button not executing method.
Kindly advice.
My code as below:
ClientMaster.xhtml
<h:body>
<ui:composition template="/template/mainLayout.xhtml" >
<ui:define name="pageContent">
<h:form id="cm">
<p:growl life="5000" showDetail="true" showSummary="true" id="mymessage" autoUpdate="true"/>
<br/>
user id :#{sessionScope.USER_ID};
<br/>
<p:wizard widgetVar="wiz" flowListener="#{clientUitility.onFlowProcess}" showNavBar="true" >
<p:tab id="personal" title="Personal" >
<p:panel id="personal1" header="Personal Details">
<!-- <h:messages errorClass="error"/> -->
<h:panelGrid columns="6" styleClass="grid">
<h:outputText value="First Name:*" />
<p:inputText required="true" label="FirstName"
value="#{clientUitility.client.firstName}" >
</p:inputText>
<h:outputText value="Middle Name:*" />
<p:inputText required="true" label="MidddleName"
value="#{clientUitility.client.middleName}" />
<h:outputText value="Last Name:*" />
<p:inputText required="true" label="LastName"
value="#{clientUitility.client.lastName}" />
<h:outputText value="Login ID:* " />
<p:inputText required="true" label="LoginID"
value="#{clientUitility.client.loginID}"/>
<h:outputText value="Password:* " />
<p:inputText required="true" label="Password"
value="#{clientUitility.client.password}"/>
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="address" title="Address" >
<p:panel id="address1" header="Adress Details">
<!-- <h:messages errorClass="error"/> -->
<h:panelGrid columns="6" styleClass="grid">
<h:outputText value="Address:*" />
<p:inputText required="true" label="Address1"
value="#{clientUitility.client.address1}" />
<h:outputText />
<p:inputText label="Address2"
value="#{clientUitility.client.address2}" />
<h:outputText />
<p:inputText label="Address3"
value="#{clientUitility.client.address3}" />
<h:outputText value="City:* " />
<p:inputText required="true" label="City"
value="#{clientUitility.client.city}" />
<h:outputText value="Pincode:* " />
<p:inputText required="true" label="Pincode"
value="#{clientUitility.client.pincode}" />
<h:outputText value="State:* " />
<p:inputText required="true" label="State"
value="#{clientUitility.client.state}" />
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="contact" title="Contact" >
<p:panel id="contact1" header="Contact Information">
<!-- <h:messages errorClass="error"/> -->
<p:panelGrid columns="4" styleClass="grid">
<h:outputText value="Mobile:* " />
<p:inputText required="true" label="MobileNo"
value="#{clientUitility.client.mobileNo}" />
<h:outputText value="Email ID: "/>
<p:inputText label="EmailID"
value="#{clientUitility.client.emailID}" />
<h:outputText value="STD Code: "/>
<p:inputText label="STDCode"
value="#{clientUitility.client.stdCode}" />
<h:outputText value="Phone No: "/>
<p:inputText label="PhoneNo"
value="#{clientUitility.client.phoneNo}" /> </p:panelGrid>
</p:panel>
</p:tab>
<p:tab id="confirm" title="Confirmation" >
<p:panel id="confirm1" header="Confirm and Submit">
<h:panelGrid columns="6" styleClass="grid" >
<h:outputText value="First Name: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.firstName}" />
<h:outputText value="Middle Name: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.middleName}" />
<h:outputText value="Last Name: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.lastName}" />
<h:outputText value="Login ID: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.loginID}"/>
<h:outputText value="Password: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.password}"/>
<h:outputText/>
<h:outputText/>
<h:outputText value="Address: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.address1}" />
<h:outputText />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.address2}" />
<h:outputText />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.address3}" />
<h:outputText value="City: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.city}" />
<h:outputText value="State: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.state}" />
<h:outputText value="Pincode: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.pincode}" />
<h:outputText value="Email ID: " />
<h:outputText styleClass="outputLabel"
value="#{clientUitility.client.emailID}" />
<p:commandButton id="addClient" immediate="true" value="Add Client" actionListener="#{clientUitility.save}" oncomplete="wiz.loadStep (wiz.cfg.steps [0], true)" update="#parent,:cm:clientList"> <!-- update="#parent,:cm:clientList" -->
</p:commandButton>
</h:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
<ui:include id="ce" src="ClientEditDatatable.xhtml"/>
</h:form>
</ui:define>
</ui:composition>
</h:body>
ClientEditDatatable.xhtml
<h:body>
<h:form id="fce">
<p:confirmDialog message="Delete client?" severity="alert" widgetVar="confirmDeleteClient" visible="false" appendToBody="true">
<p:commandButton value="Yes" update=":cm:fce:clientList" oncomplete="confirmDeleteClient.hide()" actionListener="#{clientUitility.deleteRecord}" >
</p:commandButton>
<p:commandButton value="No" onclick="confirmDeleteClient.hide()" type="button" />
</p:confirmDialog>
<p:dataTable var="client" value="#{clientUitility.clientAll}" id="clientList" editable="true"
rowKey="#{client.clientID}" paginator="true" rows="10" rowsPerPageTemplate="10,15,20">
<p:column headerText="First Name" style="width:125px" filterBy="#{user.firstname}" sortBy="#{client.firstName}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.firstName}" />
</f:facet>
<f:facet name="input">
<h:outputText value="#{client.firstName}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Middle Name" style="width:125px" filterBy="#{client.middleName}" sortBy="#{client.middleName}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.middleName}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.middleName}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Last Name" style="width:125px" filterBy="#{client.lastName}" sortBy="#{client.lastName}" >
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.lastName}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.lastName}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Login ID" style="width:125px" filterBy="#{client.loginID}" sortBy="#{client.loginID}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.loginID}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.loginID}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Password" style="width:125px" filterBy="#{client.password}" sortBy="#{client.password}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.password}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.password}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Address1" style="width:125px" filterBy="#{client.address1}" sortBy="#{client.address1}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.address1}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.address1}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Address2" style="width:125px" filterBy="#{client.address2}" sortBy="#{client.address2}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.address2}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.address2}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Address3" style="width:125px" filterBy="#{client.address3}" sortBy="#{client.address3}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.address3}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.address3}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="City" style="width:125px" filterBy="#{client.city}" sortBy="#{client.city}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.city}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.city}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="State" style="width:125px" filterBy="#{client.state}" sortBy="#{client.state}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.state}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.state}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Pincode" style="width:125px" filterBy="#{client.pincode}" sortBy="#{client.pincode}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.pincode}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.pincode}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Mobile No" style="width:125px" filterBy="#{client.mobileNo}" sortBy="#{client.mobileNo}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.mobileNo}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.mobileNo}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="STD Code" style="width:125px" filterBy="#{client.stdCode}" sortBy="#{client.stdCode}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.stdCode}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.stdCode}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Phone No" style="width:125px" filterBy="#{client.phoneNo}" sortBy="#{client.phoneNo}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.phoneNo}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.phoneNo}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Email ID" style="width:125px" filterBy="#{client.emailID}" sortBy="#{client.emailID}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{client.emailID}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{client.emailID}" style="width:100%" >
</p:inputText>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Edit" style="width:50px">
<p:rowEditor />
</p:column>
<p:ajax event="rowEdit" listener="#{clientUitility.editRowListner}" update=":cm:mymessage"/>
<p:column headerText="Delete" style="width:50px">
<p:commandButton id="deleteClient" value="Delete" onclick="confirmDeleteClient.show()" title="Delete this Client" styleClass="ui-icon-closethick">
</p:commandButton>
</p:column>
</p:dataTable>
</h:form>
</h:body>
clientUtility.java
#ManagedBean
#ViewScoped
public class ClientUitility {
private ClientBean client = new ClientBean();
private List<ClientBean> clientAll = new ArrayList<ClientBean>();
/** Creates a new instance of ClientUitility */
public ClientUitility() {
clientAll = new ArrayList<ClientBean>();
int userID = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("USER_ID").toString());
clientAll = ClientService.GenerateClientList(userID);
}
public List<ClientBean> getClientAll() {
return clientAll;
}
public void setClientAll(List<ClientBean> clientAll) {
this.clientAll = clientAll;
}
public ClientBean getClient() {
return client;
}
public void setClient(ClientBean client) {
this.client = client;
}
public String onFlowProcess(FlowEvent event) {
System.out.println("Current wizard step:" + event.getOldStep());
System.out.println("Next step:" + event.getNewStep());
System.out.println("First name : " + client.getfirstName());
System.out.println("Last name : " + client.getlastName());
System.out.println("Age name : " + client.getloginID());
return event.getNewStep();
}
public void editRowListner(RowEditEvent rowEditEvent) {
try {
ClientBean updatedClient = (ClientBean) rowEditEvent.getObject();
System.out.println("Client First Name: " + updatedClient.getfirstName());
ClientService.EditClient(updatedClient);
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Updated", updatedClient.getfirstName() + " " + updatedClient.getlastName()));
} catch (Exception e) {
e.getMessage();
}
}
public void deleteRecord(ActionEvent actionEvent) {
try {
//System.out.println("Client ID: " + actionEvent.getComponent().getAttributes().get("cID").toString());
System.out.println("delete client of User ID: " + FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("USER_ID").toString());
FacesMessage msg = new FacesMessage("Client Deleted", "");
FacesContext.getCurrentInstance().addMessage(null, msg);
} catch (Exception e) {
e.printStackTrace();
}
}
public void save(ActionEvent actionEvent) { client.setuserID(Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("USER_ID").toString()));
System.out.println("Client ID : " + client.getclientID());
System.out.println("User ID : " + client.getuserID());
ClientService.AddClient(client);
client = new ClientBean();
clientAll = ClientService.GenerateClientList(Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("USER_ID").toString()));
FacesMessage msg = new FacesMessage("Client Created", "");
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
Kindly advice where am I mistaking?
You can't and shouldn't nest forms.
In the ClientMaster.xhtml, replace
<ui:include id="ce" src="ClientEditDatatable.xhtml"/>
</h:form>
by
</h:form>
<ui:include id="ce" src="ClientEditDatatable.xhtml"/>
See also:
commandButton/commandLink/ajax action/listener method not invoked or input value not updated

Dropdown's valueChangeListener not working with primefaces datatable

I have datatable and a dropdown within a xhtml. If I am deleting p:datatable code within this page then I am able to call the valueChangeListener of dropdown , but if p:datatable is present in xhtml, then I am not able to call it.
Xhtml code is
<ui:define name="content">
<f:view>
<h:form id="accountSummaryForm" prependId="false">
<h:selectBooleanCheckbox id="checkbox" value="true" />
<h:outputLabel value="Show certificates preview on sumit"></h:outputLabel>
<h:outputLabel value="Show certificates preview on sumit"></h:outputLabel>
<h:outputText align="left"
value="Value is #{reqSummaryHandler.certNumber}" />
<p:dataTable id="reqActList" paginatorAlwaysVisible="true"
var="reqInfo" value="#{reqSummaryHandler.certActListModel}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
paginator="true" rows="#{label.accountList_defaultNumberOfRows}"
selectionMode="single"
rowsPerPageTemplate="#{label.accountList_numberOfRows}" width="60%">
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="#{label.certNumber}" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.certNumber}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Version" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.certVersionNbrString}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Insured" />
</f:facet>
<ui:repeat value="#{reqInfo.clientList}" var="insuredInfo">
<h:outputText align="left"
value="#{insuredInfo.generalPartyInfo.nameInfo.commName.commercialName}" />
</ui:repeat>
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Certificate Holder" />
</f:facet>
<ui:repeat value="#{reqInfo.certificateHolderInfoList}"
var="certHoldInfo">
<h:outputText align="left"
value="#{certHoldInfo.additionalInterest.generalPartyInfo.nameInfo.commName.commercialName}" />
</ui:repeat>
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Activity Performed" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.effectiveTypeCd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Certificate Status" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.statusCd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Third Party" />
</f:facet>
<h:outputText align="left"
value="#{reqInfo.certWordingEndorsementInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Manual Form" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.manualEntryInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Manual Addendum" />
</f:facet>
<h:outputText align="left" value="#{reqInfo.mnlAddendumInd}" />
</p:column>
<p:column style="text-align:center;" filterBy="" sortBy=""
width="5%">
<f:facet name="header">
<h:outputLabel value="Path" />
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText align="left" value="#{reqInfo.routePathCd}"
readonly="true" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu value="#{reqInfo.routePathCd}">
<f:selectItem itemLabel="Issue Distribute" itemValue="A" />
<f:selectItem itemLabel="Send to Underwriter" itemValue="B" />
<f:selectItem itemLabel="Issue Do Not Distribute"
itemValue="C" />
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
<p:rowEditor rendered="#{reqInfo.statusCd eq 'A'}" />
</p:column>
<p:column style="text-align:center;white-space: normal;nowrap">
<f:facet name="header">
<h:outputLabel value="Action" />
</f:facet>
<ui:repeat value="#{reqInfo.availableFunctions.functionNameArray}"
var="linkInfo">
<p:commandLink id="View" value="#{linkInfo}" ajax="false" />
<br />
</ui:repeat>
</p:column>
</p:dataTable>
<p:spacer width="50" height="0"></p:spacer>
<p:spacer width="50" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<p:spacer width="3" height="0"></p:spacer>
<h:outputLabel value="Assign Path" style="font-weight:bold" />
<p:spacer width="5" height="10" />
<h:selectOneMenu id="dropdown2"
valueChangeListener="#{reqSummaryHandler.DoPathProcessing1}"
value="#{reqSummaryHandler.certNumber}" onchange="submit();">
<f:selectItem itemLabel="Issue Distribute" itemValue="A" />
<f:selectItem itemLabel="Send to Underwriter" itemValue="B" />
<f:selectItem itemLabel="Issue Do Not Distribute" itemValue="C" />
</h:selectOneMenu>
</h:form>
</f:view>
</ui:define>
And listener code is
public void DoPathProcessing1(ValueChangeEvent event) {
String newValue = (String) event.getNewValue();
System.out.println("Path"
+ certActListModel.getRowData().getRoutePathCd());
certActListModel.getRowData().setRoutePathCd(newValue);
System.out.println("value is " + newValue);
}
Any idea why it is not working?
I am using jsf-api-2.0.3 and primefaces-2.2.1
You are using both the value and the valueChangeListener attributes of the drop down component. Why would you do this?
Just having value="#{reqSummaryHandler.certNumber} will call setCertNumber(String certNumber) in your managed bean. Why not just put this code into the setter method?

Resources