Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Show adequate error if fileStorageUploadField is bound to wrong attribute type #314

Closed
alexbudarov opened this issue Feb 16, 2021 · 1 comment
Assignees
Milestone

Comments

@alexbudarov
Copy link
Contributor

// wrong type
    @PropertyDatatype("uri")
    @JmixProperty
    @Column(name = "QUESTION_PICTURE")
    private URI questionPicture;

                <fileStorageUpload id="questionPictureField" property="questionPicture"
                                   permittedExtensions=".png,.jpg,.svg" fileStoragePutMode="IMMEDIATE"/>

In runtime opening such screen fails with unexpected error:
image

Caused by: java.lang.ClassCastException: class java.net.URI cannot be cast to class io.jmix.core.FileRef (java.net.URI is in module java.base of loader 'bootstrap'; io.jmix.core.FileRef is in unnamed module of loader 'app')
	at io.jmix.ui.component.impl.FileStorageUploadFieldImpl.convertToPresentation(FileStorageUploadFieldImpl.java:31) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.impl.AbstractValueComponent.setValue(AbstractValueComponent.java:103) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.data.value.ValueBinder$ValueBindingImpl.valueSourceStateChanged(ValueBinder.java:269) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170) ~[jmix-core-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.data.value.ContainerValueSource.setState(ContainerValueSource.java:212) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.data.value.ContainerValueSource.containerItemChanged(ContainerValueSource.java:219) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170) ~[jmix-core-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.model.impl.InstanceContainerImpl.fireItemChanged(InstanceContainerImpl.java:167) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.model.impl.InstanceContainerImpl.setItem(InstanceContainerImpl.java:100) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.model.impl.InstanceLoaderImpl.load(InstanceLoaderImpl.java:108) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.dataloadcoordinator.OnFrameOwnerEventLoadTrigger.load(OnFrameOwnerEventLoadTrigger.java:48) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.dataloadcoordinator.OnFrameOwnerEventLoadTrigger.lambda$new$0(OnFrameOwnerEventLoadTrigger.java:39) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170) ~[jmix-core-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.screen.Screen.fireEvent(Screen.java:124) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.screen.UiControllerUtils.fireEvent(UiControllerUtils.java:58) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.sys.ScreensImpl.fireScreenBeforeShowEvent(ScreensImpl.java:1341) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.sys.ScreensImpl.show(ScreensImpl.java:353) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.screen.Screen.show(Screen.java:306) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.action.list.EditAction.execute(EditAction.java:366) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.action.list.EditAction.actionPerform(EditAction.java:313) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]
	at io.jmix.ui.component.impl.AbstractTable.handleClickAction(AbstractTable.java:1381) ~[jmix-ui-0.3.0-SNAPSHOT.jar:na]

Expected:
Some nice DevelopmentException explaning that fileStorageUploadField doesn't support URI attribute type.

@glebshalyganov glebshalyganov self-assigned this Feb 16, 2021
@knstvk knstvk added this to the 1.0.0 milestone Mar 18, 2021
@knstvk knstvk modified the milestones: 1.0.0, 1.0.x Jun 23, 2021
@knstvk knstvk modified the milestones: 1.0.x, 1.1.0 Jul 20, 2021
@lovtsovaik lovtsovaik assigned reznikova21 and unassigned lovtsovaik Oct 18, 2021
@reznikova21
Copy link

Jmix version: 1.1.0-SNAPSHOT - verified

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants