How can Entity Edit screen automatically choose create or edit mode?

I have a persisted entity that will only have 0 or 1 row. I would like to skip the browse screen and allow the user to go straight to the edit screen. However, if there is no record yet it should start in create mode. If there is 1 record, then it should start in edit mode with the record loaded.

I looked for ways to override the init() method, but found no way to change the create/edit mode of the screen. WindowManager.OpenMode and .OpenType looked promising, but appear to mean the same thing?


you can do by putting some code between the open of the screen and the editor. I attached an example that uses a class “SettingsOpener” is called from the main menu and opens the settings editor either with a new instance of the “Settings” entity or with the already existing one.

The class looks like this:

public class SettingsOpener implements Runnable {
    public void run() {
        Settings settings = loadOrCreateSettings();

    private Settings loadOrCreateSettings() {
        Metadata metadata = AppBeans.get(Metadata.class);
        Settings settings = tryLoadSettings();
        if (settings == null) {
            settings = metadata.create(Settings.class);
        return settings;

    private Settings tryLoadSettings() {
        DataManager dataManager = AppBeans.get(DataManager.class);
        LoadContext<Settings> loadContext = LoadContext.create(Settings.class)
                .setQuery(LoadContext.createQuery("select e from ceses$Settings e").setMaxResults(1)

        return dataManager.load(loadContext);

    private void openSettingsScreen(Settings settings) {
        WindowManager wm = App.getInstance().getWindowManager();
        WindowConfig wc = AppBeans.get(WindowConfig.NAME);
        wm.openEditor(wc.getWindowInfo("ceses$Settings.edit"), settings, WindowManager.OpenType.NEW_TAB);

Mario (29.9K)

Thank you Mario! That works perfectly and your example made it very easy.