Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ontopoly date and datetime fields don't allow user input #325

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 9 comments
Closed

Ontopoly date and datetime fields don't allow user input #325

GoogleCodeExporter opened this issue Mar 16, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Load the attached topic map into Ontopoly
2. Create a new instance of type "a topic type"
3. Try to enter a value for the date field without using the calendar widget. 
You will always get the current date.
4. Try to enter a value for the datetime field without using the calendar 
widget. You will always get today's date with a time of "12:00:00". You also 
only get an ordinary calendar widget so there is no way to enter a time.

What is the expected output? What do you see instead?

I expected to be able to enter the date in some reasonable formay, e.g., 
yyyy-mm-dd or (for me) mm-dd-yy but no format I have tried works. I looked at 
the code and I think that the problem is in file 

src/main/java/ontopoly/components/FieldInstanceDateField.java 

in this block of code:

public FieldInstanceDateField(String id, FieldValueModel fieldValueModel) {
    super(id);
    this.fieldValueModel = fieldValueModel;

    OccurrenceIF occ = (OccurrenceIF)fieldValueModel.getObject();
    this.oldValue = (occ == null ? null : occ.getValue());
    setModel(new Model<String>(oldValue));

    add(new DatePickerBehavior("yy-mm-dd"));
    add(new DateFormatValidator(this, fieldValueModel.getFieldInstanceModel()) {
      @Override
      public DateFormat createDateFormat() {
        return new SimpleDateFormat("yyyy-MM-dd");
      }
      @Override
      protected String resourceKey() {
        return super.resourceKey() + ".date";
      }
    });

specifically, the add(new DatePickerBehavior("yy-mm-dd")); line which doesn't 
match the format specified in createDateFormat().

It looks like there is a similar problem in FieldInstanceDateTimeField.java:

public FieldInstanceDateTimeField(String id, FieldValueModel fieldValueModel) {
    super(id);
    this.fieldValueModel = fieldValueModel;

    OccurrenceIF occ = (OccurrenceIF)fieldValueModel.getObject();
    this.oldValue = (occ == null ? null : occ.getValue());
    setDefaultModel(new Model<String>(oldValue));

    add(new DatePickerBehavior("yy-mm-dd 12:00:00"));
    add(new DateFormatValidator(this, fieldValueModel.getFieldInstanceModel()) {
      @Override
      public DateFormat createDateFormat() {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      }
      @Override
      protected String resourceKey() {
        return super.resourceKey() + ".datetime";
      }
    });

    // validate field using registered validators
    ExternalValidation.validate(this, oldValue);
  }




Please use labels and text to provide additional information.

Original issue reported on code.google.com by dan.sp...@gmail.com on 29 Oct 2010 at 8:45

Attachments:

@GoogleCodeExporter
Copy link
Author

I don't have this problem. See the attached screenshot.

Which web browser do you use?

Original comment by indiapaleale@gmail.com on 29 Oct 2010 at 10:05

Attachments:

@GoogleCodeExporter
Copy link
Author

The two given dateformats are actually both correct, but they follow different 
formatting rule syntaxes, i.e. jQuery[1] and Java[2]. 

[1] http://docs.jquery.com/UI/Datepicker/formatDate
[2] 
http://download.oracle.com/javase/1.5.0/docs/api/java/text/SimpleDateFormat.html

Original comment by indiapaleale@gmail.com on 30 Oct 2010 at 12:26

@GoogleCodeExporter
Copy link
Author

I have tested this issue against Firefox 3.6.11 and the latest Firefox 4.0 Beta.

To be clear, the problem is with entering text via the keyboard into the date 
and datetime fields. I am able to use the calendar widget to enter the date. 
The datetime field (apparently) uses the same calendar widget as the date field 
so there is no way to enter a timestamp.

Regarding the different time formats--they may each be valid according to their 
respective syntaxes but they can't both be valid with the same date field 
instance as one requires a two-digit year and the other requires a four-digit 
year.

Original comment by dan.sp...@gmail.com on 30 Oct 2010 at 1:07

@GoogleCodeExporter
Copy link
Author

I tested this issue against oks 4.1.0 and it was present in that version. I 
have also tested it against oks 4.0.5 and was able to enter both a date and a 
datetime with the keyboard. The Ontopoly UI looks considerably different 
between 4.0.5 and 4.1.0 so it may have been introduced then.

In oks 4.0.5 when I begin to type into a date or datetime field the calendar 
widget doesn't automatically pop up, which I think is good.

Original comment by dan.sp...@gmail.com on 30 Oct 2010 at 1:25

@GoogleCodeExporter
Copy link
Author

I have also seen this issue with Opera. Basically, you can do some typing in 
date fields, but it's fairly limited. Some things are allowed, and some are 
not. I don't think the restrictions really make any sense.

Original comment by lar...@gmail.com on 2 Nov 2010 at 8:42

  • Added labels: Component-Ontopoly

@GoogleCodeExporter
Copy link
Author

Original comment by lar...@gmail.com on 18 Aug 2011 at 6:44

  • Changed state: Accepted
  • Added labels: Release5.2.0

@GoogleCodeExporter
Copy link
Author

I've been able to reproduce the problem:

- onBlur of the element, the new value gets saved, but validation seems to be 
skipped. I was able to successfully store the date 2011-55-55. 
- If you hit return while focus is on the date edit field, the new value is not 
saved, but the old value is reloaded.

jQuery does seem to recognize the pattern because you cannot input non-date 
characters. IF you look at the jQuery demo[1] page for this control, you see 
that it should be responding to value changes by selecting a different date in 
the calendar as you type, ontopoly doesn't do this either.

[1]: http://jqueryui.com/demos/datepicker/

Original comment by qsieb...@gmail.com on 13 Sep 2011 at 1:14

@GoogleCodeExporter
Copy link
Author

Revision 2238 improves the date picker behavior of jQuery

Original comment by qsieb...@gmail.com on 11 Nov 2011 at 12:34

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision r2239.

Original comment by qsieb...@gmail.com on 11 Nov 2011 at 12:39

  • Changed state: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant