Class PrintButton<T extends StoredObject>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<Button>
com.storedobject.ui.PrintButton<T>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

public final class PrintButton<T extends StoredObject> extends com.vaadin.flow.component.Composite<Button>
A "print button" is created automatically by ObjectEditors and ObjectBrowsers if one or more PrintLogicDefinitions exist for the StoredObject class. The "print button" may be a single button if there is only one PrintLogicDefinition defined, or it can contain multiple buttons.

The most common use-case of PrintButton is to define logic for printing. For defining such logic, either the PDFObjectReport or the ODTObjectReport may be extended. If the ODTObjectReport is extended, the ODT template may be specified in the PrintLogicDefinition.

Rather than writing a custom ODTObjectReport, you could extend the ObjectFiller class and such an instance is also supported. It should have a default no-arguments constructor. This is the recommended approach when a template-based output is desired.

The "printing logic" that is defined in the PrintLogicDefinition should have a constructor that takes a Device and a StoredObject instance as its parameters. (Have a look at the constructors - PDFObjectReport(Device, StoredObject) and ODTObjectReport(Device, StoredObject)

Usage as a generic button: PrintButton may be used to invoke non-printing logic too by defining any generic logic in the PrintLogicDefinition. The logic must implement Runnable and must have a constructor that takes a Device and a StoredObject instance as its parameters.

Yet another feature is to define a class extending ObjectLogicButton where the desired logic is implemented in the ObjectLogicButton.accept(StoredObject, Object) method.

In ObjectEditor, by default, the PrintButton will be hidden if the object instance is null. However, you can control this behavior and control the visibility of it or its individual buttons by overriding the ObjectEditor.enablePrintButtons(boolean) method.

Author:
Syam
See Also: