How to get the Instance of the current editing entity in EntityCombinedScreen

Dear Sir,
I am implementing the user avatar in the EntityCombinedScreen. By the way i am using an example project: Sample User Avatar.

The sample was implemented in Editor Screen and working as expected, But i am using the EntityCombinedScreen. When execute the following line, i am getting error.

((Users) getItem()).setImage(committedImage);

The getItem() method is not available for EntityCombinedScreen. So, please help me how to get the instance of the current editing entity in EntityCombinedScreen.

Hi,

You can easily get it from the datasource.
Use:

public class ClientBrowse extends EntityCombinedScreen {
    @Inject
    private Datasource<Client> clientDs;
    
    public void onClick() {
        clientDs.getItem();
    }
}

Just find the <datasource> in your XML and inject it by Id.

I changed the code like the below…
from: ((Users) getItem()).setImage(committedImage);
to: ((Users) clientDs.getItem()).setImage(committedImage);

Now i’m getting the following exception:
IllegalStateException: Cannot get unfetched attribute [image] from detached object

Please help me resolving this…

Hi…
I resolved the error:

IllegalStateException: Cannot get unfetched attribute [image] from detached object

by adding the image attribute in the view …

Thank you…Yuriy