Class AttachmentDetailView
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<T>
io.jmix.flowui.view.View<io.jmix.flowui.component.layout.ViewLayout>
io.jmix.flowui.view.StandardView
io.jmix.flowui.view.StandardDetailView<Attachment>
de.bytestore.hostinger.view.attachment.AttachmentDetailView
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasStyle,com.vaadin.flow.router.AfterNavigationObserver,com.vaadin.flow.router.BeforeEnterObserver,com.vaadin.flow.router.BeforeLeaveObserver,com.vaadin.flow.router.HasDynamicTitle,com.vaadin.flow.router.internal.AfterNavigationHandler,com.vaadin.flow.router.internal.BeforeEnterHandler,com.vaadin.flow.router.internal.BeforeLeaveHandler,io.jmix.flowui.fragment.FragmentOwner,io.jmix.flowui.view.ChangeTracker,io.jmix.flowui.view.DetailView<Attachment>,io.jmix.flowui.view.HasEditedEntity<Attachment>,io.jmix.flowui.view.ReadOnlyAwareView,io.jmix.flowui.view.ReadOnlyTracker,io.jmix.flowui.view.SupportEntityLock<Attachment>,Serializable
@Route(value="attachments/:id",
layout=MainView.class)
@ViewController("host_Attachment.detail")
@ViewDescriptor("attachment-detail-view.xml")
public class AttachmentDetailView
extends io.jmix.flowui.view.StandardDetailView<Attachment>
The
AttachmentDetailView class is a standard detail view for managing attachments
in the application. It extends the StandardDetailView class specialized for the
Attachment entity type. The view allows uploading files, displaying previews,
and adapting the UI depending on the file type (e.g., image, PDF, or code file).
This class utilizes various UI components for handling and displaying attachment data:
- JmixImage: Displays image previews.
- CodeEditor: Displays text/code content for textual or code-based files.
- IFrame: Renders PDF previews.
- FileStorageUploadField: Allows file uploads.
Additionally, it integrates services such as FileStorage and FileService
to handle file-related operations.
Annotations:
- @Route: Defines the route path for the view.
- @ViewController: Specifies the controller name for defining the view logic.
- @ViewDescriptor: Provides the XML descriptor for the view.
- @EditedEntityContainer: Links the view to the data container for editing entities.
Event subscriptions and methods:
- onFileUploadComponentValueChange(AbstractField.ComponentValueChangeEvent):
Handles changes in the file upload field and updates the corresponding file preview.
- onInitEntity(InitEntityEvent): Invoked during entity initialization for additional setup.
- handleChange(): Updates the UI previews based on the type of file uploaded.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.flowui.view.StandardDetailView
io.jmix.flowui.view.StandardDetailView.AfterSaveEvent, io.jmix.flowui.view.StandardDetailView.BeforeSaveEvent, io.jmix.flowui.view.StandardDetailView.InitEntityEvent<E extends Object>, io.jmix.flowui.view.StandardDetailView.SetupLockEvent, io.jmix.flowui.view.StandardDetailView.ValidationEventNested classes/interfaces inherited from class io.jmix.flowui.view.View
io.jmix.flowui.view.View.AfterCloseEvent, io.jmix.flowui.view.View.BeforeCloseEvent, io.jmix.flowui.view.View.BeforeShowEvent, io.jmix.flowui.view.View.InitEvent, io.jmix.flowui.view.View.PostReadyEvent, io.jmix.flowui.view.View.QueryParametersChangeEvent, io.jmix.flowui.view.View.ReadyEvent, io.jmix.flowui.view.View.RestoreComponentsStateEventNested classes/interfaces inherited from interface io.jmix.flowui.view.ReadOnlyTracker
io.jmix.flowui.view.ReadOnlyTracker.ReadOnlyChangeEvent -
Field Summary
Fields inherited from class io.jmix.flowui.view.StandardDetailView
DEFAULT_ROUTE_PARAM, LOCKED_BEFORE_REFRESH_ATTR_NAME, MODE_PARAM, MODE_READONLY, NEW_ENTITY_ID, READ_ONLY_BEFORE_REFRESH_ATTR_NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonFileUploadComponentValueChange(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<io.jmix.flowui.component.upload.FileStorageUploadField, ?> event) Handles the value change event for the file upload component.voidonInit(io.jmix.flowui.view.View.InitEvent event) voidonInitEntity(io.jmix.flowui.view.StandardDetailView.InitEntityEvent<Attachment> event) Handles the initialization of a new or an existing `Attachment` entity.Methods inherited from class io.jmix.flowui.view.StandardDetailView
addReadOnlyStateChangeListener, beforeEnter, clearChanges, closeWithDiscard, closeWithSave, getEditedEntity, getEditedEntityOrNull, getLockStatus, hasUnsavedChanges, isCrossFieldValidationEnabled, isReadOnly, isReloadSaved, isShowSaveNotification, isShowValidationErrors, save, setCrossFieldValidationEnabled, setEntityToEdit, setReadOnly, setReloadSaved, setShowSaveNotification, setShowValidationErrorsMethods inherited from class io.jmix.flowui.view.View
afterNavigation, beforeLeave, close, close, closeWithDefaultAction, getId, getPageTitle, isPreventBrowserTabClosing, setId, setPageTitle, setPreventBrowserTabClosingMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
findAncestor, from, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, isAttached, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, setVisibleMethods inherited from class java.lang.Object
equals, 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
-
Constructor Details
-
AttachmentDetailView
public AttachmentDetailView()
-
-
Method Details
-
onInit
@Subscribe public void onInit(io.jmix.flowui.view.View.InitEvent event) -
onFileUploadComponentValueChange
@Subscribe("fileUpload") public void onFileUploadComponentValueChange(com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<io.jmix.flowui.component.upload.FileStorageUploadField, ?> event) Handles the value change event for the file upload component. This method is triggered when the value of the associated file upload field changes. It processes the newly uploaded file, updates the preview components, and adapts the UI depending on the file type (e.g., image, PDF, or code file).- Parameters:
event- the event object containing information about the value change, including the source component and the new value of the file upload field
-
onInitEntity
@Subscribe public void onInitEntity(io.jmix.flowui.view.StandardDetailView.InitEntityEvent<Attachment> event) Handles the initialization of a new or an existing `Attachment` entity. This method is triggered during the entity's initialization phase. It checks whether the entity is newly created or already existing. If the entity is not new, it disables the file upload component. Additionally, it invokes a method to process and adjust the UI based on the current file associated with the entity.- Parameters:
event- the initialization event containing the `Attachment` entity
-