public class ExportToolbar extends AbstractToolbar
IExportableColumn
s in the table
exported to formats supported by the IDataExporter
s configured.IDataExporter
,
IExportableColumn
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
ExportToolbar.DataExportResourceStreamWriter
An
IResourceStreamWriter which writes the exportable data from a table to an output stream. |
ENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING
Constructor and Description |
---|
ExportToolbar(DataTable<?,?> table)
Creates a new instance with the default message model.
|
ExportToolbar(DataTable<?,?> table,
IModel<String> fileNameModel)
Creates a new instance with the provided data table and file name model.
|
ExportToolbar(DataTable<?,?> table,
IModel<String> messageModel,
IModel<String> fileNameModel)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
ExportToolbar |
addDataExporter(IDataExporter exporter)
Adds a
IDataExporter to the list of data exporters to be used in this toolbar. |
protected void |
calculateVisibility()
This toolbar is only visible if there are rows in the data set and if there are exportable columns in the
data table and if there are data exporters added to the toolbar.
|
protected Component |
createExportLink(String componentId,
IDataExporter dataExporter)
Creates a new link to the exported data for the provided
IDataExporter . |
IModel<String> |
getFileNameModel()
Returns the model of the file name used for the exported data.
|
IModel<String> |
getMessageModel()
Returns the model of the export message displayed in the toolbar.
|
protected void |
onConfigure()
Called once per request on components before they are about to be rendered.
|
protected void |
onDetach()
Called to allow a component to detach resources after use.
|
protected void |
onInitialize()
This method is meant to be used as an alternative to initialize components.
|
ExportToolbar |
setFileNameModel(IModel<String> fileNameModel)
Sets the model of the file name used for the exported data.
|
ExportToolbar |
setMessageModel(IModel<String> messageModel)
Sets the models of the export message displayed in the toolbar.
|
getTable
getRegionMarkup, newMarkupSourcingStrategy
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onComponentTag, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dequeue, newDequeueContext
public ExportToolbar(DataTable<?,?> table)
table
- The data table this toolbar belongs to.public ExportToolbar(DataTable<?,?> table, IModel<String> fileNameModel)
table
- The table to which this toolbar belongs.fileNameModel
- The model of the file name. This should exclude the file extensions.public ExportToolbar(DataTable<?,?> table, IModel<String> messageModel, IModel<String> fileNameModel)
table
- The table to which this toolbar belongs.messageModel
- The model of the export message.fileNameModel
- The model of the file name. This should exclude the file extensions.public ExportToolbar setMessageModel(IModel<String> messageModel)
messageModel
- the models of the export message displayed in the toolbar.this
, for chaining.public ExportToolbar setFileNameModel(IModel<String> fileNameModel)
fileNameModel
- The model of the file name used for the exported data.this
, for chaining.public IModel<String> getFileNameModel()
public IModel<String> getMessageModel()
protected void onInitialize()
Page
thus providing the component with an atomic callback
when the component's environment is built out.
Overrides must call super#Component.onInitialize()
. Usually this should be the first thing an
override does, much like a constructor.
Parent containers are guaranteed to be initialized before their children
It is safe to use Component.getPage()
in this method
NOTE:The timing of this call is not precise, the contract is that it is called sometime
before Component.onBeforeRender()
.
onInitialize
in class MarkupContainer
protected Component createExportLink(String componentId, IDataExporter dataExporter)
IDataExporter
.componentId
- The component of the link.dataExporter
- The data exporter to use to export the data.IDataExporter
.protected void onConfigure()
Component
Overrides must call super.onConfigure()
, usually before any other code
NOTE: Component hierarchy should not be modified inside this method, instead it should be
done in Component.onBeforeRender()
NOTE: Why this method is preferrable to directly overriding Component.isVisible()
and
Component.isEnabled()
? Because those methods are called multiple times even for processing of
a single request. If they contain expensive logic they can slow down the response time of the
entire page. Further, overriding those methods directly on form components may lead to
inconsistent or unexpected state depending on when those methods are called in the form
processing workflow. It is a better practice to push changes to state rather than pull.
NOTE: If component's visibility or another property depends on another component you may call
other.configure()
followed by other.isVisible()
as mentioned in
Component.configure()
javadoc.
NOTE: Why should Component.onBeforeRender()
not be used for this? Because if a component's
visibility is controlled inside Component.onBeforeRender()
, once invisible the component will
never become visible again.
onConfigure
in class Component
protected void calculateVisibility()
protected void onDetach()
Component
onDetach
in class MarkupContainer
public ExportToolbar addDataExporter(IDataExporter exporter)
IDataExporter
to the list of data exporters to be used in this toolbar.exporter
- The IDataExporter
to add to the toolbar.this
, for chaining.Copyright © 2006–2021 Apache Software Foundation. All rights reserved.