Edit screen validation

Hi,
Below is the use case required.

  1. user clicks Edit button in the browse screen, the edit screen opens
  2. Edit Screen contains few tabs (lets say 5 tabs) , based on one specific field from browse screen I want to hide/show few tabs in edit screen.

Thanks,
Saurabh

Hi,

You can create multiple editor screens and open one of them depending on the passed parameter. It is a common case, and you can get some ideas from lots of similar questions here:

https://www.cuba-platform.com/discuss/t/create-related-entity-from-parent-browse-screen/3843

https://www.cuba-platform.com/discuss/t/how-to-pass-string-variable-as-parameter-from-one-screen-to-another/2767

https://www.cuba-platform.com/discuss/t/how-to-present-different-editor-page-based-off-of-logic/2119

https://www.cuba-platform.com/discuss/t/make-fields-on-edit-screen-editable-depending-on-from-where-the-screen-is-opened/3341

https://www.cuba-platform.com/discuss/t/multiple-editors-for-one-entity/2102

https://www.cuba-platform.com/discuss/t/passing-variable-to-the-next-screen/1107

https://www.cuba-platform.com/discuss/t/setting-editor-values/1648

Also, if need only to hide/show tabs, use the setVisible() method for the tabs of the TabSheet.

For example:

public class PersonBrowse extends AbstractLookup {
    @Named("personsTable.edit")
    private EditAction personsTableEdit;
    @Inject
    private CheckBox hideTabs;

    @Override
    public void init(Map<String, Object> params) {
        personsTableEdit.setWindowParamsSupplier(()-> ParamsMap.of("hide", hideTabs.isChecked()));
        hideTabs.addValueChangeListener(e ->
                personsTableEdit.setWindowParamsSupplier(() ->
                        ParamsMap.of("hide", hideTabs.isChecked())));
    }
}
public class PersonEdit extends AbstractEditor<Person> {
    @Inject
    private TabSheet tabSheet;
    @WindowParam(name = "hide", required = true)
    private boolean hideTabs;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);
        hideTabs = (boolean) params.get("hide");
        tabSheet.getTab("addressTab").setVisible(hideTabs);
        tabSheet.getTab("phoneTab").setVisible(hideTabs);
    }
}
1 Like

Thanks very much . it worked