In the legacy version of the platform we could select the OpenType of the Editor from the table event designer without writing any code but I don’t see it anymore.
Do we need to code it under @Subscribe in the controller? Thanks for guiding to the right process CUBA being a RAD tool!
The difference is, in V6x only selection of openMode in the screen builder used to do all it needs. Now the lines of codes to open the screen making the platform moving away a bit from a RAD tool and this is only an example (there are many more such example I am coming across). I hope this is not how it is planned but matter of time to get those RAD functionalities back in V7 soon.
The third possible approach is to implement custom Create/Edit actions that can be used independently of the standard ones.
Take a look at the demo project that illustrates the above dialog-actions.zip (81.7 KB).
DialogCreateAction and DialogEditAction are custom actions and both are used in the product-browse.xml:
@ActionType(DialogCreateAction.ID)
public class DialogCreateAction extends CreateAction {
public static final String ID = "create_dialog";
public DialogCreateAction() {
this(ID);
}
public DialogCreateAction(String id) {
super(id);
}
@SuppressWarnings("unchecked")
@Override
public void actionPerform(Component component) {
// if standard behaviour
if (!hasSubscriptions(ActionPerformedEvent.class)) {
Screen editor = screenBuilders.editor(target)
.newEntity()
.withOpenMode(OpenMode.DIALOG)
.build();
editor.show();
} else {
super.actionPerform(component);
}
}
}
@ActionType(DialogEditAction.ID)
public class DialogEditAction extends EditAction {
public static final String ID = "edit_dialog";
public DialogEditAction() {
super(ID);
}
public DialogEditAction(String id) {
super(id);
}
@SuppressWarnings("unchecked")
@Override
public void actionPerform(Component component) {
// if standard behaviour
if (!hasSubscriptions(ActionPerformedEvent.class)) {
Entity editedEntity = target.getSingleSelected();
Screen editor = screenBuilders.editor(target)
.editEntity(editedEntity)
.withOpenMode(OpenMode.DIALOG)
.build();
editor.show();
} else {
super.actionPerform(component);
}
}
}