Hello! I have successfully extended User and all of its screens. The only problem I’m having is the following: on the ext-user-edit screen (user-edit’s child) there’s a substTable table, which shows substituted users. I am trying to add a column to this table (say, substitutedUser.lastName), but the datasource this table is working with does not fetch this field, as I can see in debug mode. It only fetches id and name (and maybe some other) fields that the parent screen works with. Any suggestions on how I could fix this?
Btw, the error I get when the screen is being loaded is the following:
IllegalStateException: Cannot get unfetched attribute [lastName] from detached object com.company.usertestproject.entity.UserExtension-60885987-1b61-4247-94c7-dff348347f93 [detached].
a full stacktrace:
java.lang.IllegalStateException: Cannot get unfetched attribute [lastName] from detached object com.company.usertestproject.entity.UserExtension-60885987-1b61-4247-94c7-dff348347f93 [detached].
at org.eclipse.persistence.internal.queries.EntityFetchGroup.onUnfetchedAttribute(EntityFetchGroup.java:98)
at com.haulmont.cuba.core.sys.persistence.CubaEntityFetchGroup.onUnfetchedAttribute(CubaEntityFetchGroup.java:61)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.processUnfetchedAttribute(EntityManagerImpl.java:2846)
at com.haulmont.chile.core.model.impl.AbstractInstance._persistence_checkFetched(AbstractInstance.java)
at com.haulmont.cuba.security.entity.User._persistence_get_lastName(User.java)
at com.haulmont.cuba.security.entity.User.getLastName(User.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.haulmont.chile.core.model.utils.MethodsCache.invokeGetter(MethodsCache.java:72)
at com.haulmont.chile.core.model.impl.AbstractInstance.getValue(AbstractInstance.java:102)
at com.haulmont.cuba.core.entity.BaseGenericIdEntity.getValue(BaseGenericIdEntity.java:149)
at com.haulmont.chile.core.model.utils.InstanceUtils.getValueEx(InstanceUtils.java:139)
at com.haulmont.cuba.web.gui.data.PropertyWrapper.getValue(PropertyWrapper.java:76)
at com.haulmont.cuba.web.gui.components.WebAbstractTable$TablePropertyWrapper.getValue(WebAbstractTable.java:2014)
at com.haulmont.cuba.web.gui.data.PropertyWrapper.getFormattedValue(PropertyWrapper.java:149)
at com.haulmont.cuba.web.gui.components.WebAbstractTable$TablePropertyWrapper.getFormattedValue(WebAbstractTable.java:2000)
at com.haulmont.cuba.web.toolkit.ui.CubaTable.formatPropertyValue(CubaTable.java:240)
at com.haulmont.cuba.web.toolkit.ui.CubaTable.getPropertyValue(CubaTable.java:200)
at com.vaadin.ui.Table.parseItemIdToCells(Table.java:2432)
at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:2282)
at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1780)
at com.vaadin.ui.Table.refreshRowCache(Table.java:2732)
at com.vaadin.ui.Table.containerItemSetChange(Table.java:4661)
at com.haulmont.cuba.web.gui.data.CollectionDsWrapper.fireItemSetChanged(CollectionDsWrapper.java:111)
at com.haulmont.cuba.web.gui.data.CollectionDsWrapper$ContainerDatasourceCollectionChangeListener.collectionChanged(CollectionDsWrapper.java:273)
at com.haulmont.cuba.gui.data.impl.WeakDsListenerAdapter.collectionChanged(WeakDsListenerAdapter.java:46)
at com.haulmont.bali.events.EventRouter.fireEvent(EventRouter.java:45)
at com.haulmont.cuba.gui.data.impl.AbstractCollectionDatasource.fireCollectionChanged(AbstractCollectionDatasource.java:370)
at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.afterRefresh(CollectionDatasourceImpl.java:183)
at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.refresh(CollectionDatasourceImpl.java:148)
at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.refresh(CollectionDatasourceImpl.java:104)
at com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl.setSuspended(CollectionDatasourceImpl.java:696)
at com.haulmont.cuba.gui.data.impl.DsContextImpl.resumeSuspended(DsContextImpl.java:83)
at com.haulmont.cuba.gui.WindowManager.afterShowWindow(WindowManager.java:968)
at com.haulmont.cuba.web.WebWindowManager.showWindow(WebWindowManager.java:402)
at com.haulmont.cuba.gui.WindowManager.openEditor(WindowManager.java:727)
at com.haulmont.cuba.web.WebWindowManager.openEditor(WebWindowManager.java:159)
at com.haulmont.cuba.gui.components.WindowDelegate.openEditor(WindowDelegate.java:250)
at com.haulmont.cuba.web.gui.WebWindow.openEditor(WebWindow.java:445)
at com.haulmont.cuba.gui.components.actions.EditAction.internalOpenEditor(EditAction.java:274)
at com.haulmont.cuba.gui.components.actions.EditAction.actionPerform(EditAction.java:223)
at com.haulmont.cuba.web.gui.components.WebAbstractTable.handleClickAction(WebAbstractTable.java:801)
at com.haulmont.cuba.web.gui.components.WebAbstractTable.lambda$initComponent$4fd149ee$1(WebAbstractTable.java:687)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:510)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:200)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:163)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:1037)
at com.vaadin.ui.Table.handleClickEvent(Table.java:3220)
at com.vaadin.ui.Table.changeVariables(Table.java:2997)
at com.haulmont.cuba.web.toolkit.ui.CubaTable.changeVariables(CubaTable.java:252)
at com.haulmont.cuba.web.toolkit.ui.CubaGroupTable.changeVariables(CubaGroupTable.java:144)
at com.vaadin.server.communication.ServerRpcHandler.changeVariables(ServerRpcHandler.java:623)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:470)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:413)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:274)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:90)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1422)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:385)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:278)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at com.haulmont.cuba.web.sys.CubaHttpFilter.handleNotFiltered(CubaHttpFilter.java:108)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:95)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Try to redefine the following view in your project:
<view class="com.haulmont.cuba.security.entity.UserSubstitution"
name="user.edit"
extends="user.edit">
<property name="substitutedUser">
<property name="login"/>
<property name="name"/>
<property name="lastName"/>
</property>
</view>
As you can see, I’ve added the lastName property to it.
Thank you very much, Konstantin! This worked.