Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

FilterBuilder and custom date parser

$
0
0
Dear Support,

I was able to reproduce a problem when I'm using the FilterBuilder, date picker and custom data parsers together.

1) I've configured our own date parser (we've added our own parsers and formatters using the DateUtil API) :

Code:

[...]
private static DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd MMM yyyy");
        private static DateTimeFormat        dateTimeFormat        = DateTimeFormat.getFormat("dd MMM yyyy - HH:mm:ss");
        private static DateTimeFormat        dateFormat                = DateTimeFormat.getFormat("dd MMM yyyy");
        private static DateTimeFormat        timeFormat                = DateTimeFormat.getFormat("HH:mm:ss");
[...]

// We've setup all the Normal/Short Date/Time formaters and parses in your API
DateUtil.setDateParser(new DateParser() {

                        public Date parse(String dateString) {
                                return dateFormat.parse(dateString);
                        }
                });

2) Here is a test case code (we are using the serialization to store the current filter of a listgrid) :

Code:

DataSource.load(DSBusinessUnit.DS_NAME,new Function() {
                        @Override
                        public void execute() {
                                VLayout panel = new VLayout();
                                panel.setBackgroundColor("white");
                                final FilterBuilder builder = new FilterBuilder();
                                builder.setDataSource(DataSource.get(DSBusinessUnit.DS_NAME));
                                panel.setMembers(builder);
                                panel.show();
                        }
                }, false);

3) In our Datasource we have this field:

Code:

<field name="CREATED" type="creatorTimestamp" title="$created" hidden="false" details="true" />
To reproduce the bug on 4.0p:
- Select that "CREATED" field in the field list
- Use the date picker icon and select a Date (see screenshot)

- First, we see that it uses our other formatters (DateTime !) to format the date displayed right to the picker.
- Then it uses our formatter (Date) to when the picker popup is shown
- As soon as we CLICK on a date in the popup, it use our DateTime formatter
- The we have the following exception... because you seem to try to parse the collected date (in DateTime format) using the Date parser:

We receive this kind of error:

Code:

java.lang.IllegalArgumentException: 29 Jan 2014 - 10:06:00
        at com.google.gwt.i18n.shared.DateTimeFormat.parse(DateTimeFormat.java:1437)
        at com.google.gwt.i18n.shared.DateTimeFormat.parse(DateTimeFormat.java:882)
        at com.fircosoft.cdb.client.localization.Localization.parseDate(Localization.java:209)
        at com.fircosoft.cdb.client.localization.Localization$7.parse(Localization.java:116)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Unknown Source)

Many thanks in advance for your help,
Thomas

Attached Images
File Type: png test.png (5.9 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles