DataExporter doesn't export DataTable column headerText - primefaces

I try to export datatable datas to excel file by dataexporter. DataExporter export datatable column headerTexts when i use primefaces 6.1. But I upgraded to version 12.0.0, dataexporter doesn't export datatable column headerTexts. I use all export header types. But both of them doens'nt work. I checked primefaces showcase page. It doesn't work at primefaces showcase page. I see "null" when i call getRow(0). Rows start at index 1. But I see first row is empty when i check exported excel file. How can i export headerTexts?
<p:column headerText="test" style="width:170px;"
filterBy="#{variable}" filterMatchMode="contains">
<h:outputText value="test" />
</p:column>
<p:column style="width:170px;"
filterBy="#{variable}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="test" />
</f:facet>
<h:outputText value="test" />
</p:column>

Issue: https://github.com/primefaces/primefaces/issues/9290
PR: https://github.com/primefaces/primefaces/pull/9291
Fixed in PF Elite 12.0.1 and Community 13.0.0

Related

DataTable - ContextMenu

Primefaces Migration-Guide 5.3 to 6.0:
ContextMenu: p:contextMenu must be placed AFTER the target component (e.g. datatable) in the xhtml now.
I tried exactly that, but it' not working. No Menu at all.
Placing ContextMenu before dataTable: Menu is showing. Additional output on browser console:
ContextMenu targets a widget which is not available yet. Please place the contextMenu after the target component. targetWidgetVar: widget_base_cars
My Webshpere Liberty log:
...org.primefaces.webapp.PostConstructApplicationEventListener I Running on PrimeFaces 7.0
Java:
java.version = 1.8.0_102
Stripped down to primefaces showcase
<h:body>
<h1>Context Menu</h1>
<h2>ContextMenu: p:contextMenu must be placed AFTER the target component</h2>
<h:form id="base" >
<p:dataTable id="cars" var="car" value="#{dtContextMenuView.cars}" rowKey="#{car.id}" >
<f:facet name="header">
List with #{dtContextMenuView.numberOfCars} Items
</f:facet>
<p:column headerText="Id">
<h:outputText value="#{car.id}" />
</p:column>
<p:column headerText="Year">
<h:outputText value="#{car.year}" />
</p:column>
<p:column headerText="Brand">
<h:outputText value="#{car.brand}" />
</p:column>
<p:column headerText="Color">
<h:outputText value="#{car.color}" />
</p:column>
</p:dataTable>
<p:contextMenu for="cars" >
<p:menuitem value="Hello" />
<p:menuitem value="World" />
</p:contextMenu>
<h2>but it fails</h2>
</h:form>
</h:body>
I expect the menu to show on right click.
Is it a bug, or am i the bug?
I reproduced this testing around with PF 5.3/6.0/7.0. I'm with you as long as your p:dataTable is not selectable:
The p:contextMenu appears on rightclick when added above the p:dataTable element in xhtml. When added below, no context menu appears at all. But tbh.: is a context menu useful on a datatable which does not allow selection?
When making it selectable by adding the attributes
selection="#{myBean.selectedValue}" selectionMode="singel"
it behaves like this:
p:contextMenu below p:dataTable as suggested by migration guide: On rightclick, the clicked row is selected and context menu appears on it.
p:contextMenu above p:dataTable: on rightclick, context menu appears either, but the row is not selected.
So if p:contextMenu is added above the table, selection does not work as expected which must be the reason for the migration guide telling "add it below!".
Btw: I did not get that warning in my JavaScript console during my tests, don't know why.

FilterBy using column doesn't work in primefaces 5.3

Here is the source code of my .xhtml file when the datatable appears i try to filter by id in olumn it doesn't work.
I have looked for the solution and i found that there is another mechanism in primefaces 5.3 that i don't understand please if you can help me. I'm newbie to primesfaces and JSF
Thank you
<p:column filterBy="#{student.id}" filterMatchMode="contains">
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{student.id}" />
</p:column>

How to change Primefaces Datatable filter position?

Right now by default PF Datatable showing filter position with header .Is it possible to show filter position on footer of the DataTable ?
I tried below code in Datatble Footer but not worked
<f:facet name="footer">
<p:column>
<f:facet name="filter">
<p:spinner onchange="PF('carsTable').filter()" styleClass="year-spinner">
<f:converter converterId="javax.faces.Integer" />
</p:spinner>
</f:facet>
</p:column>
<p:column>
<f:facet name="filter">
<p:spinner onchange="PF('carsTable').filter()" styleClass="year-spinner">
<f:converter converterId="javax.faces.Integer" />
</p:spinner>
</f:facet>
</p:column>
</f:facet>
No, not possible in this way. I see three options:
Use DOM manipulation to move the filters to the corresponding tags in the bottom. Do not forget to do this after each ajax call. And by hiding the filters in the header with css anyway, you prevent a 'jumpy' userinterface
Using OmniFaces' moveComponent showcase.omnifaces.org/components/moveComponent as proposed by #MathieuCastets
Change the source of the PrimeFaces dataTable and create your own component.

primefaces datatable is showing blank rows. Showing the same number of rows as the records in backed list

