Contents
- Stripes Annotations
- Dispatch Annotations
- @UrlBinding
- @HandlesEvent
- @DefaultHandler
- @SessionScope
- @Wizard
- Validation Annotations
- @DontValidate
- @Validate
- @ValidateNestedProperties
Stripes Annotations
Stripes uses Java 5 metadata to allow your classes to define their behavior in the framework without external information, such as is usually stored in XML files. Placing this information directly into your classes reduces the chance of different files becoming out of synch and reduces the duplication and added complexity required of placing behavioral metadata in many locations.
Dispatch Annotations
The following annotations manage the handling requests and their routing to ActionBean implementations.
@UrlBinding
| Applies to |
ActionBean Class |
| Example |
@UrlBinding("/action/MyAction") |
| Class |
net.sourceforge.stripes.action.UrlBinding |
This annotation must be applied to all ActionBean classes. It binds the ActionBean to a request path so that this bean is invoked in response to that path being called.
@HandlesEvent
| Applies to |
ActionBean Method |
| Example |
@HandlesEvent("Save") |
| Class |
net.sourceforge.stripes.action.HandlesEvent |
This annotation is applied to each method in an ActionBean in order to bind that method to a requested event name. The event name as passed into the request is used to determine which event to execute on the bound ActionBean. When there is no provided event, the default handler will be called should one be defined.
@DefaultHandler
| Applies to |
ActionBean Method |
| Class |
net.sourceforge.stripes.action.DefaultHandler |
When applied to an ActionBean method, this annotion denotes that the method should be executed when there is no event name provided in the request.
@SessionScope
| Applies to |
ActionBean Class |
| Class |
net.sourceforge.stripes.action.SessionScope |
Causes the ActionBean, the first time it is used within a user's session, to be placed in the user's HttpSession. On subsequent requests the ActionBean will be retrieved from the HttpSession and re-used.
@Wizard
| Applies to |
ActionBean Class |
| Class |
net.sourceforge.stripes.action.Wizard |
Causes submissions to this ActionBean to be treated as part of a wizard form (a logical form split over more than one physical page). Wizards receive special state management and validation handling.
Validation Annotations
The following annotations support the validation system of stripes, providing metadata about the expected parameters to a request and their boundary conditions.
@DontValidate
| Applies to |
ActionBean Method |
| Class |
net.sourceforge.stripes.action.DontValidate |
When applied to an event method, this annotation overrides the stripes validation process, skipping the typical required field and field value checks. ActionBean properties are still converted and bound where possible with the use of this annotation.
@Validate
| Applies to |
ActionBean Member Variable |
| Example |
@Validate(required="true",minlength="5", maxlength="10") |
| Class |
net.sourceforge.stripes.validation.Validate |
This annotation defines the rules of validation for a single field in an ActionBean.
| required |
(true or false) If true, this field must be present or a validation error will be created |
| minlength |
(#) The minimum length of the parameter string in characters |
| maxlength |
(#) The maximum number of characters in the parameter string |
| minvalue |
(#) The minimum numeric value for a property (applicable to numeric types only) |
| maxvalue |
(#) The maximum numeric value for a property (applicable to numeric types only) |
| mask |
(regex) A regular expression that must be matched to the parameters string |
| converter |
(class) The converter class that will be used to transform this parameter into its object representation |
| ignore |
(true or false) If true Stripes will ignore this property and not bind any input to it |
@ValidateNestedProperties
| Applies to |
ActionBean Member Variable |
| Example |
@ValidateNestedProperties( Unknown macro: {
@Validate(field="username", required="true"),
@Validate(field="password", required="true")} ) |
| Class |
net.sourceforge.stripes.validation.ValidateNestedProperties |
This annotation can be used for complex object validation. For example, if your ActionBean has a User member variable, with a username property and a password property, you can apply individual field validation to each of the sub fields of the object. This validation may only include @Validate definitions.