Opening an Edit Screen for the Current User

Hello,

My application has a Member Entity and a Member browser and edit screens. Each member is related to a system user. When the administrator login to the app, he has access to Member’s browser screen and can add or edit members.

I created a custom edit screen for members, and when a regular member login, he will have access to this custom edit screen, but not the member’s browser. So the idea is to open the custom edit screen with the member related to the current user.

My question is, how can I open the custom screen with the current user/member record?

Thank you,

Claudio

Hi Claudio
You may use the current user as follows:

userSessionSource.getUserSession().getUser()

And you may extend user Entity to ExtUser where use the default entity name to open when the user is logged in…

Hi,

i created an example of such requirement for you. You can check it out at github:

The README contains the information how it looks and works.

I hope this helps to understand what to do in order to load the “current member”.

Bye
Mario

2 Likes

Hello Mario,

Thank you, I ran your example and it worked perfectly.

I tried to do the same in my application but I think I’m losing some detail. I’m getting:

java.lang.ClassCastException: com.inoutech.yfams.web.member.CurrentMemberOpener cannot be cast to com.haulmont.cuba.gui.components.Window
at com.haulmont.cuba.gui.WindowManager.createWindow(WindowManager.java:674)

Thanks,

Claudio

Mario,

I got it. I was calling the wrong screen at:

wm.openEditor(wc.getWindowInfo(“yfams$Member.edit”), currentMember, WindowManager.OpenType.NEW_TAB);

Thanks a lot for the help!