WhoAmI
WhoAmI

Reputation: 819

@Required Validation messages

I am using Play 1.2.5.

The below validation is working fine but the message I am getting is not customized.

public static void welcome(@Required(message="validation.required.em") String txtName,@Required(message="validation.required.em") Integer txtAge){
    ....
    ....
}

Below is the messages file:

validation.required.em=%s is required

I am getting this message:

txtName is required
txtAge is required

I wan't to use customized name for the txtName and txtAge like this:

Customer Nameis required
Customer Age is required

I can't see any parameters which I can pass to this for customizing the names.

Please let me know about this.

Upvotes: 0

Views: 176

Answers (1)

Theo
Theo

Reputation: 396

You do this with changing the annotation to:

@Required(message="Customer Name is required") when annotating txtName

and

@Required(message="Customer Age is required") when annotating txtAge

Alternatively,

In the messages file you want can add

txtName=Customer Name
txtAge=Customer Age

and leave everything else you have the same.

Upvotes: 1

Related Questions