@Action
The @Action
annotation simplifies writing actions. The annotation
is added to a method and that method is wrapped in a transaction. The transaction can be
read-write or read-only depending on whether the @Action.mutation
parameter
is true
or false
. By default actions use read-write transactions.
The annotation also defines parameters that control the name of the action and whether the methods parameters
are logged during development mode. See the @Action
API documentation for further details.
Actions are usually invoked in response to an event in the system, whether that been in response to a user action or a network response.
An example:
@ArezComponent
public abstract class Wallet
{
@CascadeDispose
final Currency aud = new Arez_Currency();
// A read-write action that updates observable value
@Action
public void updateAustralianDollarBalance( final BigDecimal newBalance )
{
aud.setAmount( newBalance );
}
// A read-only action that queries observable value
@Action( mutation = false )
public boolean holdsAnyAustralianDollars()
{
return aud.getAmount().compareTo( BigDecimal.ZERO ) > 0;
}
}