Associating actions with properties and collections
The associateWith element allows an action to be associated with other properties or collections of the same domain object.
The optional sequence element specifies the order of the action in the UI.
For example, an Order could have a collection of OrderItems, and might provide actions to add and remove items:
public class Order {
@Getter @Setter
@Collection
private final SortedSet<OrderItem> items = ...
@Action(associateWith="items") (1)
@ActionLayout(sequence="1" ) (2)
public Order addItem(Product p, int quantity) {
// ...
}
@Action(associateWith="items") (3)
@ActionLayout(sequence="2" ) (4)
public Order removeItem(OrderItem item) {
// ...
}
// ...
}
| 1 | matches the name of the collection |
| 2 | first action in the list of all associated actions |
| 3 | matches the name of the collection |
| 4 | second action in the list of all associated actions |
These actions - addItem() and removeItem() can be thought of as associated with with the items collection because that is the state that they primarily affect.
In the user interface associated actions are rendered close to the member to which they relate.
|
The same effect can be accomplished using the |