Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How do I get DateRange data out of a DateRangeItem?

    I'm using a DateRangeItem and I need to get data out of it. I have coded a button for the user to click when the dates are set, however, I get exceptions when I try to get data out of the DateRangeItem and it's associated DateRange.

    Code:
    // dateRangeItem and dateRange are declared as class level variables: 
    	private final DateRange dateRange;
    	private final DateRangeItem dateRangeItem;
    
    // The working code follows:	
    
            dateRangeItem = new DateRangeItem("dri","");
            dateRangeItem.setWidth(180);
            dateRange = new DateRange();
            dateRangeItem.setValue(dateRange);
            
            dateForm.setItems(dateRangeItem);
    
            vStack.addMember(dateForm);
            
            IButton goButton = new IButton();  
            goButton.setTitle("Go");  
            goButton.addClickHandler(new ClickHandler() {  
            	public void onClick(ClickEvent event) {
            		try {
            			DateRange currentRange = dateRangeItem.getValue();
                		Date start = currentRange.getStartDate();
                		Date end = currentRange.getEndDate();
                		if (start != null && end != null) {
                			pcdcListener.onDateRangeSelected("Both the dates are OK");
                    		String range = String.valueOf(start.getMonth())+"/"+String.valueOf(start.getDay())+"/"+String.valueOf(start.getYear());
                    		range += " to " + String.valueOf(end.getMonth())+"/"+String.valueOf(end.getDay())+"/"+String.valueOf(end.getYear());            			
                		} else {
                			pcdcListener.onDateRangeSelected("One of the dates was null");
                		}
                		
            		} catch (Exception e){
            			pcdcListener.onDateRangeSelected("There was some sort exception"+e.getMessage());
            		}
            	}  
            });
    This piece of code always throws an exception - It seems to be whenever I'm trying to work with the DateRangeItem and DateRange objects.

    #2
    I am experiencing the same thing. The exception is also thrown when trying to access to/from date directly from the DateRangeItem.

    The exception looks like it is failing to find certain JavaScript. However, all of my other widgets seem to display/work just fine.

    Is there any special configuration for the DateRangeItem?

    I have tried 2.2 and the nightly build of LGPL (nightly as of last night).

    Here is the error:

    Code:
    Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): ret.getTime is not a function
     fileName: http://127.0.0.1:8888
     lineNumber: 775
     stack: ("toDate")@http://127.0.0.1:8888:775
    @:0
    ([object GWTJavaObject],5243052,[object GWTJavaObject])@http://127.0.0.1:8888/virtualterminal/hosted.html?virtualterminal:56
    ([object Object],[object Object],[object Object])@http://127.0.0.1:8888:8
    ((function () {var param = {form: arguments[0], item: arguments[1]};var event = __gwt_makeJavaInvoke(1)(null, 11599959, param);__gwt_makeJavaInvoke(1)(selfJ, 5243052, event);}),[object Object],[object Object])@http://127.0.0.1:8888:45
    @:0
    (null,65642,(function () {var param = {form: arguments[0], item: arguments[1]};var event = __gwt_makeJavaInvoke(1)(null, 11599959, param);__gwt_makeJavaInvoke(1)(selfJ, 5243052, event);}),[object Object],[object Object])@http://127.0.0.1:8888/virtualterminal/hosted.html?virtualterminal:56
    ([object Object],[object Object],[object Object])@http://127.0.0.1:8888:58
    isc_FormItem__fireStandardHandler("click")@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Forms.js:1323
    isc_FormItem_handleClick()@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Forms.js:1328
    isc_c_Class_invokeSuper(null,"handleClick")@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:276
    isc_c_Class_Super("handleClick",[object Object])@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:268
    isc_ButtonItem_handleClick()@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Forms.js:1827
    ([object Object],(void 0))@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Forms.js:1821
    isc_StatefulCanvas_handleActivate([object Object],(void 0))@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Foundation.js:296
    isc_StatefulCanvas_handleClick([object Object],(void 0))@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Foundation.js:298
    isc_c_EventHandler_bubbleEvent([object Object],"click")@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:1484
    isc_c_EventHandler_handleClick([object Object])@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:1337
    isc_c_EventHandler__handleMouseUp([object MouseEvent],(void 0))@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:1324
    isc_c_EventHandler_handleMouseUp([object MouseEvent])@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:1315
    isc_c_EventHandler_dispatch(isc_c_EventHandler_handleMouseUp,[object MouseEvent])@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:1547
    anonymous([object MouseEvent])@http://127.0.0.1:8888/virtualterminal/sc/modules/ISC_Core.js:38
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:247)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:510)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.widgets.form.fields.FormItem.getPropertyAsDate(FormItem.java)
        at com.smartgwt.client.widgets.form.fields.FormItem.getAttributeAsDate(FormItem.java:3234)
        at com.smartgwt.client.widgets.form.fields.DateRangeItem.getToDate(DateRangeItem.java:317)
        at com.touchnet.mmx.reporting.client.view.CMEReportingView.getToDate(CMEReportingView.java:894)
        at com.touchnet.mmx.reporting.client.presenter.CMEReportingPresenter.startSearch(CMEReportingPresenter.java:70)
        at com.touchnet.mmx.reporting.client.presenter.CMEReportingPresenter$4.onClick(CMEReportingPresenter.java:213)
        at com.smartgwt.client.widgets.form.fields.events.ClickEvent.dispatch(ClickEvent.java:95)
        at com.smartgwt.client.widgets.form.fields.events.ClickEvent.dispatch(ClickEvent.java:1)
        at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.fireEvent(HandlerManager.java:78)
        at com.google.gwt.event.shared.HandlerManager$HandlerRegistry.access$1(HandlerManager.java:55)
        at com.google.gwt.event.shared.HandlerManager.fireEvent(HandlerManager.java:208)
        at com.smartgwt.client.core.DataClass.fireEvent(DataClass.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:154)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:336)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:217)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:510)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
        at sun.reflect.GeneratedMethodAccessor42.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        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:154)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:291)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:541)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:362)
        at java.lang.Thread.run(Thread.java:619)

    Comment


      #3
      colinsulin : Fixed in SVN.

      tdoty : The exception you posted seems to be different. After using the latest nightly if you still see the error then please post a minimal standalone testcase.

      Sanjiv
      Last edited by sjivan; 11 Sep 2010, 08:52.

      Comment


        #4
        Thanks for the fix sjivan. Unfortunately I wasn't very clear in my previous post, and I apologize. I was using the DateRangeItem.getToDate and getFromDate, instead of calling getStart/EndDate on the DateRange contained within the DateRangeItem. With the previous build, neither way worked. With the latest, the DateRange's getStart/EndDate methods now seem to work just fine.

        However, after testing DRI's getTo/FromDate methods, these still throw the same exception listed above. You should be able to reproduce with the above test case posted by colinsulin, but instead try accessing the dates directly from the DRI.

        Let me know if you are able to reproduce, or if I need to come up with a better test case. I have a work around now with your last fix, but if what I am seeing is actually a problem, I would imagine you would like to fix that as well.

        Thanks again.

        Comment


          #5
          This has been fixed. Please try the latest nightly.

          Comment

          Working...
          X