Thanks to all those who are responding to the problems of the developers.
I am facing some issue with primefaces 5.0 in datatable.
i am having one datatable with 14 records into that backed by list as usual. It was working fine till the time i added spring into my JSF application.
list backed in datatable is getting data from database though one method which is setting the values into the list(not filling data in getter method).
now when i am checking in getter of the list, it is having 14 records into the list. The problem is datatable is not showing the values for those records. It is showing blank rows for that. It is showing 14 blank records for that.
if i am trying to print the value of the records of list it is printing fine.
i tried to see the type of the records of the list that is also the desired type.
if i will try to print the perticular value of the field of the record of the list outside of the datatable that is also printing fine in xhtml page but it is not showing the same into the datatable.
i didn't change any sysntex as it was working fine before adding spring into it.
please help me for this. Thanks to all of you. I am showing the xhtml code below.
<p:dataTable id="datatable" var="variable" value="#{myClass.existingRecordList}" resizableColumns="true"
paginator="true" rows="10" editable="true" style="font-size:12px" paginatorAlwaysVisible="true"
paginatorPosition="top" rowIndexVar="rowIndex" rowsPerPageTemplate="5,10,15,20"
paginatorTemplate="Displaying {RowsPerPageDropdown} records / page {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {CurrentPageReport}"
currentPageReportTemplate="{startRecord} - {endRecord} of {totalRecords}" >
<p:columnGroup type="header" >
<p:row>
<p:column headerText="#" style="text-align:center;white-space:normal;width:25px"/>
<p:column headerText="Field1" style="text-align:center;white-space:normal;width:50px;vertical-align:bottom"
sortBy="#{variable.field1}" filterBy="#{variable.field1}" filterMatchMode="contains" rendered="#{otherClass.field1}" />
<p:column headerText="Field2" style="text-align:center;white-space:normal;width:50px;vertical-align:bottom"
sortBy="#{variable.field2}" filterBy="#{variable.field2}" filterMatchMode="contains" rendered="#{otherClass.field2}"/>
<p:column headerText="Field3" style="text-align:center;white-space:normal;width:50px;vertical-align:bottom"
sortBy="#{variable.field3}" filterBy="#{variable.field3}" filterMatchMode="contains" rendered="#{otherClass.field3}"/>
</p:row>
</p:columnGroup>
<p:column headerText="#" style="text-align:center;white-space:normal;width:20px" exportable="false">
<h:outputText value="#{rowIndex+1}" style="text-align:center"/> <!-- This is printing the value -->
</p:column>
<p:column headerText="Field1" style="text-align:center;" rendered="#{otherClass.field1}">
<h:outputText value="#{variable.field1}" style="text-align:center;white-space:normal"/><!-- This is not printing the value showing blank-->
</p:column>
<p:column headerText="Field2" style="text-align:center;" rendered="#{otherClass.field2}">
<h:outputText value="#{variable.field2}"/> <!-- This is not printing the value showing blank-->
</p:column>
<p:column headerText="Field3" style="text-align:center;" rendered="#{otherClass.field3}">
<h:outputText value="#{variable.field3}"/> <!-- This is not printing the value showing blank-->
</p:column>
</p:dataTable>
<h:outputText value="This is the value #{myClass.existingRecordList.get(0).field1}"></h:outputText> <!-- This is printing the value -->

Bug when editing date field in DataTable component

I've got a weird bug when editing a date field using a Calendar component inside of an editable DataTable. To explain, I'm going to need to show you some pictures.
First, here is the actual page I'm working from:
Now, let's change date 1 in the list to the 13th of February and click OK.
As you can see, the table changes, but the row takes on another row's data.
Other than in the GUI, the update's gone just fine, and if we reload the page the date has been updated in the database. This is what the table looks like after the page has been refreshed:
I've turned the code inside and out trying to get at this bug, and I'm starting to wonder if it's a bug in PrimeFaces itself. I've stepped through the entire workflow and have concluded that the backing ArrayList has the correct values at all times. I was thinking it may have had something to do with me sorting the list both when fetching it from the database and using the sortBy attribute of the DataTable. After disabling both however, the bug continues to manifest itself.
Here's my code for the page. Can anyone see anything I've done wrong? If so, you're my hero =)
<ui:composition template="/WEB-INF/standard-page-template.xhtml">
<ui:define name="title">Change Dates</ui:define>
<ui:define name="content">
<p:panel header="Change dates" style="width:760px">
<h:form>
<p:panel>
Just the search stuff here...
</p:panel>
<p:panel header="Search">
<h:panelGrid columns="1">
<p:dataTable id="listDatesTable" value="#{view.dateWrappers}" var="wrapper"
rowIndexVar="index" editable="true"
emptyMessage="Search for an ID above">
<p:ajax event="rowEdit" listener="#{changePublishDateView.changeDate}"/>
<p:column headerText="Dragning" width="90">
<h:outputText value="#{wrapper.id}"/>
</p:column>
<p:column headerText="Beskrivning" width="180">
<h:outputText value="#{wrapper.description}"/>
</p:column>
<p:column headerText="Distribution" width="100">
<h:outputText value="#{wrapper.id2}"/>
</p:column>
<p:column headerText="Publiceringstid" width="170" styleClass="#{view.duplicateDateInRow(wrapper)}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{wrapper.newhDate}">
<f:convertDateTime pattern="yyyy-MM-dd HH:mm"/>
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar
mindate="#{view.minDate}" stepMinute="30" minHour="8" maxHour="22"
pattern="yyyy-MM-dd HH:mm" value="#{wrapper.newDate}"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column width="50">
<p:rowEditor/>
</p:column>
</p:dataTable>
</h:panelGrid>
</p:panel>
</h:form>
</p:panel>
</ui:define>
As it turns out, this bug was due to the data in the individual rows being mostly identical.
Solution: Set a rowKey attribute on the datatable, to the date field. Now it works fine with or without sorting.
http://www.developer.am/primefaces/?page=RowKey