ActionErrors errors = new ActionErrors();
try
{
// initialize validation
Validation validation = new Validation();
boolean itemPresent =false;
if (this.itemid != null)
{
if (this.itemid.length>0)
{
itemPresent = true;
//System.out.println("Item Present");
}
else
{
//System.out.println("Item is Not Present");
}
}
if (!itemPresent)
{
errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.general.requiredField", "Items"));
}
// title
validation.checkForRequired("error.promotion.name", this.getPname(), "error.application.required", errors);
validation.checkForMaxlength("error.promotion.name", this.getPname(), "error.application.maxlength", errors, 25);
// detail
validation.checkForRequired("label.promotion.desc", this.getPdescription(), "error.application.required", errors);
validation.checkForMaxlength("error.promotion.desc", this.getPdescription(), "error.application.maxlength", errors, 100);
validation.checkForRequired("error.promotion.startday", this.getStartday(), "error.application.required", errors);
validation.checkForRequired("error.promotion.startyear", this.getStartyear(), "error.application.required", errors);
validation.checkForRequired("error.promotion.startmonth", this.getStartmonth(), "error.application.required", errors);
validation.checkForRequired("error.promotion.endyear", this.getEndyear(), "error.application.required", errors);
validation.checkForRequired("error.promotion.endmonth", this.getEndmonth(), "error.application.required", errors);
validation.checkForRequired("error.promotion.endday", this.getEndday(), "error.application.required", errors);
if (
(this.getStartyear() != null && this.getStartyear().length() != 0) ||
(this.getStartmonth() != null && this.getStartmonth().length() != 0) ||
(this.getStartday() != null && this.getStartday().length() != 0)
)
{
// due date
validation.checkForDate("error.promotion.startdate", this.getStartyear(), this.getStartmonth(), this.getStartday(), "error.application.date", errors);
if (
(this.getEndyear() != null && this.getEndyear().length() != 0) ||
(this.getEndmonth() != null && this.getEndmonth().length() != 0) ||
(this.getEndday() != null && this.getEndday().length() != 0)
)
{
validation.checkForDate("error.promotion.enddate", this.getEndyear(), this.getEndmonth(), this.getEndday(), "error.application.date", errors);
// comparison
validation.checkForDateComparison(
"error.promotion.enddate", this.getStartyear(), this.getStartmonth(), this.getStartday(), "00:00 AM",
"error.promotion.startdate", this.getEndyear(), this.getEndmonth(), this.getEndday(), "00:00 AM",
"error.promotion.datecomparison", errors, "error.promotion.enddate",
"error.promotion.startdate");
}