OverviewSince 3.0 The data exporter is a utility component that exports data from a datatable and serves it as a file in Excel, PDF, XML or CSV format. This component renders an HTML button element. More components and HTML elements can be nested inside this tag to give a different look and feel to the button. When the button is clicked, a file is generated with the requested data, and a new JSF Resource is created to serve that file. The URL to that Resource is then sent to the client, which automatically loads the file on the same page, without navigating away from it and without disturbing its state.
Getting StartedThe data exporter has three required attributes: target, the id of the table to export; type the file format, and fileName the name of the file (not including its extension). The following is an example of the basic usage. <ace:dataExporter type="csv" target="myTable" fileName="tableData"/> <ace:dataTable id="myTable" value="#{bean.items}" var="item"> <ace:column headerText="Column One"> <h:outputText value="#{item.propertyA}"/> </ace:column> <ace:column headerText="Column Two"> <h:outputText value="#{item.propertyB}"/> </ace:column> </ace:dataTable> If one wishes to prevent certain data to be exported in the file, one can add the <ace:excludeFromExport /> tag inside the component one wants to avoid exporting. If this tag is placed inside <ace:column>, <ace:row>, or <ace:columnGroup> it will prevent the entire column, row or column group from being exported. The following is an example of <ace:excludeFromExport />. <ace:dataExporter type="csv" target="myTable" fileName="tableData"/> <ace:dataTable id="myTable" value="#{bean.items}" var="item"> <ace:column headerText="Column One"> <ace:excludeFromExport /> <h:outputText value="#{item.propertyA}"/> </ace:column> <ace:column headerText="Column Two"> <h:outputText value="#{item.propertyB}"/> <h:outputText value="#{item.propertyC}"> <ace:excludeFromExport /> </h:outputText> </ace:column> </ace:dataTable> If a table is using stacked columns, it won't affect the results of the exporting action. The data exporter is unaware of stacked columns. Attributes
The pageOnly attribute exports only the current page being displayed in the table, when using pagination. The excludeColumns attribute accepts a comma-separated list of column indexes (zero-relative) to be excluded from the exporting. This is an additional method of excluding columns to the <ace:excludeFromExporting> tag described above. It can be modified dynamically. The userColumnOrder attribute is used to specify whether the columns should be exported according to the order established by the user in the client or according to the order in which the columns appear in the facelet. In the case of xls and pdf formats, one can use the preProcessor and postProcessor attributes to specify a method that will be invoked before or after the exporting, so that a developer can modify the document being delivered. The method specified must accept an argument of type com.lowagie.text.Document in the case of the pdf format, and an argument of type org.apache.poi.ss.usermodel.Workbook in the case of the xls format. The encoding attribute is used to specify the character encoding to use. The default value is UTF-8. The includeHeaders and includeFooters boolean attributes are used to specify whether the column headers and column footers are included in the exported file, respectively. If the selectedRowsOnly attribute is set to true, only the selected rows in the table will be included in the exported file. This doesn't work in conjunction with the pageOnly attribute. All selected rows in the entire table in all pages will be included in the exported file. The style and styleClass attributes are passed thru to the style and class attributes of the root HTML button. Client Behavior Events
JavaScript APIsICEfaces 3.xThe client side component object is exposed through the global variable name specified in the widgetVar attribute. ICEfaces 4+The "widgetVar" attribute on the ACE components has been removed in ICEfaces 4 and in its place a new "ice.ace.instance()" client JavaScript object lookup API has been introduced. The reason for this change is to enable lazy-initialization of the ACE component JavaScript objects to improve runtime performance and reduce browser memory use. var widget = ice.ace.instance('frm:componentId);
Keyboard and ARIA SupportThe following ARIA roles are supported: button. CSS ClassesThe following markup represents the basic HTML structure of the component and the CSS classes it uses. <button class="[user defined classes] ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="[user defined styles]"> <span class="ui-button-text"> <span>Label</span> </span> </button> Known IssuesNone. Other Notes
|
DataExporter
© Copyright 2021 ICEsoft Technologies Canada Corp.