rowToggle should call first rowSelect event jsf primefaces - primefaces

<p:dataTable var="item" id="datatable-list" value="#{generalJournalEntryMB.generalJournalEntries}" rows="10"
paginator="true" reflow="true" paginatorPosition="top" rowExpandMode="single"
rendered="#{generalJournalEntryMB.generalJournalEntries.size() > 0}" rowIndexVar="rowIndex"
paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {NextPageLink} " rowKey="#{item.id}"
selectionMode="single" selection="#{generalJournalEntryMB.generalJournalEntry}" widgetVar="datatable-list">
<p:column style="width:16px">
<p:rowToggler />
</p:column>
<p:column headerText="Id">
<h:outputText value="#{item.id}" />
</p:column>
<p:column headerText="Description">
<h:outputText value="#{item.description}" />
</p:column>
<p:column headerText="Amount">
<h:outputText value="#{item.amount}" />
</p:column>
<p:column headerText="Reference">
<h:outputText value="#{item.reference}" />
</p:column>
<p:column headerText="State">
<h:outputText value="#{item.postingState.value}" />
</p:column>
<p:rowExpansion id="expand" rendered="true">
<p:panelGrid columns="2" columnClasses="label,value" style="width:300px">
<h:outputText value="Id:" />
<h:outputText value="1" />
<h:outputText value="Year" />
<h:outputText value="1983" />
<h:outputText value="Color:" />
<h:outputText value="White" />
<h:outputText value="Price" />
<h:outputText value="#{generalJournalEntryMB.price}" />
</p:panelGrid>
</p:rowExpansion>
<p:ajax event="rowSelect" listener="#{generalJournalEntryMB.rowSelectListener}" update="main:top-menu-bar" />
<p:ajax event="rowToggle" listener="#{generalJournalEntryMB.rowToggleListener}" update="main:top-menu-bar" />
</p:dataTable>
When I expand the row without selecting the row, it show nothing. Currently what am I doing is to first select row and expand it to get desire result.
How we can trigger rowSelect even / ajax call automatically when rowToggle event fire?

You can override primefaces toggleExpansion function so it executes selectRow before
PrimeFaces.widget.DataTable.prototype.toggleExpansion = (function() {
var cached_function = PrimeFaces.widget.DataTable.prototype.toggleExpansion;
return function() {
var row = arguments[0].closest('tr');
if(this.cfg.selectionMode === 'single') {
this.unselectAllRows();
}
if(this.cfg.selectionMode){
this.selectRow(row, false);
}
var result = cached_function.apply(this, arguments);
return result;
};
})();

Related

Primefaces Data Exporter : Exporting data issue

I have an List of List. lets say student and address. one to many relationship. In my data table there are 3 columns for the Name, Surname, Age related to the Student and In a single column I need to show address with concatenating the following fields like, address1, address2, city, country.Now I need to export this table by using <p:dataExporter>. When I try to export as Excel the corresponding column of Address is exported as Object (org.primefaces.uirepeat. blah blah..)
My code is
<p:dataTable value="#{manager.studentList}" var="item" id="studentData">
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{item.name}" />
</p:column>
<p:column>
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{item.surname}" />
</p:column>
<p:column>
<f:facet name="header">Age</f:facet>
<h:outputText value="#{item.age}" />
</p:column>
<p:column>
<f:facet name="header">Address</f:facet>
<ui:repeat value="#{studentBean.addressList}" var="address">
<h:outputText value="#{address.address1}" /> <br />
<h:outputText value="#{address.address2}" /> <br />
<h:outputText value="#{address.city}" /> <br />
<h:outputText value="#{address.country}" />
</ui:repeat>
</p:column>
</p:dataTable>
<h:commandLink>
<p:graphicImage name="/images/excel.png" />
<p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/>
</h:commandLink>
Suggest me some way to export. even I tried with c:forEach and columns.
<p:dataTable value="#{manager.studentList}" rowIndexVar="index" var="item" id="studentData">
<p:column>
<f:facet name="header">Name</f:facet>
<h:outputText value="#{item.name}" />
</p:column>
<p:column>
<f:facet name="header">Surname</f:facet>
<h:outputText value="#{item.surname}" />
</p:column>
<p:column>
<f:facet name="header">Age</f:facet>
<h:outputText value="#{item.age}" />
</p:column>
<p:column>
<f:facet name="header">Address</f:facet>
<c:forEach var="address" items="#{studentBean.addressList.get(index).address}">
<h:outputText value="#{address.address1}" />,
<h:outputText value="#{address.address2}"/>,
<h:outputText value="#{address.city}" />,
<h:outputText value="#{address.country}" />
</c:forEach>
</p:column>
</p:dataTable>
<h:commandLink>
<p:graphicImage name="/images/excel.png" />
<p:dataExporter type="xls" target="studentData" fileName="studentdetails" pageOnly="true"/>
</h:commandLink>
i trying with c:forEach is ok

