lovespring
lovespring

Reputation: 19589

In struts2, how to use annotaion to validate a modeldriven action?

I want to use annotation to validate my action.

but the data is located in a model (because the modeldriven interface), So I cannot annotation the action fields.

So, How can I annotation the "Model"'s fields?

Upvotes: 0

Views: 99

Answers (1)

Pravin Varpe
Pravin Varpe

Reputation: 198

You can use annotations by using @VisitorFieldValidator on your overridden getModel() method.

@Override
@VisitorFieldValidator(appendPrefix = false)
public Object getModel() {
    return yourBean;
}

Now do the normal validations using annotation.

Upvotes: 1

Related Questions