Class PrintButton<T extends StoredObject>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,Serializable
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:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <O extends StoredObject>
PrintButton<O> create(ObjectEditor<O> objectEditor) Create a "print button" for the object editor.static <O extends StoredObject>
PrintButton<O> create(ObjectGrid<O> objectGrid) Create a "print button" for the object grid.static <O extends StoredObject>
PrintButton<O> Create a "print button" for the object supplier.Get the button corresponding to the label passed.protected ButtonMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Method Details
-
initContent
-
create
Create a "print button" for the object editor.- Parameters:
objectEditor- Object editor for which the button to be created.- Returns:
- Print button.
-
create
Create a "print button" for the object grid.- Parameters:
objectGrid- Object grid for which the button to be created.- Returns:
- Print button.
-
create
public static <O extends StoredObject> PrintButton<O> create(Class<O> objectClass, Supplier<O> objectSupplier) Create a "print button" for the object supplier.- Parameters:
objectClass- Object class of the object supplier.objectSupplier- Object supplier for which the button to be created.- Returns:
- Print button.
-
getButton
Get the button corresponding to the label passed. This could be used fromObjectEditor.enablePrintButtons(boolean)to selectively hide buttons.- Parameters:
label- Label of the button.- Returns:
- Button.
-
definitions
-