Make fields on edit screen editable depending on from where the screen is opened

I have an edit screen that can be opened from a couple of places in my application. What is the best way in Cuba to make fields editable depending on from where they are launched?

Hi
You can send specific value of the parameters when you call from the menu, thus depending on the value you get in edit screen you can achieve what you want to.

Mortoza

Hi,

You can specify parameters for an opening screen by passing them to the openEditor() method, for instance:

openEditor("windowAlias", enitity, WindowManager.OpenType.THIS_TAB,
        ParamsMap.of("paramName", "paramValue"));

Then, you can obtain passed parameters either in the init method:

@Override
public void init(Map<String, Object> params) {
    SomeType paramValue = params.get("paramName");
}

or inject parameters passed in a map to the init() method into the controller using @WindowParam annotation:

@WindowParam(name = "paramName")
private SomeType paramValue;

Regards,
Gleb

Thanks Gleb.

This worked, however the create and edit buttons that call openEditor are active all the time now, not just when the screen is in “edit” mode. Do you know how I can make the buttons behave like when they use use the default actions?

Hi,

Could you attach your code, so that I will be able to investigate the problem?

Regards,
Gleb

Hi Gleb,

I redesigned my app and data model a bit and solved the issue another way, so I don’t have the old code to post. Thanks for your help though; it got me on a better track.