ui:include not updateing on selection of row in dataTable

On selecting a row, I need to update the page which is in ui:insert of p:dialog. What my issue is when the page is loaded I can select the row and fetch the data. After selection of another row, I am not able to fetch. There is no action going on.
This is my dataTable
<p:ajax event="rowSelect" update="samples" />
<p:ajax event="rowUnselect" update="samples" />
<p:column headerText="SNo" style="width:20px;" >
#{rowIndex+1}
</p:column>
<p:column headerText="PatientId">
#{patServ.patientOrder.patientEpisode.patientRegistration.patientId}
</p:column>
<p:column headerText="Patient Name" >
#{patServ.patientOrder.patientEpisode.patientRegistration.firstName} #{patServ.patientOrder.patientEpisode.patientRegistration.lastName}
</p:column>
<p:column headerText="Visit ID">
#{patServ.patientOrder.patientEpisode.id}
</p:column>
<p:column headerText="Order ID">
#{patServ.patientOrder.id}
</p:column>
<p:column headerText="Barcode ID" >
<p:outputLabel value="#{resultEntryBean.getBarcodes(patServ.id)}" />
</p:column>
<p:column headerText="Department Name" >
#{loginBean.getSpecialityName( patServ.serviceLabData.serviceHeaderData.speciality )}
</p:column>
<p:column headerText="Service Name" >
#{patServ.serviceLabData.serviceHeaderData.serviceName}
</p:column>
<p:column headerText="Ordered Date">
<p:outputLabel value="#{patServ.createdOn}">
<f:convertDateTime pattern="dd/MM/yyyy hh:mm a" type="date" timeZone="IST" />
</p:outputLabel>
</p:column>
<p:column headerText="Status">
<p:outputLabel value="#{resultEntryBean.status == 3 ? 'Acknowledged': resultEntryBean.status == 5 ? 'Result Entered': resultEntryBean.status == 6 ? 'Result Authorized' : 'Result Deauthorized'}" />
</p:column>
<p:column>
<p:commandButton value="Print" icon="ui-icon-print" update="reportContent" disabled="#{empty resultEntryBean.selectedPatientService}" onclick ="PF('templateDlg').show()" ajax="true"/>
</p:column>
</p:dataTable>
and im updating xhtml in ui:include here in the dialog box
<p:dialog id="mainDialog" header="Selected Template" widgetVar="templateDlg">
<h:panelGroup id="reportContent">
<ui:include src="#{resultEntryBean.selectedTemplate()}.xhtml"></ui:include>
</h:panelGroup>
</h:form>
How should I update the xhtml file in the ui:include of p:dialog

export text then datalist in excel and pdf with dataexporter

