Mendix Rapid Developer study materials
Mendix Rapid Developer study resources

Mendix Rapid Developer: XPath, Validation, and Events

Mendix Rapid Developer · Work through your exam, one topic at a time.

All guide sections

XPath, Validation, and Events

This domain tests three connected areas: writing XPath constraints correctly, enforcing validation, and hooking entity events with microflows.

XPath essentials

XPath appears in retrieve activities and in entity access constraints. Attribute tests look like [Status = 'Open'] or [Amount > 100]; booleans can be written as [Active]. Combine with and, or, not, parentheses. Functions include contains(), starts-with() and length(). Navigate associations with a slash, for example [MyModule.Order_Customer/MyModule.Customer/City = 'Rotterdam']. empty tests for an empty string or an empty association. Tokens [%CurrentUser%] and [%CurrentDateTime%] are resolved at runtime.

Validation

Validation rules on attributes (required, unique, range) are evaluated when the object is committed. The Validation feedback activity attaches a message to a specific attribute so it shows next to the input widget instead of in a generic dialog.

Events

Every persistent entity can have event handlers for before/after create, commit and delete. A before-commit handler can still modify the object and its changes are saved by the commit; raising an error there prevents the commit. After-commit handlers run once the data is already stored.

Worked example

Requirement: no order may be committed with a negative total. Reasoning: a before-commit event handler is right, because it runs inside the commit and can adjust the total (or raise an error) before the row is written. An after-commit handler would run after persistence, needing a second commit and leaving a moment where bad data exists in the database.

Traps

  • XPath in entity access cannot use microflow parameters; only the provided tokens.
  • A constraint that looks right but navigates the association backwards returns the wrong rows.
  • Validation feedback needs a rollback or an error path, otherwise the caller may still commit.