Package com.storedobject.vaadin
Class AbstractResourcedComponent
java.lang.Object
com.vaadin.flow.component.Component
com.storedobject.vaadin.AbstractResourcedComponent
- All Implemented Interfaces:
HasSize,ResourcedComponent,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
- Direct Known Subclasses:
ModelViewer,PDFViewer
public abstract class AbstractResourcedComponent
extends com.vaadin.flow.component.Component
implements ResourcedComponent, HasSize
Abstract "resourced component" that knows how to register/unregister the resource during attach/detach events.
By default, it will set the "display" style to "flex" and size to "full". Inherited classes may override this if
required.
- Author:
- Syam
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.AbstractResourcedComponent(com.vaadin.flow.server.AbstractStreamResource streamResource) Constructor with a stream resource to view.AbstractResourcedComponent(String fileURI) Constructor with a file to view. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the current content.protected abstract StringGet the name of the URI attribute.protected voidinit()This will be invoked by the constructor for initial set up.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDetach(com.vaadin.flow.component.DetachEvent detachEvent) voidsetSource(com.vaadin.flow.server.AbstractStreamResource streamResource) Set the file to view from aStreamResource.voidSet the file to view.protected voidSet the URI attribute for the source.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, 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.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
AbstractResourcedComponent
public AbstractResourcedComponent()Default constructor. -
AbstractResourcedComponent
Constructor with a file to view.- Parameters:
fileURI- URI of the file to view
-
AbstractResourcedComponent
public AbstractResourcedComponent(com.vaadin.flow.server.AbstractStreamResource streamResource) Constructor with a stream resource to view.- Parameters:
streamResource- Stream resource
-
-
Method Details
-
init
protected void init()This will be invoked by the constructor for initial set up. The default implementation sets the "display" style to "flex" and size to "full". I also sets a unique "id" attribute. -
setSource
Set the file to view.- Parameters:
fileURL- URL of the file to view
-
getURIAttributeName
Get the name of the URI attribute. The default value returned is "src".- Returns:
- URI attribute name.
-
setURI
-
setSource
public void setSource(com.vaadin.flow.server.AbstractStreamResource streamResource) Set the file to view from aStreamResource.- Specified by:
setSourcein interfaceResourcedComponent- Parameters:
streamResource- Stream source
-
clear
public void clear()Clear the current content. -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onDetach
protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent) - Overrides:
onDetachin classcom.vaadin.flow.component.Component
-