I am using primefaces 3.4.2 jar. I have a datatable with four columns. In two columns I have a datalist and I want to export text showed by datalist. But when I export it, it shows the following "org.primefaces.component.datalist.DataList#1195cc3" in the pdf and xls file.
<p:dataTable emptyMessage="#{messages['empty.result.set']}" id="searchResult" var="row" value="#{managePessoaJuridica.manageableList}" rows="10" paginator="true" paginatorPosition="top" paginatorAlwaysVisible="false" style="display:#{managePessoaJuridica.manageableList == null? 'none': ''}">
<p:column styleClass="column_icons" exportable="false">
<p:panelGrid columns="#{pessoaJuridicaController.showSelectAction?3:2}">
<p:commandButton id="selectAction" icon="ui-icon-circle-check" title="#{messages['action.select']}" action="#{pessoaJuridicaController.select(row.id)}" immediate="true" process="#this" rendered="#{pessoaJuridicaController.showSelectAction}"/>
<p:commandButton id="editAction" icon="ui-icon-pencil" title="#{messages['action.edit']}" action="#{pessoaJuridicaController.load(row.id)}" immediate="true" process="#this" update="#form"/>
<p:commandButton id="deleteAction" icon="ui-icon-trash" title="#{messages['action.delete']}" action="#{pessoaJuridicaController.delete(row.id)}" immediate="true" process="#this" update="searchResult"
onclick="return confirm('#{messages['confirm.delete.this']} #{messages['pessoa.juridica.view.title']}');" />
</p:panelGrid>
</p:column>
<p:column id="column_nome" sortBy="#{row.nome}" >
<f:facet name="header">
<h:outputText id="columnHeader_nome" value="#{messages['pessoa.nome']}"/>
</f:facet>
<h:outputText id="nome" value="#{row.nome}">
</h:outputText>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_categoriasPessoa" value="#{messages['pessoa.categorias.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="categoriasPessoa" var="item" value="#{row.categoriasPessoa}" >
<p:column>
<h:outputText id="item_categoriasPessoa" value="#{item}" converter="com.domain.configuracao.crud.CategoriaPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column style="width:0px;">
<f:facet name="header">
<h:outputText id="columnHeader_identificacoesPessoa" value="#{messages['pessoa.identificacoes.pessoa']}"/>
</f:facet>
<p:dataList type="definition" id="identificacoesPessoa" var="item" value="#{row.identificacoesPessoa}">
<p:column>
<h:outputText id="item_categoriaIdentificacoes" value="#{pessoaJuridicaController.getCategoriaIdentificacao(item)}" converter="com.domain.configuracao.crud.CategoriaIdentificacaoJsfConverter"/>:
<h:outputText id="item_identificacoesPessoa" value="#{item}" converter="com.domain.configuracao.crud.IdentificacaoPessoaJsfConverter"/>
</p:column>
</p:dataList>
</p:column>
<p:column id="column_ativo" sortBy="#{row.ativo}" >
<f:facet name="header">
<h:outputText id="columnHeader_ativo" value="#{messages['classe.base.cadastro.ativo']}" />
</f:facet>
<h:outputText id="ativo" value="#{row.ativo}" converter="com.BooleanJsfConverter" >
</h:outputText>
</p:column>
<f:facet name="footer">
<p:menuButton value="#{messages['export.action']}" rendered="#{not empty managePessoaJuridica.manageableList}">
<p:menuitem value="#{messages['export.spreadsheet']}" ajax="false">
<p:dataExporter type="xls" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.pdf']}" ajax="false">
<pe:exporter type="pdf" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
<p:menuitem value="#{messages['export.csv']}" ajax="false">
<p:dataExporter type="csv" target="searchResult" fileName="export" excludeColumns="0" encoding="ISO-8859-1"/>
</p:menuitem>
</p:menuButton>
<p:spacer width="10"/>
<h:outputText value="#{fn:length(managePessoaJuridica.manageableList)} #{messages['records.found']}" rendered="#{not empty managePessoaJuridica.manageableList}"/>
</f:facet>
</p:dataTable>
But when I export it, it shows the following
"org.primefaces.component.datalist.DataList#1195cc3" in the pdf and
xls file.
Obviously, Primefaces's data exporter use the toString() method of an object to print its "value(s)".
Suggestions :
Write a custom exporter (recommended)
Override toString() method of org.primefaces.component.datalist.DataList (not advised)

Primefaces 5 Checkbox Multiselect Bug after Filtering

