How Actions Work
Actions are a core concept in DynamiaTools. They let you encapsulate reusable behavior in different parts of the application: buttons, menus, table cells, toolbars, and more.
Defining an Action
Section titled “Defining an Action”You typically define a class that extends AbstractCrudAction or implements Action.
package demo.actions;
import tools.dynamia.actions.AbstractAction;import tools.dynamia.actions.ActionEvent;import tools.dynamia.actions.InstallAction;
@InstallActionpublic class PrintHelloAction extends AbstractCrudAction {
public PrintHelloAction() { setId("PrintHelloAction"); setName("Say Hello"); setApplicableClass(Person.class); // Optional: limit this action to Person entities }
@Override public void actionPerformed(CrudActionEvent evt) { System.out.println("Hello from Dynamia Action"); }}Registering and using the Action
Section titled “Registering and using the Action”With @InstallAction, Dynamia automatically discovers it in the Spring context.
Recommendations
Section titled “Recommendations”- Use stable action names (
setName) to reference them from YAML. - Move business logic to Spring services and invoke them from the action.
- Avoid overly large actions; split by responsibility.
- Add context validations when the action depends on a selected row or entity.