use of com.evolveum.midpoint.web.component.input.DatePanel in project midpoint by Evolveum.
the class DatePanelFactory method getPanel.
@Override
protected InputPanel getPanel(PrismPropertyPanelContext<XMLGregorianCalendar> panelCtx) {
DatePanel panel = new DatePanel(panelCtx.getComponentId(), panelCtx.getRealValueModel());
Form<?> form = Form.findForm(panelCtx.getForm());
DateValidator validator;
String validatorErrorMessageKey;
if (ScheduleType.F_EARLIEST_START_TIME.equals(panelCtx.getDefinitionName()) || ScheduleType.F_LATEST_START_TIME.equals(panelCtx.getDefinitionName())) {
validator = WebComponentUtil.getRangeValidator(form, TaskType.F_SCHEDULE);
validatorErrorMessageKey = "ScheduleType.dateValidator.errorMessage";
} else {
validator = WebComponentUtil.getRangeValidator(form, SchemaConstants.PATH_ACTIVATION);
validatorErrorMessageKey = "DateValidator.message.fromAfterTo";
}
if (ActivationType.F_VALID_FROM.equals(panelCtx.getDefinitionName()) || ScheduleType.F_EARLIEST_START_TIME.equals(panelCtx.getDefinitionName())) {
validator.setDateFrom((DateTimeField) panel.getBaseFormComponent());
} else if (ActivationType.F_VALID_TO.equals(panelCtx.getDefinitionName()) || ScheduleType.F_LATEST_START_TIME.equals(panelCtx.getDefinitionName())) {
validator.setDateTo((DateTimeField) panel.getBaseFormComponent());
}
validator.setMessageKey(validatorErrorMessageKey);
return panel;
}
Aggregations