I tried to make a <p:dataTable> with <p:contextMenu> using primefaces 3.5 on Mojarra 2.2.1.
The ContextMenu Code :
<p:contextMenu for="actionnairesDT">
<p:menuitem value="View" update="displayActionnaires" icon="ui-icon-search" oncomplete="actDialog.show()"/>
<p:menuitem value="Delete" update="actionnairesDT" icon="ui-icon-close" />
</p:contextMenu>
the problem is that the dialog box is displayed empty.
I tried to show my object in the setter setSelecedActionnaire(), it displays nothing
not even null.
public void setSelectedActionnaire(Actionnaires selectedActionnaire) {
System.out.println(selectedActionnaire);
this.selectedActionnaire = selectedActionnaire;
}
<p:dataTable> and <p:dialog> code is below. thank you in advance for your help !
<p:dataTable id="actionnairesDT" paginatorPosition="bottom"
pageLinks="10" paginator="true" rows="20" value="#{actionnairesBean.actionnairesList()}" var="actionnaires"
rowKey="#{actionnaires.nomAct}" selection="#{actionnairesBean.selectedActionnaire}" selectionMode="single"
>
<p:ajax event="rowSelect" update="actionnairesDT" oncomplete="actDialog.show()" />
<p:column sortBy="#{actionnaires.actionnairesPK.codeAct}" headerText="N°">
#{actionnaires.actionnairesPK.codeAct}
</p:column>
<p:column headerText="Nom" sortBy="#{actionnaires.nomAct}">
#{actionnaires.nomAct}
</p:column>
<p:column>
#{actionnaires.quatiteAct}
</p:column>
<p:column headerText="Sicav">
#{actionnaires.actionnairesPK.codeSicav}
</p:column>
</p:dataTable>
<p:dialog header="Détail Actionnaire" widgetVar="actDialog" resizable="false"
showEffect="clip" hideEffect="fold" id="actDialog" closable="true" modal="true">
<h:panelGrid id="displayActionnaires" columns="2" cellpadding="4">
<h:outputText value="Nom Actionnaire"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.nomAct}"/>
<h:outputText value="Quantité"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.quatiteAct}"/>
<h:outputText value="Sicav"/>
<h:outputText value="#{actionnairesBean.selectedActionnaire.sicavs.libelleSicav}"/>
</h:panelGrid>
</p:dialog>
In the end, I found the solution
I add <p:ajax> to the <p:dataTable>:
<p:ajax event="contextMenu"/>
Related
I'm using Primefaces 3.4.2 and due to some restrictions i can't update it to latest version. I have to add a edit option for column "Contact" in the datatable in below code so that user can edit it and update it.
I already tried by using Primefaces inplace and row editing (only for a single column) but it takes ages to submit when clicked on save or cancel button.
Can anyone help me with this?
Thank you very much for your help in advance.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<p:dialog id="viewSitesHistoricAlarm" header="Alarm Information" widgetVar="viewSiteHistoricAlmDialog" modal="false" minWidth="930"
minHeight="600" fixedCenter="false" appendToBody="true" effect="FADE" effectDuration="0.5" close="true" closeListener="#{historicActivity.dlgClose}">
<h:form id="viewsiteHistoricAlmFrm">
<h:panelGrid columns="1" style="margin:5px;" id="printid">
<p:dataTable id="alarmResolution" var="alm" value="#{historicActivity.alarmResolution}"
style="border-right-width: 2px !important;overflow: -moz-scrollbars-vertical;overflow-x: auto;overflow-y: auto; width:895px;max-height:500px !important;" paginatorPosition="top" paginatorTemplate="{PreviousPageLink} {CurrentPageReport}
{NextPageLink}" editable="true" rows="100" paginatorAlwaysVisible="false">
<p:ajax event="rowEdit" listener="#{historicActivity.updateContactName}" />
<p:column style="width:155px">
<f:facet name="header">
<h:outputText value="Action Time"/>
</f:facet>
<h:outputText value="#{alm.timeActioned}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="User"/>
</f:facet>
<h:outputText value="#{alm.user}"/>
</p:column>
<p:column style="width:140px" >
<f:facet name="header">
<h:outputText value="Action"/>
</f:facet>
<h:outputText value="#{alm.action}"/>
</p:column>
<p:column style="width:140px" >
<f:facet name="header">
<h:outputText value="Contact"/>
</f:facet>
<h:outputText value="#{alm.alm.contactName}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Comments"/>
</f:facet>
<h:outputText value="#{alm.comments}"/>
</p:column>
<p:column headerText="Modify">
<p:rowEditor />
</p:column>
</p:dataTable>
<p:toolbar>
<p:toolbarGroup align="left">
<p:commandButton value="CSV" ajax="false" style="color:#A8A6A8!important;">
<p:dataExporter type="csv" target="alarmResolution" fileName="historicalarminfo" preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}"/>
</p:commandButton>
<p:commandButton value="PDF" style="color:#A8A6A8!important;" update="viewsiteHistoricAlmFrm" onstart= "pdfDownloadDialog.show();" rendered="#{historicActivity.val==true}">
<f:setPropertyActionListener target="#{pdfExp.columnValues}" value="#{historicActivity.exptrColValsAlmSpecific}"/>
<f:setPropertyActionListener target="#{pdfExp.tabColumnsWithSize}" value="#{historicActivity.exptrSpecificAlmCol}"/>
<f:setPropertyActionListener target="#{pdfExp.headerContent}" value="#{historicActivity.exptrHeaderAlmSpecific}"/>
<f:setPropertyActionListener target="#{pdfExp.logo}" value="#{historicActivity.exptrHeaderLogo}"/>
<f:setPropertyActionListener target="#{pdfExp.pageTitle}" value="#{historicActivity.exptrPgTitle}"/>
<f:setPropertyActionListener target="#{pdfExp.fileName}" value="#{historicActivity.exptrFileName}"/>
<f:setPropertyActionListener target="#{pdfExp.redirectTo}" value="HistoricActivityPage?faces-redirect=true"/>
</p:commandButton>
<p:commandButton value="PDF" style="color:#A8A6A8!important;" actionListener
="#{historicActivity.checkHistoricSiteAlmsSize}" update="viewsiteHistoricAlmFrm" rendered
="#{historicActivity.val==false}"/>
<p:commandButton value="XLS" ajax="false" style="color:#A8A6A8!important;">
<p:dataExporter type="xls" target="alarmResolution" preProcessor="#{exporter.preProcessor}" postProcessor="#{exporter.postProcessor}" fileName="historicalarminfo"/>
</p:commandButton>
</p:toolbarGroup>
</p:toolbar>
</h:panelGrid>
</h:form>
</p:dialog>
</ui:composition>
I am trying to use datatable selection in dialog widget. But I cannot get selected value in my bean. Datatable selection is working, if I delete dialog widget tag. I am using PrimeFaces 4.0. How can I fix this?
passengerform.xhtml
<p:hotkey bind="esc" handler="dialogWidget.hide();" />
<p:dialog id="dialog" widgetVar="dialogWidget"
header="Coupon List" modal="true" width="400" showEffect="fade"
hideEffect="fade" appendTo="#(body)">
<h:form id="formDialog">
<h:outputLabel value="Lütfen E-ticket Kuponunu Seçiniz." />
<p:dataTable id="singleDT" var="coupon"
value="#{passengerFormService.couponList}"
rowKey="#{coupon.id}" rowIndexVar="rowIndex"
selection="#{passengerFormService.selectedCoupon}"
selectionMode="single">
<p:ajax event="rowSelect"
listener="#{passengerFormService.selectCoupon}"
update=":tab1:tab1_1:eticketform:formDialog">
<f:setPropertyActionListener value="#{coupon}"
target="#{passengerFormService.coupon}" />
</p:ajax>
<f:facet name="header"></f:facet>
<h:inputHidden name="hidden1"
value="#{passengerFormService.passengerForm.id}" />
<p:column style="width:20px" width="20">
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{rowIndex+1}" />
</p:column>
<p:column headerText="Id">
<h:outputText value="#{coupon.id}" />
</p:column>
<p:column headerText="Departure Location">
<h:outputText value="#{coupon.departureLocation}" />
</p:column>
<f:facet name="footer"></f:facet>
</p:dataTable>
<p:separator />
<h:panelGrid columns="2" cellspacing="5"
columnClasses="alignLeft,alignRight" style="width:100%">
<p:commandButton id="selectButton1" update=""
icon="ui-icon-close" value="İptal"
oncomplete="PF('dialogWidget').hide()" />
<p:commandButton id="cancelSelectedButton1"
update=":tab1:tab1_1:passengerInsertform"
icon="ui-icon-check"
value="Onayla" oncomplete="PF('dialogWidget').hide()" />
</h:panelGrid>
</h:form>
</p:dialog>
PassengerFormService.java
public void selectCoupon(SelectEvent event) {
Log.getLogger().debug("New2 coupon selected...");
Log.getLogger().debug("selected: " +getSelectedCoupon());
}
I have this datatable:
<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single" selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<p:column headerText="Equipo">
<h:outputText value="#{ref.equipo}" />
</p:column>
<p:column headerText="Marca">
<h:outputText value="#{ref.marca}" />
</p:column>
//More colums here...
</p:dataTable>
And I want to show this dialog after the user select a row:
<p:dialog id="myDialog" widgetVar="refaccionDialog" header="Detalle Refaccion" resizable="false" width="300" showEffect="explode" hideEffect="explode">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Info:" />
<h:outputText value="#{consultasBean.refaccionSeleccionada.equipo}" />
</h:panelGrid>
//More things here...
</p:dialog>
And this is part of my bean (viewscoped):
private List<RefaccionBean> listaRefacciones = null;
private RefaccionBean refaccionSeleccionada = null;
// setters and getters...
listaRefacciones already has info, so dont worry about how it gets it.
I know i have to use p:ajax but just dont know how.
I was checking this (example 1 is what i want) but the info is too old and does not work now.
Please help me.
Just include a p:ajax inside your table
<p:ajax event="rowSelect" oncomplete="PF('refaccionDialog').show()" update=":dialogId" />
Hope this helps.
rowKey attribute of datatable is wrongly written.
it should be like as follows
rowKey="#{ref.idRefaccion}"
The datatable code should as follows
<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single"
selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<p:column headerText="Equipo">
<h:outputText value="#{ref.equipo}" />
</p:column>
<p:column headerText="Marca">
<h:outputText value="#{ref.marca}" />
</p:column>
//More colums here...
</p:dataTable>
I want increment visible rows of p:dataTable when click on p:outputLink. Here is picture:
and my code is:
<p:dataTable value="#{tasks}" styleClass="dashTable"
var="tasklar" rows="5" lazy="true"
selection="#{flowScope.selectedTask}" selectionMode="single" >
<p:ajax event="rowSelect" />
<p:column headerText="#{messages.label_task_temasy}">
<h:outputText value="#{tasklar.taskTemasy}"/> </p:column>
</p:dataTable>
Thank`s for help.
I have resolved my problem. Here is code:
<h:form id="dataForm">
<p:dataTable value="#{tasks}" styleClass="dashTable"
var="tasklar" rows="#{taskCriteria.pageSize}" lazy="true"
selection="#{flowScope.selectedTask}" selectionMode="single" >
<p:ajax event="rowSelect" />
<p:column headerText="#{messages.label_task_temasy}">
<h:outputText value="#{tasklar.taskTemasy}"/> </p:column>
</p:dataTable>
<p:commandLink style="float:left" update=":dataForm"
action="#{taskCriteria.setPageSize(taskCriteria.pageSize+5)}">
<h:outputText value="Show more..." />
</p:commandLink>
</h:form>
I'm using Primefaces Datatable-ContextMenu and Dialog to update a row (When after click to contextmenu it opens a dialog which contains will update object's fields in <p:inputext />).
I have tried dynamic true, initilazing object on constructor because when page is rendered selectedObject will be null in dialog and when I tried to use it gives null pointer exception so that i need other advices.
Here is ContextMenu:
<p:contextMenu for="functions" id="functionContextMenu">
<p:menuitem value="Guncelle" icon="ui-icon-" update="updateDialog" oncomplete="updateDialog.show()"/>
And my dialog is here:
<p:dialog header="Guncelle" widgetVar="updateDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="updateDialog" dynamic="true">
<h:panelGroup id="display">
<h:outputText value="#{functionControllerBean.selectedFunction.functionName}" />
<h:inputText id="firstName" value="{functionControllerBean.tempSelectedFunction1.functionName}" />
</h:panelGroup>
</p:dialog>
If I dont use <p:inputText /> its ok and show what i put <h:outputText /> but when i put p:inputext inside of dialog;it doesnt show output text value and shows <p:inputText /> empty even its not.
I had used beanname.objectname.field before inside of <p:inputText /> or <h:inputText /> but there was no problem but now it's not working.
And here is my ManagedBean :
#ManagedBean
#RequestScoped
public class FunctionControllerBean implements Serializable {
private EfaFunctions willAddFunction;
private EfaFunctions selectedFunction = new EfaFunctions();
Thanks in advance
UPDATE Here is page
<h:form id="form">
<p:contextMenu for="functions" id="functionContextMenu">
<p:menuitem value="Guncelle" icon="ui-icon-" update="updateDialog" oncomplete="updateDialog.show()"/>
<p:menuitem value="Sil" update="#form" icon="ui-icon-close" actionListener="#{functionControllerBean.deleteFunction}"/>
</p:contextMenu>
<p:dataTable resizableColumns="true" id="functions" var="function" value="#{functionControllerBean.functions}" rowKey="#{function.functionId}"
selection="#{functionControllerBean.selectedFunction}" selectionMode="single">
<p:column headerText="Id">
#{function.functionId}
</p:column>
<p:column headerText="Key ">
#{function.functionKey}
</p:column>
<p:column headerText="Isim" >
#{function.functionName}
</p:column>
<p:column headerText="Tip" >
#{function.functionType}
</p:column>
<p:column headerText="Url" >
#{function.uri}
</p:column>
<p:column headerText="Olusturulma Tarihi" >
#{function.creationDate}
</p:column>
<p:column headerText="Guncelleme Tarihi" >
#{function.lastUpdateDate}
</p:column>
<p:column headerText="Olusturan Kisi" >
#{function.createdBy}
</p:column>
<p:column headerText="Guncelleyen Kisi" >
#{function.createdBy}
</p:column>
</p:dataTable>
<p:dialog header="Islem Sonucu" widgetVar="actionResult" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="actionResult"
visible="#{functionControllerBean.actionResult!=null}">
<h:outputText value="#{functionControllerBean.actionResult}"/>
</p:dialog>
<p:dialog header="Guncelle" widgetVar="updateDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold" id="updateDialog" >
<h:panelGroup id="display">
<h:outputText value="#{functionControllerBean.selectedFunction.functionName}" />
<p:inputText value="#{functionControllerBean.selectedFunction.functionName}"/>
</h:panelGroup>
</p:dialog>
</h:form>