private String inMonth = EventVO.RecurrenceInMonth.DAY_OF_WEEK.toString();
public void validate(ActionMapping mapping, ActionMessages errors, HttpServletRequest request)
{
EventVO event = (EventVO)getPanel().getAttribute("event");
untilDate = FormUtility.adjustParameter(untilDate);
EventVO.RecurrenceType type = EnumUtility.valueOf(EventVO.RecurrenceType.class, recurrenceType);
if(recurrence)
{
// add the missing startDate
HashSet<String> newInWeek = new HashSet<String>();
for(String day : inWeek) {
newInWeek.add(day);
}
newInWeek.add(EventVO.RecurrenceInWeek.getForDate(event.getStartDate()).toString());
inWeek = newInWeek.toArray(new String[newInWeek.size()]);
if(cycle < 1)
errors.add("cycle", new ActionMessage("module.calendar.event.error.invalidCycle", MessageUtil.message(request, "entity.calendar.event.recurrence.cycle")));
if(EventVO.RecurrenceType.NUMBER_OF_TIMES.equals(type))
{
if(numberOfTimes < 1)
errors.add("numberOfTimes", new ActionMessage("module.calendar.event.error.invalidNumberOfTimes", MessageUtil.message(request, "entity.calendar.event.recurrence.numberOfTimes")));
}
else if(EventVO.RecurrenceType.UNTIL_DATE.equals(type))
{
if (untilDate == null)
{
errors.add("untilDate", new ActionMessage("default.error.missingInput", MessageUtil.message(request, "entity.calendar.event.recurrence.untilDate")));
}
else
{
String format = MessageUtil.message(request, "default.format.input.date");
try
{
untilDate = DateUtility.adjustDate(format, untilDate);
if(!event.getStartDate().before(DateUtility.getEndOfDay(new SimpleDateFormat(format).parse(untilDate))))
errors.add("untilDate", new ActionMessage("module.calendar.event.error.untilDateBeforeStart", MessageUtil.message(request, "entity.calendar.event.recurrence.untilDate")));
}
catch (ParseException e)
{
errors.add("untilDate", new ActionMessage("default.error.invalidFormat", MessageUtil.message(request, "entity.calendar.event.recurrence.untilDate"), format));