Announcement

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

    Bug? FieldType.Time causing exceptions and listgrid filter doesn't work

    Power 3.0
    Using Oracle 11g with an SQLDataSource.

    We've had an old bug where fields of type 'time' in a ds.xml file would throw some sort of exception in ISC code.

    We were able to "work around" this issue in 1 of 2 ways:
    1) Create a custom attribute called "useTimeOnly" in ds.xml fields. We would then look for this in a custom ListGrid that would override setDataSource() and look for this attribute, and if it existed, change the FieldType to Time instead of DateTime.
    2) Intercept all fetch() calls from a datasource extending from SQLDataSource. Look for all fields with type 'time' and manually convert the oracle.sql.TIMESTAMP object from the server into a java.sql.Time object for the client.

    Either of these workarounds fixes the exceptions we were seeing in SmartGwt. However, filtering doesn't work on the FilterEditor for ListGrids. We would see an error about IContains not being valid for fields of type Time and that it would be ignored. This caused the time filter to conver to 0:00 on the UI and it would always return no data.

    Here is the error below. We would really just like to use field types "time" in our ds.xml files and avoid the hacks. Please let us know how we should proceed with that as well as what we can do to be able to filter by time in the ListGrid filter editor.

    Code:
    Uncaught JavaScript exception [newData is undefined] in http://127.0.0.1:8888/drmsWebApp/sc/modules/ISC_DataBinding.js, line 1443
    Code:
    12:34:41.092 [ERROR] [drmsWebApp] 12:34:41.067:XRP5:WARN:Log:TypeError: newData is undefined
        unnamed({Obj}, undef, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1443
        [c]Class.fireCallback(_1=>{Obj},  _2=>"dsResponse,data,dsRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Class.fireCallback(_1=>{Obj},  _2=>"dsResponse,data,dsRequest",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:432
        DataSource.fireResponseCallbacks({Obj}, {Obj}, {Obj}, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:587
        DataSource._completeResponseProcessing(undef, {Obj}, {Obj}, {Obj}, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:584
        DataSource._handleSCServerReply({Obj}, undef, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1891
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:432
        anonymous(callback=>{Obj},  request=>{Obj},  response=>{Obj},  data=>undef) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1335
        unnamed({Obj}, {Obj}, {Obj}, undef) @ :188
        [c]RPCManager.fireReplyCallbacks(_1=>{Obj},  _2=>{Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1340
        [c]RPCManager.performOperationReply(_1=>{Obj},  _2=>{Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1334
        RPCManager._performTransactionReply(5) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1328
        [c]RPCManager.performTransactionReply(_1=>5,  _2=>"//isc_RPCResponseStart-->[{data:[{START..."[ 737],  _3=>undef) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1285
        anonymous(5, [object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:62
        [c]Class.fireCallback(_1=>"isc.RPCManager.performTransactionReply(..."[ 67],  _2=>"transactionNum,results,wd",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Comm.performXmlTransactionReply(_1=>5,  _2=>[object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:1319
        anonymous([object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:62
        [c]Class.fireCallback(_1=>"isc.Comm.performXmlTransactionReply(5, ..."[ 56],  _2=>"xmlHttpRequest",  _3=>[object Array],  _4=>[object Proxy],  _5=>true) @ drmsWebApp/sc/modules/ISC_Core.js:334
        Comm._fireXMLCallback([object XMLHttpRequest], "isc.Comm.performXmlTransactionReply(5, ..."[ 56]) @ drmsWebApp/sc/modules/ISC_Core.js:1293
        unnamed([object Event]) @ drmsWebApp/sc/modules/ISC_Core.js:1305
        unnamed() @ 
    
    
    com.smartgwt.client.core.JsObject$SGWT_WARN: 12:34:41.067:XRP5:WARN:Log:TypeError: newData is undefined
        unnamed({Obj}, undef, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1443
        [c]Class.fireCallback(_1=>{Obj},  _2=>"dsResponse,data,dsRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Class.fireCallback(_1=>{Obj},  _2=>"dsResponse,data,dsRequest",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:432
        DataSource.fireResponseCallbacks({Obj}, {Obj}, {Obj}, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:587
        DataSource._completeResponseProcessing(undef, {Obj}, {Obj}, {Obj}, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:584
        DataSource._handleSCServerReply({Obj}, undef, {Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1891
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array],  _4=>{Obj},  _5=>undef) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Class.fireCallback(_1=>{Obj},  _2=>"rpcResponse,data,rpcRequest",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:432
        anonymous(callback=>{Obj},  request=>{Obj},  response=>{Obj},  data=>undef) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1335
        unnamed({Obj}, {Obj}, {Obj}, undef) @ :188
        [c]RPCManager.fireReplyCallbacks(_1=>{Obj},  _2=>{Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1340
        [c]RPCManager.performOperationReply(_1=>{Obj},  _2=>{Obj}) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1334
        RPCManager._performTransactionReply(5) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1328
        [c]RPCManager.performTransactionReply(_1=>5,  _2=>"//isc_RPCResponseStart-->[{data:[{START..."[ 737],  _3=>undef) @ drmsWebApp/sc/modules/ISC_DataBinding.js:1285
        anonymous(5, [object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:62
        [c]Class.fireCallback(_1=>"isc.RPCManager.performTransactionReply(..."[ 67],  _2=>"transactionNum,results,wd",  _3=>[object Array]) @ drmsWebApp/sc/modules/ISC_Core.js:334
        [c]Comm.performXmlTransactionReply(_1=>5,  _2=>[object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:1319
        anonymous([object XMLHttpRequest]) @ drmsWebApp/sc/modules/ISC_Core.js:62
        [c]Class.fireCallback(_1=>"isc.Comm.performXmlTransactionReply(5, ..."[ 56],  _2=>"xmlHttpRequest",  _3=>[object Array],  _4=>[object Proxy],  _5=>true) @ drmsWebApp/sc/modules/ISC_Core.js:334
        Comm._fireXMLCallback([object XMLHttpRequest], "isc.Comm.performXmlTransactionReply(5, ..."[ 56]) @ drmsWebApp/sc/modules/ISC_Core.js:1293
        unnamed([object Event]) @ drmsWebApp/sc/modules/ISC_Core.js:1305
        unnamed() @ 
    
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        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:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)

    #2
    We are not aware of a bug with time type fields generally failing on a fetch against a sql type dataSource, and the stack trace unfortunately doesn't give us enough to go on. Definitely this should work - you should not need the hacks you describe to get Times working in your app.

    It sounds like you're saying that time fields *in general* aren't working for you with your datasource. If so, could you try the following:
    - put together a trivally simple .ds.xml file that contains just a time type field (and possibly another field)
    - put together an entry point class that simply loads this dataSource and does whatever your app is doing that leads to the problem (E.G. binds a ListGrid to it and issues a fetch request)
    - you'll need to build the table and populate with test data of course - probably easiest to write a simple test data file (similar to the ones visible under the "test_data" directory of the built-in-ds sample for example), then call SCEE.openDataSourceConsole() from your application, and use the datasource console tool to create the table and import your test data.

    If you still get a failure, show us your test case so we can run it on our end and experiment with your particular database, etc.
    If not, see if you can determine what's special about your app that is leading to the problem and get us a test case that demonstrates the problem from that.

    Thanks
    Isomorphic Software

    Comment


      #3
      Test Case

      Here is the standalone test case. All of the "date" and "time" fields are mapped to fields in the Oracle Database who are type "Timestamp". We are not doing any sort of timezone stuff, validation, functions, etc with this table. I've also removed our custom sqldatasource just in case and are using the built-in sqldatasource.

      With no data, it loads fine with no errors. I'm able to add the record but on the auto-fetch that occurs, and on every fetch after that, I get the errors that I described in my original post.

      ds.xml
      Code:
      <DataSource 
      	tableName="CATEGORYS"
      	ID="timeTestCase"
      	serverType="sql"
      >
      	<fields>
      		<field primaryKey="true" name="CATEGORY_PK" type="sequence" hidden="true" sequenceName="CATEGORY_SEQ"></field>
      		<field name="CATEGORY_NAME" type="text" length="128" required="true" title="Name">
      			<validators>
      				<validator type="isUnique"></validator>
      			</validators>
      		</field>
      		<field name="START_DATE" type="date" useTextField="true" title="Start Date" required="true"></field>
      		<field name="END_DATE" type="date" useTextField="true" title="End Date" required="true"></field>
      		<field name="START_TIME" type="time" title="Start Time" required="true"></field>
      		<field name="END_TIME" type="time" title="End Time" required="true"></field>
      	</fields>	
      </DataSource>
      EntryPoint
      Code:
      public void onModuleLoad() {
      	VLayout testLayout = new VLayout();
      	testLayout.setSize("640", "480");
      	
      	DataSource ds = DataSource.get("timeTestCase");
      	
      	ListGrid grid = new ListGrid();
      	grid.setSize("100%", "100%");
      	grid.setShowFilterEditor(true);
      	grid.setDataSource(ds);
      	grid.setAutoFetchData(true);
      	
      	final DynamicForm form = new DynamicForm();
      	form.setDataSource(ds);
      	
      	testLayout.addMember(grid);
      	testLayout.addMember(form);
      	
      	IButton addBtn = new IButton("Add Record");
      	addBtn.addClickHandler(new ClickHandler() {
      		@Override
      		public void onClick(ClickEvent event) {
      			form.saveData();
      			form.clearValues();
      		}		
      	});
      	testLayout.addMember(addBtn);
      	
      	testLayout.show();
      }

      Comment


        #4
        Hi
        We don't have anything conclusive yet, but wanted to follow up to let you know we have a developer looking at this.
        If there is a problem here it appears to be Oracle specific and may be due to the database column type (TIMESTAMP vs DATE). However we need to do some more investigation before we know what's going on for sure.

        We'll follow up when we have more information

        Regards
        Isomorphic Software

        Comment


          #5
          Fantastic. Thank you.

          I think there are a few odd things going on. For instance, if we "Group By" on a column with type 'datetime', all items get put into their own group despite them having the same date and time. My guess is that the "nanoseconds" being cut off are causing SmartGwt to think they are different.

          And finally, I was able to fix the exception I listed above with the following code in an extended DataSource:

          Code:
          public DSResponse executeFetch(DSRequest req) throws Exception {
          		DSResponse response = super.executeFetch(req);
          		long totalRows = response.getTotalRows();
          		
          		DataSource ds = response.getDataSource();
          		Vector<String> timeFields = new Vector<String>();
          		for (Object field : ds.getFields()) {
          			DSField dsField = null;
          			
          			try {
          				dsField = (DSField)field;
          			} catch (Exception e) {
          				continue;
          			}
          			
          			
          			if (dsField != null) {
          				if (dsField.getType().equals(DsFieldTypeEnum.TIME)) {
          					timeFields.add(dsField.getName());
          				}
          			}
          		}
          		
          		if (response.getStatus() >= DSResponse.STATUS_SUCCESS && totalRows > 0) {
          			for (Object obj : response.getRecords()) {
          				HashMap record = null;
          				
          				try {
          					record = (HashMap) obj;
          				} catch (Exception e) {
          					continue;
          				}
          				
          				if (record != null) {
          					for (String timeFieldName : timeFields) {
          						oracle.sql.TIMESTAMP timeStamp = null;
          						
          						try {
          							timeStamp = (TIMESTAMP) record.get(timeFieldName);
          						} catch (Exception e) {
          							continue;
          						}
          						
          						if (timeStamp != null) {
          							java.sql.Time time = timeStamp.timeValue();
          							record.put(timeFieldName, time);
          						}
          					}
          				}
          			}
          		}
          		return response;
          	}
          However, fixing that error does not fixing the ListGrid being able to sort or groupBy on that column - then a different error gets generated.

          Comment


            #6
            Its been a while - just wanted to see if anything new has come up for this? We have a defect logged internally with some of our clients about this and they'd like a resolution soon.

            Comment


              #7
              Sorry - normal service has been affected recently as we were focusing on releasing 3.1. We'll get to this in the next day or two - thanks for your patience.

              Comment


                #8
                We corrected a couple of things:

                1. there were issues where the underlying Oracle column was TIMESTAMP (our tests used a normal DATE column)

                2. there was cases where a form would submit the iContains operator for "time" fields, this has been corrected

                We're still looking at possibly providing a different set of grouping modes for "datetime" / "time".

                Comment


                  #9
                  Sounds great. Is this part of a 3.0 nightly?

                  Comment


                    #10
                    Yes, the latest 3.0 nightly has the fix.

                    Comment


                      #11
                      Power 3.0

                      Update:
                      I can confirm that adding and editing records with the field type of 'time' now work correctly.

                      However, in the ListGrid FilterEditor, we are still seeing the issue where every filter we put in gets replaced with a '0:00'. This is still happening in our standalone test case posted earlier.

                      The "GroupBy" options for Time and Date are really good (although an option to show 1pm instead of 13 for the group title would be nice).

                      Comment


                        #12
                        We're not seeing the issue with the Time field in the filter editor being reset to "0:00" when you enter some specific time on our end.

                        Can you confirm exactly which build you're seeing this with (in fact as a sanity check, it's probably worth picking up the very latest nightly build for your branch and working with that).

                        If so, can you confirm exact steps for how you're reproducing the problem with the sample from earlier in the thread. We're interested in anything that can help shed light on how to reproduce this and what the culprit could be.
                        For example - exact steps to reproduce, including what exact string you enter / whether other fields are blank, etc? At what point does the entered value get reset to zero - when you tab out of the field? If you hit enter or click the filter button? Before or after the server responds?
                        Other than the field resetting does the fetch transaction appear to go through with the correct criteria and what does the returned data look like?

                        Thanks for your help

                        Isomorphic Software

                        Comment


                          #13
                          Just leaving the office. I'll check into this tomorrow. Thanks for the update.

                          Comment


                            #14
                            Standalone test case - still seeing the issue.
                            SmartGwtPower 3.0
                            latest nightly
                            Tested on FF 10 ESR and IE8

                            EntryPoint Code
                            Code:
                            	private void doStandaloneTestCase() {
                            		VLayout layout = new VLayout();
                            		layout.setSize("100%", "100%");
                            		
                            		DataSource ds = DataSource.get("testTime");
                            		
                            		final ListGrid grid = new ListGrid();
                            		grid.setDataSource(ds);
                            		grid.setAutoFetchData(true);
                            		grid.setShowFilterEditor(true);
                            		grid.setFilterOnKeypress(false);
                            		grid.setAllowFilterExpressions(true);
                            		
                            		final DynamicForm form = new DynamicForm();
                            		form.setDataSource(ds);
                            		
                            		IButton clearButton = new IButton("Clear");
                            		clearButton.addClickHandler(new ClickHandler() {
                            			
                            			@Override
                            			public void onClick(ClickEvent event) {
                            				form.clearValues();
                            			}
                            		});
                            		
                            		IButton saveButton = new IButton("Save");
                            		saveButton.addClickHandler(new ClickHandler() {
                            			
                            			@Override
                            			public void onClick(ClickEvent event) {
                            				form.saveData(new DSCallback() {
                            
                            					@Override
                            					public void execute(DSResponse response, Object rawData, DSRequest request) {
                            						if (response.getStatus() >= DSResponse.STATUS_SUCCESS) {
                            							SC.say("Save Successful");
                            							form.clearValues();
                            						} else {
                            							SC.warn("Save Failed");
                            						}
                            					}
                            				});
                            			}
                            		});
                            		
                            		layout.addMember(grid);
                            		layout.addMember(form);
                            		layout.addMember(clearButton);
                            		layout.addMember(saveButton);
                            		layout.show();
                            	}
                            datasource.xml file
                            Code:
                            <DataSource 
                            	tableName="CATEGORYS"
                            	ID="testTime"
                            	serverType="sql"
                            	title="Time Test Case"
                            >
                            	<fields>
                            		<field primaryKey="true" name="CATEGORY_PK" type="sequence" hidden="true" sequenceName="CATEGORY_SEQ"></field>
                            		
                            		<field name="CATEGORY_NAME" type="text" length="128" required="true" title="Record Name">
                            			<validators>
                            				<validator type="isUnique"></validator>
                            			</validators>
                            		</field>
                            		
                            		<field name="START_DATE" type="date" useTextField="true" title="Start Date" required="true"></field>
                            		<field name="END_DATE" type="date" useTextField="true" title="End Date" required="true"></field>
                            		
                            		<field name="START_TIME" type="time" title="Start Time" required="true"></field>
                            		<field name="END_TIME" type="time" title="End Time" required="true"></field>
                            	</fields>	
                            </DataSource>
                            Behavior:
                            Entering a filter and going to a new filter cell (either by clicking in it or tabbing) will cause the field to be formatted correctly.
                            i.e. entering "1pm" and then tabbing to a new field will cause the entry to be rewritten as "13:00".

                            However, when performing the filtering action (be either hitting 'enter' inside of a filter cell or by clicking on the filter icon), the entry immediately transforms to "0:00" and, of course, the filtered data is incorrect.

                            Please advise.
                            Last edited by amcculley; 3 Dec 2012, 12:48. Reason: Replaced code with all built-in SmartGwt types instead of custom buttons

                            Comment


                              #15
                              As some additional info - I've tried it with and without the filter editor expression capability enabled and it doesn't make a difference either way.

                              Comment

                              Working...
                              X