I've been trying to make use of primefaces lazy loading datatable. Without the lazy loading, the method delete(trans) gets called but not same with the lazy. Please, can someone tell me why the delete(trans) is never called when clicked. I've been on it all day (I tried with primefaces 4.x and 5.x)
<h:form>
<p:dataTable value="#{transactionView.transactions}" var="trans"
paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="5,10,15" lazy="true">
<p:column headerText="#{messages.trans_date}" width="100">
<h:outputText value="#{trans.transDate}">
<f:convertDateTime pattern="#{messages.date_pattern2}"/>
</h:outputText>
</p:column>
<p:column headerText="#{messages.description}">
<h:outputText value="#{trans.description}"/>
</p:column>
<p:column>
<p:commandLink value="X" style="color: red" update="#form" ajax="true"
action="#{transactionView.delete(trans)}"/>
</p:column>
</p:dataTable>
</h:form>
Related
i have a realy strange behavior if i place components inside a datatable header.
Code for the Table
<p:dataTable id="groupTable" var="group" value="#{profile.user.groups}"
widgetVar="groupTable" rows="10" paginator="true"
paginatorPosition="bottom"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,20,40,80"
emptyMessage="Keine Einträge mit den gewünschten Kriterien gefunden"
filteredValue="#{groupView.filteredGroups}" sortMode="multiple"
resizableColumns="true" liveResize="true">
<f:facet name="header">
<h:outputText value="Zugeordnete Gruppen" />
<p:outputPanel style="float:left;">
<p:inputText id="globalFilter" onkeyup="PF('groupTable').filter()" style="width:150px;" placeholder="Suche"/>
</p:outputPanel>
</f:facet>
<p:column headerText="Gruppenname" filterBy="#{group.name}"
sortBy="#{group.name}" filterMatchMode="contains"
filterStyle="display:none" style="width:150px">
<h:outputText value="#{group.name}"/>
</p:column>
<p:column headerText="Beschreibung" filterBy="#{group.beschreibung}"
sortBy="#{group.beschreibung}" filterMatchMode="contains"
filterStyle="display:none">
<h:outputText value="#{group.beschreibung}"/>
</p:column>
</p:dataTable>
you can find the generated HTML here jsfiddle
On the Page itself it looks like this:
So what is the problem with the code? why does the serach box destroy the table layout?
Okay i found it. Maybe it will help someday another facing the same Problem.
The Searchbox is to big in line with the Text. If i change the inputtext size and set the outputpanel inline it looks like it was intended.
<f:facet name="header">
<h:outputText value="Zugeordnete Gruppen" />
<p:outputPanel style="display:inline">
<p:inputText id="globalFilter" onkeyup="PF('groupTable').filter()" style="width:150px;height:10px;float:left" placeholder="Suche"/>
</p:outputPanel>
</f:facet>
dialog not displaying with ManagedBeans. if datatable is not connecting Managedbean, dialog is displaying. i think dialog and datatable tags codes are correct. Maybe it depends on managedbeans pls suggest me.
<p:commandButton value="insert Qstn" onclick="PF('dlgAdd').show();"/>
<p:dataTable var="lstQstn" value="#{qstnBean.lstQstn}" rows="5" sortMode="multiple"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5, 10, 15">
<p:column headerText="group" sortBy="#{lstQstn.qGroup}">
<p:outputLabel value="#{lstQstn.qGroup}"/>
</p:column>
<p:column headerText="qstn">
<p:outputLabel value="#{lstQstn.qQuestion}"/>
</p:column>
<p:column headerText="type" sortBy="#{lstQstn.qType}">
<p:outputLabel value="#{lstQstn.qType}"/>
</p:column>
<p:column headerText="AskedCnt">
<p:outputLabel value="#{lstQstn.qAskedCnt}"/>
</p:column>
<p:column headerText="state">
<p:outputLabel value="#{lstQstn.qState}"/>
</p:column>
</p:dataTable>
<p:dialog id="dlg" header="fielder" widgetVar="dlgAdd" appendTo="#(body)">
<p:panelGrid>
....
</p:panelGrid>
<p:commandButton value="Хадгал" oncomplete="PF('dlgAdd').hide();"/>
</p:dialog>
You are missing an end tag for one of your columns:
<p:column headerText="qstn">
<p:outputLabel value="#{lstQstn.qQuestion}"/>
I have nested overlay panels inside nested datatables. In the code below ajax is not working properly. The same ajax call work sometimes and does not work next time. Sometimes it works perfectly and sometimes it does not.
<p:dataTable
id="MultipleDataTable"
var="MultipleDiseasedDetail"
rendered="#{diseasePatientDetailController.radioButtonSelect == 2}"
value="#{diseasePatientDetailController.groupedMultiDiseasedPatientsByDiseaseIdList}"
scrollable="true"
scrollHeight="235"
rows="20"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30"
paginatorPosition="bottom"
style="float:left;width:500px;"
>
<p:column styleClass="DiseaseNameTableColumn" sortBy="#{MultipleDiseasedDetail.disease_Name}">
<f:facet name="header">
<h:outputText value="Diseases"/>
</f:facet>
<h:commandLink id="patient" value="#{MultipleDiseasedDetail.disease_Name}">
<f:param id="diseaseIdParam" name="diseaseIdParam" value="#{MultipleDiseasedDetail.disease_Id}"/>
<f:ajax
listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
execute ="patient diseaseIdParam"
event="click"
render ="drDiseasesByCountTable"
/>
</h:commandLink>
<p:overlayPanel
id="MultipleDiseasePanel"
appendToBody="true"
for="patient"
hideEffect="fade"
dynamic="true"
style="width:600px"
showCloseIcon="true"
>
<p:dataTable
id="drDiseasesByCountTable"
var="drDiseasesByCount"
value="#{diseasePatientDetailController.groupedMultiDiseasedPatientsByDiseaseGroupList}"
scrollable="true"
scrollHeight="175"
rows="20"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30"
paginatorPosition="bottom"
>
<p:column styleClass="DiseaseNameTableColumn" sortBy="#{drDiseasesByCount.grp_disease_names}">
<f:facet name="header">
<h:outputText value="Diseases"/>
</f:facet>
<h:commandLink id="groupedDiseasesLink" value="#{drDiseasesByCount.grp_disease_names}">
<f:param id="grpDiseaseIdsParam" name="grpDiseaseIdsParam" value="#{drDiseasesByCount.grp_disease_ids}"/>
<f:ajax
listener="#{diseasePatientDetailController.drDiseasesByCountTable_RowClickEvent}"
execute ="groupedDiseasesLink grpDiseaseIdsParam"
event="click"
render="groupedDiseasesPatientsTable"
/>
</h:commandLink>
<p:overlayPanel
id="MultipleDiseasePatientPanel"
appendToBody="true"
for="groupedDiseasesLink"
hideEffect="fade"
dismissable="false"
showCloseIcon="true"
dynamic="true"
style="width:600px">
<p:dataTable
id="groupedDiseasesPatientsTable"
var="drGroupPatient"
value="#{diseasePatientDetailController.multiPatientsByGroupDiseaseIDList}"
scrollable="true"
scrollHeight="150"
rows="20"
paginator="true"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,20,30"
paginatorPosition="bottom"
>
<p:column styleClass="DiseaseNameTableColumn" sortBy="#{drGroupPatient.patientName}">
<f:facet name="header">
<h:outputText value="Patient"/>
</f:facet>
<h:outputLink value="#{drGroupPatient.patientDashboardUrl}">
<h:outputText id="patient" value="#{drGroupPatient.patientName}" />
</h:outputLink>
</p:column>
</p:dataTable>
</p:overlayPanel>
</p:column>
</p:dataTable>
</p:overlayPanel>
</p:column>
</p:dataTable>
Am I doing anything wrong with the ajax call. I have well tested my backend controllers. They are working fine. Is it not a good practice to work with overlaypanel with nested datatables.
Thank you for your precious time.
For the complete answer, your f:ajax should go from
<f:ajax
listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
execute ="patient diseaseIdParam"
event="click"
render ="drDiseasesByCountTable"/>
to
<p:ajax
listener="#{diseasePatientDetailController.MultiDataTable_RowClickEvent}"
process="patient diseaseIdParam"
event="click"
update="drDiseasesByCountTable"/>
I'm using PrimeFaces 3.5, with a datatable that i need use a FilterBy component.
In show case, it works ok: http://www.primefaces.org/showcase/ui/datatableFiltering.jsf
well, when i do my first filter, its work and it show me result, but when i do a second filter, it stop working.
See my xHTML:
<p:dataTable id="users"
var="user"
value="#{userMB.users}"
rowKey="#{user.id}"
selection="#{userMB.userSelected}"
selectionMode="single"
rows="10"
paginator="true"
filteredValue="#{userMB.filteredUser}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
>
<p:column headerText="Id" >
#{user.id}
</p:column>
<p:column headerText="Login" filterBy="#{user.login}">
#{user.login}
</p:column>
</p:dataTable>
Observations: userMB its my managed bean, #SessionScoped
users it's a List
filteredUser it's a List
it's all... thank a attention :)
I am new here too, but this example worked for me.
I see some problems in your example.
First if you put var="user" then rowKey="#{userMB.id}" must be rowKey="#{user.id}"
Same here:
As you see I removed filterValue="#{usuario.login}" as I don't used this.
In the end this should look like this:
<p:dataTable id="users"
var="user"
value="#{userMB.users}"
rowKey="#{user.id}"
selection="#{userMB.userSelected}"
selectionMode="single"
rows="10"
paginator="true"
filteredValue="#{userMB.filteredUser}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
>
<p:column headerText="Id" >
#{user.id}
</p:column>
<p:column headerText="Login" sortBy="#{user.login}" filterBy="#{user.login}">
#{user.login}
</p:column>
</p:dataTable>
Maybe its not problem, but I used #ViewScoped.
Hint: you can be interested in filterMatchMode="contains"
I hope I helped you.
this is a working PF3.5 datatable dont forget to wrap it inside an
<p:dataTable id="surveyTable" var="survey" value="#{surveyBean.surveys}" widgetVar="surveysTable"
emptyMessage="Keine Umfragen zu diesem Suchbegriff vorhanden" filteredValue="#{surveyBean.filteredSurveys}"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
Liste der Umfragen
<p:outputPanel>
<h:outputText value="Suchen:" />
<p:inputText id="globalFilter" onkeyup="surveysTable.filter()" style="margin-left:5px;width:150px" />
</p:outputPanel>
</f:facet>
<p:column id="idColumn" headerText="ID" filterBy="{survey.id}" filterMatchMode="contains">
<h:outputText value="#{survey.id}" />
</p:column>
<p:column id="titleColumn" filterBy="#{survey.title}" headerText="Bezeichnung" filterMatchMode="contains">
<h:outputText value="#{survey.title}" />
</p:column>
<p:column id="activeColumn" headerText="Aktiv" filterBy="#{survey.active}" filterOptions="#{surveyBean.surveyOptions}"
filterMatchMode="exact">
<h:outputText value="#{survey.active}" />
</p:column>
<p:column id="toggleColumn">
<p:rowToggler />
</p:column>
<p:rowExpansion>
<h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;"
styleClass=" ui-widget-content grid">
<f:facet name="header">
Details der Umfrage
</f:facet>
<h:outputText value="Bezeichnung:" />
<h:outputText id="model" value="#{survey.title}" />
<h:outputText value="Status:" />
<h:outputText id="year" value="#{survey.active}" />
<h:outputText value="ID:" />
<h:outputText value="#{survey.id}"/>
</h:panelGrid>
</p:rowExpansion>
</p:dataTable>
I have a datatable inside another datatable. The nested table I need to have a multiple selection checkboxes, a button to fire actionlistener and a p:rowToggler to show more data in row. The toggler and commandbutton works fine without the selection column in the table, but when I add this column the commandButton doesn't go to the backing bean, toggler on click doesn't work properly, and setSelected isn't called. Both throw a NP. I'm using 3.4.2 is this feature on newer releases only?
SEVERE: FullAjaxExceptionHandler: An exception occurred during processing JSF ajax request. Error page '/error.xhtml' will be shown.
java.lang.NullPointerException
Table
<p:dataTable id="gro" var="g" value="#{requestBean.main.childRequest}" styleClass="veaGrid"
paginator="true" rows="1" paginatorTemplate="{CurrentPageReport}" >
<p:column>
<p:ajaxStatus >
<f:facet name="start">
<p:graphicImage value="/resources/images/ajaxloadingbar.gif" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<p:dataTable id="group" var="g2" value="#{g.groups}" rowKey="#{g2.group_name}" selection="#{requestBean.selectedGroups}" >
<p:column selectionMode="multiple" style="width:2%" />
<p:column headerText="#{g.systemCd} - Groups" style="width:25%" >
#{g2.group_name}
</p:column>
<p:column style="width:2%">
View Users <p:rowToggler />
</p:column>
<p:rowExpansion>
<p:dataTable styleClass="veaGrid" var="g3" value="#{g2.group_members}" sortOrder="descending"
paginator="true" rows="10"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
filteredValue="#{requestBean.filteredMembers}">
<p:column filterBy="#{g3.first_name}">
<h:outputText value="#{g3.first_name}"/>
</p:column>
<p:column filterBy="#{g3.last_name}">
<h:outputText value="#{g3.last_name}"/>
</p:column>
<p:column filterBy="#{g3.signon}">
<h:outputText value="#{g3.signon}"/>
</p:column>
</p:dataTable>
</p:rowExpansion>
</p:dataTable>
<center>
<p:commandButton id="continue" value="Continue" actionListener="#{requestBean.saveGroups}"/>
</center>
</p:column>
</p:dataTable>
Found the problem.. I had the requestBean.selectedGroups set to
ArrayList<Group>
I changed the property to
Group[]
and now everything is functional again.