@Override public void performValidation() { HtmlSimpleValueComponent component = (HtmlSimpleValueComponent) getComponent(); String value = component.getValue(); if (value == null || value.length() == 0) { setMessage("renderers.validator.dateTime.required"); setValid(!isRequired()); } else { if (value.equals(DateTimeConverter.INVALID)) { setMessage("renderers.validator.dateTime.invalid"); setValid(false); } else if (value.equals(DateTimeConverter.INCOMPLETE)) { setMessage("renderers.validator.dateTime.incomplete"); setValid(false); } else { int indexOfT = value.indexOf('T'); System.out.println("value: " + value); String[] dateParts = value.substring(0, indexOfT).split("-"); String[] timeParts = value.substring(indexOfT + 1).split(":"); try { int year = Integer.valueOf(dateParts[0]); if (year < 1000 || year > 9999) { setMessage("renderers.validator.dateTime.invalid"); setValid(false); } else { int hours = Integer.parseInt(timeParts[0]); int minutes = Integer.parseInt(timeParts[1]); if (inRange(hours, 0, 23) && inRange(minutes, 0, 59)) { setValid(true); } else { setMessage("renderers.validator.dateTime.notInRange"); setValid(false); } } } catch (NumberFormatException e) { setMessage("renderers.validator.dateTime.notNumbers"); setValid(false); } } } }
@Override public void execute(IViewState viewState) { HtmlSimpleValueComponent hidden = (HtmlSimpleValueComponent) getControlledComponent(); String menuValue = menu.getValue(); if (menuValue == null || menuValue.equals(OPTION_KEY)) { String value = this.other.getValue(); if (value != null) { value = value.trim(); if (value.length() == 0) { value = null; } } hidden.setValue(value); } else { hidden.setValue(this.menu.getValue()); } }