@Bean @Named("ModelDateTimePresenter") public ModelDateTimePresenter ModelDateTimePresenter() { return new ModelDateTimePresenter(); }
/** * @{inheritedDoc} */ @Override public Node present(IEmaginController controller, VLViewComponentXML configuration) { VLViewComponentXML dtf = configuration.getComponentById("DisplayFormat").orElse(null); if (dtf != null) { fullDisplayFormat = dtf.getPropertyValue("fullDisplayFormat") == null ? defaultFormat : dtf.getPropertyValue("fullDisplayFormat"); shortDisplayFormat = dtf.getPropertyValue("shortDisplayFormat") == null ? defaultFormat : dtf.getPropertyValue("fullDisplayFormat"); saveFormat = dtf.getPropertyValue("saveFormat"); } if (StringUtils.isNotBlank(saveFormat)) { String attributePath = configuration.getPropertyValue("attributePath"); String dataValue = getModelAttribute(controller, attributePath); setDate((AbstractViewController) controller, configuration, dataValue); } return label; }
public String setDate(AbstractViewController controller, VLViewComponentXML configuration, String dataValue) { if (StringUtils.isNotBlank(saveFormat)) { if (dataValue != null) { Date date = DateUtils.readFromString(dataValue, saveFormat); if (date == null) { label.setText("--"); return "--"; } if (isToday(date)) { df = new SimpleDateFormat(shortDisplayFormat); label.setText(df.format(date)); } else { df = new SimpleDateFormat(fullDisplayFormat); label.setText(df.format(date)); } } } return null; }
/** * @{inheritedDoc} */ @Override public Node present(IEmaginController controller, VLViewComponentXML configuration, Object forModel) { VLViewComponentXML dtf = configuration.getComponentById("DisplayFormat").orElse(null); if (dtf != null) { fullDisplayFormat = dtf.getPropertyValue("fullDisplayFormat") == null ? defaultFormat : dtf.getPropertyValue("fullDisplayFormat"); shortDisplayFormat = dtf.getPropertyValue("shortDisplayFormat") == null ? defaultFormat : dtf.getPropertyValue("fullDisplayFormat"); saveFormat = dtf.getPropertyValue("saveFormat"); } if (StringUtils.isNotBlank(saveFormat)) { String attributePath = configuration.getPropertyValue("attributePath"); String dataValue = getModelAttribute((OperationData) forModel, attributePath); setDate((AbstractViewController) controller, configuration, dataValue); } return label; }