Announcement

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

    ListGridField.setSortField() automatical convert to String

    Hello all,

    In my usecase I have to sort my table programmatically and after that, to change some fieldAttributeValues and "commit" them using updateData(Record)

    Code:
            m_ListGrid.setSortField("ListGridField");
    	ResultSet results = (ResultSet)       m_ListGrid.getDataAsRecordList();
    	Record rec = null;
    	for (int i=0;i<results.getLength();i++)
    	{
    		rec = results.get(i);
    		rec.setAttribute("ListGridField", newValue());
    		m_ListGrid.updateData(rec);
    	}
    	m_ListGrid.refreshFields();
    My problem is that when I'm doing this an error appears, stating that a cast from Long to String cannot be operated.

    Note: ListGridField is Integer type in DB

    Does anybody know a fix for this problem or can you help me with a solution for saving the newValue to DB?

    Thank you in advance,
    Driftdone

    #2
    Not enough information - see the FAQ for the information you should provide.

    Also, wrong forum (we'll move the thread).

    Comment


      #3
      I am using SmartGWT 2.4 with Google Chrome 12 or IE9.
      The log error is the following:

      Code:
      10:16:18.588 [ERROR] [customds] 10:16:18.582:XRP9:WARN:RPCManager:java.lang.Long cannot be cast to java.lang.String, response: {operationId: "listing_tariff_system_update", clientContext: undef, context: Obj, transactionNum: 15, httpResponseCode: 200, httpResponseText: "//isc_RPCResponseStart-->[{queueStatus:-..."[170], xmlHttpRequest: [object XMLHttpRequest], transport: "xmlHttpRequest", status: -1, clientOnly: undef, httpHeaders: Obj, isStructured: true, callbackArgs: null, results: Obj, queueStatus: -1, isDSResponse: true, invalidateCache: false, data: "java.lang.Long cannot be cast to java.la..."[49]}
      com.smartgwt.client.core.JsObject$SGWT_WARN: 10:16:18.582:XRP9:WARN:RPCManager:java.lang.Long cannot be cast to java.lang.String, response: {operationId: "listing_tariff_system_update", clientContext: undef, context: Obj, transactionNum: 15, httpResponseCode: 200, httpResponseText: "//isc_RPCResponseStart-->[{queueStatus:-..."[170], xmlHttpRequest: [object XMLHttpRequest], transport: "xmlHttpRequest", status: -1, clientOnly: undef, httpHeaders: Obj, isStructured: true, callbackArgs: null, results: Obj, queueStatus: -1, isDSResponse: true, invalidateCache: false, data: "java.lang.Long cannot be cast to java.la..."[49]}
          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:157)
          at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
          at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
          at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
          at java.lang.Thread.run(Unknown Source)
      Last edited by Driftdone; 29 Jun 2011, 23:16.

      Comment


        #4
        That's just a warning, not an error, and you haven't provided code that would allow anyone to reproduce the problem (please revisit FAQ).

        Comment


          #5
          I edited the latest post, putting the correct error message and the actual code that triggers that error.
          Code:
          	saveButton.addClickHandler(new ClickHandler()
          	{
          		@Override
          		public void onClick(ClickEvent event)
          		{
          			ResultSet results = (ResultSet)listGrid.getDataAsRecordList();
          		
          			Record rec = null;
          			for (int i=0;i<results.getLength();i++)
          			{
          				rec = results.get(i);
          				rec.setAttribute("field", newValue());
          				listGrid.updateData(rec);
          			}
          			listGrid.refreshFields();
          		}
          	}

          Comment


            #6
            This isn't runnable code. Again, if you think you've discovered a problem, you should post a minimal, runnable test case.

            Comment

            Working...
            X