Data duplicated in datatable - jsf-2

I have a problem with a dataTable component using Tomahawk.
I want to make a datatable with subcolumns in some columns. Something like that:
This table only have 2 rows but its duplicated. Here is the code:
<t:dataTable id="tabla1" value="#{userControl.mc64cljobs_encolados}" var="clh">
<t:column id="col1" >
<f:facet name="header" >
<h:outputText styleClass="leftColumn" value="Options"/>
</f:facet>
<t:dataTable id="tabla2" value="#{userControl.mc64cljobs_encolados}" var="clh1">
<t:column id="col11">
<f:facet name="header" >
<h:outputText styleClass="leftColumn" value="Delete Work"/>
</f:facet>
<center>
<h:form>
<h:commandLink actionListener="#{userControl.eliminaTrabajo(clh1.codigo, 'multicore64clustalwtrabajos', userControl.user, userControl.password, clh1.fileSequences, '')}" value="Delete" />
</h:form>
</center>
</t:column>
<t:column id="col12">
<f:facet name="header" >
File Sequence Fasta
</f:facet>
<center>
<h:form>
<h:commandLink target="popupWindow" action="popupWindow" actionListener="#{userControl.setOpenFile(clh1.fileSequences)}" value="FILE 1" />
</h:form>
</center>
</t:column>
</t:dataTable>
</t:column>
<t:column id="col2" >
<f:facet name="header">
Pairwise alignment parameters
</f:facet>
<t:dataTable id="tabla3" value="#{userControl.mc64cljobs_encolados}" var="clh2" >
<t:column id="col21" >
<f:facet name="header" >
Gap Open Cost
</f:facet>
#{clh2.costeOpenGap}
</t:column>
<t:column id="col22">
<f:facet name="header">
Gap Extend Cost
</f:facet>
#{clh2.costeExtendGap}
</t:column>
<t:column id="col23">
<f:facet name="header" >
Cost Matrix
</f:facet>
#{clh2.scoringMatrix}
</t:column>
<t:column id="col24">
<f:facet name="header">
Cost Match/Replace
</f:facet>
#{clh2.costeMatchReplace}
</t:column>
</t:dataTable>
</t:column>
</h:dataTable>
What is my error in that code? What am I doing wrong?
Thank you so much!

Check this :
Why JSF calls getters multiple times
The getter can be called more than one times in jsf lifecycle

Related

Primefaces dataExporter footer issue for PDF

I have an issue with primefaces dataExporter not showing the footer of the dataTable when exporting to PDF. the header is exported but not the footer. it works fine with excel.
let's assume this is my dataTable
<p:dataTable id="tbl" var="product" value="#{bean.productList}">
<p:column>
<f:facet name="header">
<h:outputText value="Product" />
</f:facet>
<h:outputText value="#{product.name}" />
<f:facet name="footer">
<h:outputText value="Total" />
</f:facet>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Price" />
</f:facet>
<h:outputText value="#{product.price}" />
<f:facet name="footer">
<h:outputText value="#{bean.totalPrice}" />
</f:facet>
</p:column>
</p:dataTable>
<h:commandLink>
<p:graphicImage name="/demo/images/pdf.png" />
<p:dataExporter type="pdf" target="tbl" fileName="products" />
</h:commandLink>
when i export to PDF i get all my data fine except for the footer of the dataTable which contain the Total Price for the products.
What am i doing wrong ?
I'm using jsf 2.2 and primefaces 5.0

To uncheck all checkboxes of primefaces datatable on click of command button

