Package com.storedobject.ui.util
Class HtmlTemplate
java.lang.Object
com.vaadin.flow.component.Component
com.storedobject.ui.util.HtmlTemplate
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasStyle
,Serializable
- Direct Known Subclasses:
TemplateLayout
@Tag("div")
public abstract class HtmlTemplate
extends com.vaadin.flow.component.Component
Abstract base class for a component that is initialized based on the contents
of an HTML template. The HTML content is read to create a
server-side Element tree. For instance fields marked with @
Id
, an
element with the corresponding id attribute value is identified, upgraded to
a component of the type defined by the field and the component instance is
set as the field value. However, it is possible to custom-create the component instance by
overriding the createComponentForId(String)
or createComponentForId(String, String)
method.- Author:
- Leif Åstrand (Vaadin Ltd.). Enhanced by Syam.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
Callback for creating an input stream on demand.static interface
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new HTML template based on the content of theTextContent
that has the same name of this class.protected
Creates a new HTML template based on the content of theTextContent
provided.protected
HtmlTemplate
(String textContentName) Creates a new HTML template based on the content of theTextContent
provided.protected
HtmlTemplate
(String cacheKey, HtmlTemplate.StreamSupplier streamSupplier) Creates a new HTML template based on HTML read from an input stream.protected
HtmlTemplate
(String cacheKey, HtmlTemplate.StreamSupplier streamSupplier, HtmlTemplate.StyleSupplier styleSupplier) Creates a new HTML template based on HTML read from an input stream.protected
HtmlTemplate
(Supplier<String> contentSupplier) Creates a new HTML template based on the content provided by a supplier. -
Method Summary
Modifier and TypeMethodDescriptionvoid
build()
static void
protected com.vaadin.flow.component.Component
protected com.vaadin.flow.component.Component
createComponentForId
(String id, String tag) boolean
protected void
onAttach
(com.vaadin.flow.component.AttachEvent attachEvent) void
setComponentCreator
(HtmlTemplate.ComponentCreator componentCreator) void
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
HtmlTemplate
protected HtmlTemplate()Creates a new HTML template based on the content of theTextContent
that has the same name of this class. -
HtmlTemplate
Creates a new HTML template based on the content of theTextContent
provided.- Parameters:
tc
- Text content.
-
HtmlTemplate
Creates a new HTML template based on the content of theTextContent
provided.- Parameters:
textContentName
- Text content name.
-
HtmlTemplate
-
HtmlTemplate
Creates a new HTML template based on HTML read from an input stream.- Parameters:
cacheKey
- the key to use for potentially caching the result of reading and parsing the template, ornull
never cache the resultstreamSupplier
- an input stream supplier that will be used if caching isn't used or if there is a cache miss, notnull
-
HtmlTemplate
protected HtmlTemplate(String cacheKey, HtmlTemplate.StreamSupplier streamSupplier, HtmlTemplate.StyleSupplier styleSupplier) Creates a new HTML template based on HTML read from an input stream.- Parameters:
cacheKey
- the key to use for potentially caching the result of reading and parsing the template, ornull
never cache the resultstreamSupplier
- an input stream supplier that will be used if caching isn't used or if there is a cache miss, notnull
-
-
Method Details
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttach
in classcom.vaadin.flow.component.Component
-
build
public void build() -
isCreated
public boolean isCreated() -
setView
-
setComponentCreator
-
createComponentForId
-
createComponentForId
-
clearCache
public static void clearCache()
-