I am using Primefaces 5 with Primefaces Extension 2.0.0 And JSF 2.2 on a Wildfly 8.0.0.
I implemented a datatable using frozenColumns, filtering, pagination as well as multi-select provided by the built in checkboxes.
In most cases the Selected Items are submitted, but not in the following example:
No Items are Selected
Filter the Datatable Content with any Filter field
Select Items
Submit the Form
-> No Selected Items are Submited
Pictures provided in the primefaces Forum
My datatable's xhtml
<h:form id="jobListForm">
<p:panelGrid columns="2" styleClass="no-border">
</p:panelGrid>
<p:panelGrid columns="2" styleClass="no-border">
<p:selectBooleanCheckbox id="showAllTenants" value="#{JobProtocolBean.showAllTenants}" rendered="#{TenantController.isSuperAdmin}">
<p:ajax listener="#{FacesController.refresh}" event="change"/>
</p:selectBooleanCheckbox>
<p:outputLabel for="showAllTenants" value="Show all tenants" rendered="#{TenantController.isSuperAdmin}"/>
</p:panelGrid>
<h:panelGroup>
<mx:tableControls managedBean="#{JobProtocolBean}" />
<p:commandButton icon="ui-icon-arrowreturnthick-1-s" action="#{JobProtocolBean.showExportDialog}" value="Export" ajax="false" rendered="#{Shiro.isPermitted('jobprotocol:list:xmlexport')}" />
<p:dataTable id="JobProtocolTable" widgetVar="JobProtocolTableVar" value="#{JobProtocolBean.items}" binding="#{JobProtocolBean.items.dataTable}" lazy="true"
filteredValue="#{JobProtocolBean.filter}" var="item" paginator="true" rows="10"
currentPageReportTemplate="(Displaying results {startRecord} - {endRecord} of {totalRecords})"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,50,100,200,500,1000" filterEvent="enter"
selection="#{JobProtocolBean.selectedJobProtocols}"
scrollable="true" scrollWidth="50%" scrollHeight="100%" frozenColumns="2">
<f:event type="preRenderComponent" listener="#{JobProtocolBean.items.preRenderComponent}" />
<p:column id="ACTIONS" headerText="Actions" width="120">
<p:panelGrid columns="4" styleClass="button-column">
<p:commandButton icon="ui-icon-info" action="#{JobProtocolBean.startDetail}" ajax="false" title="Detail" disabled="#{not Shiro.isPermitted('jobprotocol:list:detail')}"/>
<p:commandButton icon="ui-icon-pencil" action="#{JobProtocolBean.startEdit}" ajax="false" title="Edit" disabled="#{not (Shiro.isPermitted('jobprotocol:list:edit') and (item.stateSkipped or item.stateUnplanned))}" />
<p:commandButton icon="ui-icon-copy" action="#{JobProtocolBean.startCopy}" ajax="false" title="Copy" disabled="#{not (Shiro.isPermitted('jobprotocol:list:retry') and item.stateDone and item.cron eq 'onetime')}" rendered="#{item.stateDone}" />
<p:commandButton icon="ui-icon-arrowrefresh-1-e" action="#{JobProtocolBean.startRetry}" ajax="false" title="Retry" disabled="#{not (Shiro.isPermitted('jobprotocol:list:retry') and item.stateSkipped)}" rendered="#{not (item.stateDone or item.stateQueued or item.stateUnplanned or item.statePlanned)}" />
<p:commandButton icon="ui-icon-pause" action="#{JobProtocolBean.startSuspend}" ajax="false" title="Suspend" onclick="return confirm('Do you really want to suspend this job?');" disabled="#{not Shiro.isPermitted('jobprotocol:list:suspend')}" rendered="#{item.statePlanned}" />
<p:commandButton icon="ui-icon-play" action="#{JobProtocolBean.startResume}" ajax="false" title="Resume" onclick="return confirm('Do you really want to resume this job?');" disabled="#{not Shiro.isPermitted('jobprotocol:list:resume')}" rendered="#{item.stateUnplanned}" />
<p:commandButton icon="ui-icon-circle-minus" action="#{JobProtocolBean.startUnqueue}" ajax="false" title="Unqueue" onclick="return confirm('Do you really want to unqueue and re-schedule this job?');" disabled="#{not Shiro.isPermitted('jobprotocol:list:unqueue')}" rendered="#{item.stateQueued}" />
<p:commandButton icon="ui-icon-cancel" action="#{JobProtocolBean.startSkip}" ajax="false" title="Skip" disabled="#{not Shiro.isPermitted('jobprotocol:list:skip') or item.stateDoneOrSkipped}" />
</p:panelGrid>
</p:column>
<p:column selectionMode="multiple" width="18" />
<p:column id="ID" headerText="ID" sortBy="#{item.id}" filterBy="#{item.id}" width="50">
<h:outputText title="#{item.id}" value="#{item.id}"/>
</p:column>
<p:column id="TENANT" headerText="Tenant" rendered="#{JobProtocolBean.showAllTenants}" sortBy="#{item.tenantId}" filterBy="#{item.tenantId}" width="50">
<h:outputText title="#{item.tenantId}" value="#{item.tenantId}" converter="JobTenantConverter"/>
</p:column>
<p:column id="INITIATOR" headerText="Initiator" sortBy="#{item.initiator}" filterBy="#{item.initiator}" width="120">
<h:outputText title="#{item.initiator}" value="#{item.initiator}" />
</p:column>
<p:column id="CODE" headerText="Code" sortBy="#{item.code}" filterBy="#{item.code}" width="300">
<h:outputText title="#{item.code}" value="#{item.code}" converter="JobCodeConverter" escape="false" />
</p:column>
<p:column id="CHANNEL_ID" headerText="Channel ID" sortBy="#{item.channelId}" filterBy="#{item.channelId}" width="150">
<h:outputText title="#{item.channel}" value="#{item.channel}" />
</p:column>
<p:column id="SEQUENCE" headerText="Sequence" sortBy="#{item.orderId}" filterBy="#{item.orderId}" width="65" >
<h:outputText title="#{item.orderId}" value="#{item.orderId}" />
</p:column>
<p:column id="STATE" headerText="State" filterBy="#{item.state}" filterOptions="#{JobProtocolBean.states}" width="80">
<h:outputText value="#{item}" converter="JobStateConverter" />
</p:column>
<p:column id="CRON" headerText="Cron" sortBy="#{item.cron}" filterBy="#{item.cron}" width="70" >
<h:outputText title="#{item.cron}" value="#{item.cron}" />
</p:column>
<p:column id="META" headerText="Meta" sortBy="#{item.meta}" filterBy="#{item.meta}" width="100">
<h:outputText title="#{item.meta}" value="#{item.meta}" />
</p:column>
<p:column id="MIN_FAILURES" headerText="≥ Retries" sortBy="#{item.failures}" filterBy="#{item.failures}" width="60">
<h:outputText title="#{item.failures}" value="#{item.failures}" />
</p:column>
<p:column id="BUSINESS_ERROR" headerText="Failure" sortBy="#{item.errorCode}" filterBy="#{item.errorCode}" width="80">
<h:outputText title="#{item.errorCode}" value="#{item.errorCode}" />
</p:column>
<p:column id="SKIP_REASON" headerText="Skip Reason" sortBy="#{item.skipReason}" filterBy="#{item.skipReason}" width="80">
<h:outputText title="#{item.skipReason}" value="#{item.skipReason}" />
</p:column>
<p:column id="TIME_STORED" sortBy="#{item.timeStored}" width="120">
<mxtaglib:dateFilter dateProperty="#{item.timeStored}" datePropertyName="timeStored" headerText="Time Stored" tableBinding="#{JobProtocolBean.items}"/>
</p:column>
<p:column id="PLANNED_START" sortBy="#{item.nextPlannedStart}" width="120">
<mxtaglib:dateFilter dateProperty="#{item.nextPlannedStart}" datePropertyName="nextPlannedStart" headerText="Planned Start" tableBinding="#{JobProtocolBean.items}"/>
</p:column>
<p:column id="TIME_QUEUED" sortBy="#{item.timeQueued}" width="120">
<mxtaglib:dateFilter dateProperty="#{item.timeQueued}" datePropertyName="timeQueued" headerText="Time Queued" tableBinding="#{JobProtocolBean.items}"/>
</p:column>
<p:column id="TIME_STARTED" sortBy="#{item.timeStarted}" width="120">
<mxtaglib:dateFilter dateProperty="#{item.timeStarted}" datePropertyName="timeStarted" headerText="Time Started" tableBinding="#{JobProtocolBean.items}"/>
</p:column>
<p:column id="TIME_DONE" sortBy="#{item.timeDone}" width="120">
<mxtaglib:dateFilter dateProperty="#{item.timeDone}" datePropertyName="timeDone" headerText="Time Done" tableBinding="#{JobProtocolBean.items}"/>
</p:column>
</p:dataTable>
<p:outputPanel styleClass="ui-paginator-inline-span">
<p:selectOneMenu id="ACTION_SELECTOR" value="#{JobProtocolBean.selectedAction}" >
<f:selectItems value="#{JobProtocolBean.accessibleActions}" itemValue="#{JobProtocolBean.accessibleActions.value}" />
</p:selectOneMenu>
<p:commandButton id="ACTION_BUTTON" action="#{JobProtocolBean.startActionSelected}" ajax="false" value="OK" />
</p:outputPanel>
<mxtaglib:blockUI block="JobProtocolTable" trigger="JobProtocolTable" styleClass="block-ui" />
</h:panelGroup>
</h:form>
I found the origin of the described bug:
The Javascript Object for datatables with frozenColumns provides a function to copy the 's reveived by an ajax request like in sort, filter etc.
This function doesn't take care of the 'rk' value which is saved in the data (jQuery data()) of the .
Original:
copyRow: function(original) {
return $('<tr></tr>').data('ri', original.data('ri')).addClass(original.attr('class')).attr('role', 'row');
};
My Workaround:
PF(datatableUtils.datatableWidgetVar).copyRow = function(original) {
return $('<tr></tr>').attr('data-ri', original.data('ri')).attr('data-rk', original.data('rk')).addClass(original.attr('class')).attr('role', 'row');
};
writing the data with attr() and the 'data-' prefix is necessary as it seems to lose the stored data as the tr is not yet attached. (I honestly didn't follow this one to the end so correct me if I'm wrong with this)