I have a editable primefaces datatable with checkboxes as one of the column.Is there any way to uncheck all checked checkboxes on click of the command button.
My JSF page code snippet.
<h:form id="form">
<h:selectOneMenu id="workspaceOptions"
value="#{tableBean.selectedItem}" class="selectMenu">
<f:selectItem id="item1" itemLabel="Select" itemValue="#{null}" />
<f:selectItem id="item2" itemLabel="Assignments"
itemValue="assignment" />
<f:selectItem id="item3" itemLabel="Preview" itemValue="2" />
<f:selectItem id="item4" itemLabel="Print" itemValue="3" />
<f:selectItem id="item5" itemLabel="Refresh" itemValue="4" />
<f:selectItem id="item6" itemLabel="Clear checkmarks" itemValue="5" />
</h:selectOneMenu>
<h:commandButton value="GO" class="commandButton"
action="#{tableBean.submit}" />
<br />
<br />
<br />
<p:dataTable id="multiCars" var="car"
value="#{tableBean.mediumCarsModel}"
selection="#{tableBean.selectedCars}" editable="true" editMode="cell">
<f:facet name="header">
Checkbox Based Selection
</f:facet>
<p:ajax event="cellEdit" listener="#{tableBean.onCellEdit}"
update=":form:messages" />
<p:column headerText="Model" style="width:25%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.model}" />
</f:facet>
<f:facet name="input">
<p:inputText id="modelInput" value="#{car.model}"
style="width:96%" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Year" style="width:25%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.year}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.year}" style="width:96%" label="Year" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column selectionMode="multiple" style="width:2%;align:middle">
<f:facet name="header">
<h:outputText value="Select" />
</f:facet>
</p:column>
<p:column headerText="Manufacturer" style="width:25%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.manufacturer}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.manufacturer}" style="width:96%"
label="Year" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Color" style="width:25%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{car.color}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{car.color}" style="width:96%" label="Year" />
</f:facet>
</p:cellEditor>
</p:column>
<f:facet name="footer">
<p:commandButton id="multiViewButton" value="View"
icon="ui-icon-search" action="#{tableBean.getSelection}" />
</f:facet>
</p:dataTable>
</h:form>
I am ok with handling of this functionality at either client side or server side.
If you want to use a separate button, then you can call the Javascript method provided in the PrimeFaces documentation.
unselectAllRows() - Unselects all rows.
You would do this by providing your DataTable a widgetVar:
<p:dataTable id="multiCars" widgetVar="multiCars" ... >
then calling it from a commandButton of type "button" (for client-side processing):
<p:commandButton type="button" value="Deselect All"
onclick="multiCars.unselectAllRows();" />
That said, why don't you just use a select all/deselect all option provided by the framework? If you remove the header facet of your selectionmode="multiple" column, then it will display a checkbox allowing you to select or deselect all.
So instead of
<p:column selectionMode="multiple" style="width:2%;align:middle">
<f:facet name="header">
<h:outputText value="Select" />
</f:facet>
</p:column>
Use this (I removed the align:middle CSS attribute because it doesn't do anything):
<p:column selectionMode="multiple" style="width:2%" />

Primefaces dataTable sortBy a Date property

I'm using a p:dataTable to display a list of objects and I would like to order them by their Date property in a descending manner here is the code:
<h:form id="receivablesForm">
<p:dataTable id="receivablesTable" value="#{receivableManager.overdueReceivables}" var="receivable" rows="18" emptyMessage="#{msg['warning.noData']}" style="width: 585px;" sortBy="#{receivable.dueDate}" sortOrder="descending">
<p:column sortBy="#{receivable.invoice.number}" styleClass="fixedSizeColumnSmall">
<f:facet name="header">
<h:outputText value="#{msg['label.number']}" />
</f:facet>
<h:outputText value="#{receivable.invoice.number}-#{receivable.number}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg['label.clientName']}" />
</f:facet>
<h:outputText value="#{receivable.invoice.client.person.name}" />
</p:column>
<p:column styleClass="fixedSizeColumn">
<f:facet name="header">
<h:outputText value="#{msg['label.dueDate']}" />
</f:facet>
<h:outputText value="#{receivable.dueDate}" style="#{receivableManager.isOverdue(receivable) ? 'color: red' : ''}">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{msg['label.amount']}" />
</f:facet>
<h:outputText value="#{receivable.amount}">
<f:convertNumber type="currency" locale="pt_br" />
</h:outputText>
</p:column>
</p:dataTable>
</h:form>
However the objects are not being ordered at all. Is it possible to order by a Date property in a descending manner using the sortBy and sortOrder properties?

javax.Servlet.ServletException:cannot find component with identifier ":form:display"

Hi i need to create a accordian panel with a datatable inside the tab1 but i am geeting the following error:: javax.Servlet.ServletException:cannot find component with identifier ":form:display" ,can anyone plz help me out to resolve this error using primefaces.i need to work without using widgets.
view.xhtml
<h:form prependId="false" id="form">
<p:dataTable id="dataTable" var="car" value="#{tableBean.getList()}"
paginator="true" rows="10" selectionMode="single" selection="#{tableBean.selectedCar}" rowKey="#{car.model}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15">
<f:facet name="header">
Posted Jobs
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Model" />
</f:facet>
<h:outputText value="#{car.model}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Year" />
</f:facet>
<h:outputText value="#{car.year}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Manufacturer" />
</f:facet>
<h:outputText value="#{car.manufacturer}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Color" />
</f:facet>
<h:outputText value="#{car.color}" />
</p:column>
<f:facet name="footer">
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":form:display" oncomplete="carDialog.show()" actionListener="#{tableBean.add}"
/>
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Car Detail" widgetVar="carDialog" resizable="false"
width="200" showEffect="clip" hideEffect="fold">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Model:" />
<h:outputText value="#{tableBean.selectedCar.model}" />
<h:outputText value="Year:" />
<h:outputText value="#{tableBean.selectedCar.year}" />
<h:outputText value="Manufacturer:" />
<h:outputText value="#{tableBean.selectedCar.manufacturer}" />
<h:outputText value="Color:" />
<h:outputText value="#{tableBean.selectedCar.color}" />
</h:panelGrid>
</p:dialog>
</h:form>
AccordionPanel.xhtml
<h:head>
<title>Accordion Panel</title>
</h:head>
<h:body>
<h:form>
<p:accordionPanel>
<p:tab id="DataTable1" title="DataTable 1">
<ui:include src="view.xhtml" />
</p:tab>
<p:tab id="DataTable2" title="DataTable2">
</p:tab>
</p:accordionPanel>
</h:form>
</h:body>
</html>
You are getting this error because the update target of your commandButton can not be found using the specified component reference on the rendered html.
<p:commandButton id="viewButton" value="View" icon="ui-icon-search"
update=":form:display" oncomplete="carDialog.show()" actionListener="#tableBean.add}"/>
Try removing the update=":form:display" so that your page can render, check the generated component id of the display panelGrid with Firebug and use that id in your update target.
Since primefaces version 3.1 component referencing is aligned with the JSF Spec. See this link for further information UI Component findComponent()
update your (update=":form:display") attribute on commandButton to this :
update=":form:dialog:display"

filtering a rich:datatable with a rich:datascroller on richfaces 4

I am using richfaces 4, and i have a rich:datatable with a rich:datascroller and a column with a filter following the examples at the richfaces 4 showcase, but here's the thing, once i filter the table and the datascroller updates(ie. if at first the datascrolloer has 10 pages and after the filter have 2 pages) if I click on the next page or any of the boundary controls it suppose to go to the next page of the filtered table but instead the table resets to its original state(with out the filter expression)
here is my code:
<rich:dataTable id="mytbl" value="#{MyBean.mylist}" rows="10"
var="emp"
reRender="ds"
iterationStatusVar="it">
<f:facet name="noData">
no data found
</f:facet>
<rich:column filterValue="#{MyBean.id_filter}"
filterExpression="#{fn:containsIgnoreCase(emp.id,MyBean.id_filter)}">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="id"/>
<h:inputText value="#{MyBean.id_filter}">
<a4j:ajax event="change" render="mytbl" execute="#this"
onbegin="#{rich:component('wait_popup')}.show()"
oncomplete="#{rich:component('wait_popup')}.hide()"/>
</h:inputText>
</h:panelGroup>
</f:facet>
<h:outputText value="#{emp.id}"/>
</rich:column>
<rich:column>
<f:facet name="header">
<h:outputText value="value" />
</f:facet>
<h:outputText value="#{emp.value}">
<f:convertNumber pattern="$#,###.00"/>
</h:outputText>
</rich:column>
<f:facet name="footer">
<rich:dataScroller maxPages="10" id="ds" render="#this" />
</f:facet>
</rich:dataTable>
Probably MyBean was not view scoped.

Resources