Skip to content

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.

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;
@InstallAction
public 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");
}
}

With @InstallAction, Dynamia automatically discovers it in the Spring context.

  • 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.