public void validateEnterSearchCriteria(ValidationContext context)
{
if (this.isEmpty())
{
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error().defaultText(
"At least one of the Search criteria should not be empty.")
.build());
}
else if (lastName.startsWith("*") || firstName.startsWith("*")
|| bookingId.startsWith("*") || activityDate.startsWith("*"))
{
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error().defaultText(
"Search criterion can not start with '*'.").build());
}else if(!activityDate.isEmpty()){
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yy");
boolean error = false;
if (activityDate.trim().length() != dateFormat.toPattern().length())
{
log.error("Activity date has invalid format.");
error = true;
}
dateFormat.setLenient(true);
try {
//parse the inDate parameter
dateFormat.parse(activityDate.trim());
}
catch (ParseException pe) {
log.error("Activity date has invalid format.");
error = true;
}
if (error == true)
{
MessageContext messages = context.getMessageContext();
messages.addMessage(new MessageBuilder().error().defaultText(
"Activity date has invalid format. Please enter in mm/dd/yy format").build());
}
}