Update <p:dialog> whenever new dialog box open in PrimeFaces

It keeps showing the previous value instead of the new one.
<p:panel id="instantTransPanel" header="Quick Transfer (To Beneficiary)" toggleable="true" closable="false" toggleSpeed="500" closeSpeed="500" widgetVar="instantTransPanelVar"
rendered="#{userMBean.loggedOnUser.customer.customerType != constantuserMBean.getFETSTYPE() and (userMBean.loggedOnUser.customer.customerType != constantuserMBean.getMERCHANTTYPE() or (userMBean.loggedOnUser.customer.customerType == constantuserMBean.getMERCHANTTYPE() and userMBean.loggedOnUser.customer.hasCustomerCapability))}">
<p:commandButton value="Add New Beneficiary" onclick="addBendlg.show();" />
<br/><br/>
<p:dataTable id="beneficiariesTable" var="obj" value="#{userMBean.loggedOnUser.customer.customerBeneficiaryList}"
paginator="true" rows="20"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="20,50,100" style="width:100%" resizableColumns="true">
<p:column sortBy="#{obj.beneficiaryMsisdn}" headerText="Mobile Number" filterBy="#{obj.beneficiaryMsisdn}" filterMatchMode="contains">
<h:outputText value="#{obj.beneficiaryMsisdn}" />
</p:column>
<p:column sortBy="#{obj.beneficiaryName}" headerText="Name" filterBy="#{obj.beneficiaryName}" filterMatchMode="contains">
<h:outputText value="#{obj.beneficiaryName}" />
</p:column>
<p:column sortBy="#{obj.crt_dt}" headerText="Date Added">
<h:outputText value="#{obj.crt_dt}" />
</p:column>
<p:column headerText="Transfer">
<p:commandButton value="Transfer" update=":form:transferBenPanel" action="#{engineMBean.initTransfer(obj.beneficiaryMsisdn, obj.beneficiaryName)}" oncomplete="transferToBendlg.show();" />
</p:column>
<p:column headerText="Delete">
<p:commandButton ajax="false" onclick="return confirm('Are you sure?');" action="#{userMBean.deleteBeneficiary(obj.beneficiaryMsisdn)}" icon="ui-icon-close" style="margin:0"/>
</p:column>
</p:dataTable>
</p:panel>
After that it calls dialog and it works properly the first time but the next time I want to enter another value once clicked it pops up with the old values.
<p:dialog id="addBenDialog" header="Add Beneficiary" widgetVar="addBendlg" modal="true" dynamic="true" position="center">
<p:panelGrid columns="2" cellpadding="5" style="margin-bottom:10px;">
<f:facet name="header"></f:facet>
<h:outputLabel for="bmsisdn" value="Beneficiary Mobile Number: *" />
<p:inputText id="bmsisdn" value="#{userMBean.beneficiary.beneficiaryMsisdn}">
<p:ajax update="bname" />
</p:inputText>
<h:outputLabel for="bname" value="Beneficiary Name: " />
<h:outputText id="bname" value="#{userMBean.lookUpBeneficiaryName(userMBean.beneficiary.beneficiaryMsisdn)}" />
<f:facet name="footer">
<p:commandButton ajax="false" onclick="return confirm('Are you sure?');" action="#{userMBean.addBeneficiary}" value="Save" icon="ui-icon-disk" style="margin:0"/>
</f:facet>
</p:panelGrid>
</p:dialog>
You need to update the dialog box before it shows.
Change code as:
<p:commandButton value="Add New Beneficiary" onComplete="addBendlg.show(); update=:form:addBenDialog" />