openmeetings-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From solo...@apache.org
Subject [openmeetings] branch master updated: [OPENMEETINGS-2196] date-times are parsed case insensitive
Date Thu, 26 Mar 2020 01:39:38 GMT
This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 2850bd9  [OPENMEETINGS-2196] date-times are parsed case insensitive
2850bd9 is described below

commit 2850bd918e89abc85fc43e8c139d1f00b33502f6
Author: Maxim Solodovnik <solomax666@gmail.com>
AuthorDate: Thu Mar 26 08:39:23 2020 +0700

    [OPENMEETINGS-2196] date-times are parsed case insensitive
---
 .../openmeetings/web/common/InvitationForm.java    |  4 ++-
 .../openmeetings/web/common/OmDateTimePicker.java  | 36 ++++++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
index cafcead..c729c70 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
@@ -132,7 +132,9 @@ public abstract class InvitationForm extends Form<Invitation> {
 		add(passwd);
 		Invitation i = getModelObject();
 		passwd.setLabel(new ResourceModel("110")).setOutputMarkupId(true).setEnabled(i.isPasswordProtected());
-		add(from.setOutputMarkupId(true), to.setOutputMarkupId(true), timeZoneId.setOutputMarkupId(true));
+		add(from.setLabel(new ResourceModel("530")).setOutputMarkupId(true)
+				, to.setLabel(new ResourceModel("531")).setOutputMarkupId(true)
+				, timeZoneId.setOutputMarkupId(true));
 		timeZoneId.add(new AjaxFormComponentUpdatingBehavior("change") {
 			private static final long serialVersionUID = 1L;
 
diff --git a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmDateTimePicker.java
b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmDateTimePicker.java
index 09e2c4e..062cd4d 100644
--- a/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmDateTimePicker.java
+++ b/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/OmDateTimePicker.java
@@ -19,20 +19,52 @@
 package org.apache.openmeetings.web.common;
 
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeFormatterBuilder;
+import java.util.Locale;
 
 import org.apache.wicket.extensions.markup.html.form.datetime.LocalDateTimeTextField;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.model.IModel;
+import org.apache.wicket.util.convert.IConverter;
+import org.apache.wicket.util.convert.converter.LocalDateTimeConverter;
 
 public class OmDateTimePicker extends AbstractOmDateTimePicker<LocalDateTime> {
 	private static final long serialVersionUID = 1L;
+	private final LocalDateTimeConverter converter;
 
 	public OmDateTimePicker(String id, IModel<LocalDateTime> model) {
-		super(id, model, getDateTimeFormat());
+		this(id, model, getDateTimeFormat());
+	}
+
+	private OmDateTimePicker(String id, IModel<LocalDateTime> model, final String pattern)
{
+		super(id, model, pattern);
+		this.converter = new LocalDateTimeConverter() {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public DateTimeFormatter getDateTimeFormatter(Locale locale)
+			{
+				return new DateTimeFormatterBuilder()
+						.parseCaseInsensitive()
+						.appendPattern(pattern)
+						.toFormatter(locale);
+			}
+		};
 	}
 
 	@Override
 	protected FormComponent<LocalDateTime> newInput(String wicketId, String dateFormat)
{
-		return new LocalDateTimeTextField(wicketId, getModel(), dateFormat);
+		return new LocalDateTimeTextField(wicketId, getModel(), dateFormat) {
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			protected IConverter<?> createConverter(Class<?> clazz) {
+				if (LocalDateTime.class.isAssignableFrom(clazz)) {
+					return converter;
+				}
+				return null;
+			}
+		};
 	}
 }


Mime
View raw message