Announcement

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

    ListGrid.getSelectedRecord causes an exception

    Hi,
    I am working with the nightly build SNAPSHOT_v8.3d_2012-10-10/LGPL Development Only (built 2012-10-10).

    I have a RecordClickHandler on a ListGrid in which I call ListGrid.getSelectedRecord().
    I get the following exception:

    java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
    at com.smartgwt.client.widgets.grid.ListGrid.getSelectedRecord(ListGrid.java)

    Thanks

    #2
    Hi
    This hasn't been solved yet - also in the nightly build of 2012-10-12.
    This also happens when I call
    com.smartgwt.client.widgets.grid.ListGrid.getRecord

    There is an exception:

    java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord

    This is a major problem in this version.
    Thanks
    Rottem

    Comment


      #3
      You appear to be the only one afflicted by this.

      A minimal, ready-to-run test case is what's needed.

      Comment


        #4
        Working just fine for me with 3.1d-2012-10-22.
        ListGrid.getSelectedRecord() and ListGrid.getSelectedRecords() are prototyped as returning ListGridRecord and they return ListGridRecord.

        RecordClickEvent.getRecord () is prototyped as returning Record, and returns a ListGridRecord.

        Comment


          #5
          We've been getting this error for quite some time as well - one of the reasons we haven't moved to 3.1 yet.

          I'm going to try the latest nightly (10/23) and see if it fixes it.

          By any chance - is the other person who is having issues using a clientOnly dataSource? I haven't looked into it too much but I noticed a warning in the log about the ListGrid having autoFetchData(true) without a dataSource being set but there is a dataSource set... it is just clientOnly instead of persisted.

          Comment


            #6
            Is that build broken? Throwing GWT exception whenever I try to show a Canvas. App won't even start. I've cleared cache, recompiled, etc.

            Comment


              #7
              3.1d 10/22 nightly loads fine but still getting ClassCastException 'Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord'.

              Identical code works fine in 3.0. Not sure why this has never worked for us in 3.1.

              I'll try to dig into the code. If someone calls setdata() and passes in a Record and then tries to call getRecords(), would that cause a problem?
              Last edited by amcculley; 23 Oct 2012, 20:38.

              Comment


                #8
                Why doesn't this work any more?

                Standalone test case. 3.1d Power - Nightly 10/22

                Code:
                		VLayout testLayout = new VLayout();
                		testLayout.setSize("640", "480");
                		
                		DataSource svcActDs = DataSource.get("service_accounts");
                		final DataSource ds = new DataSource();
                		ds.setClientOnly(true);
                		ds.setFields(svcActDs.getFields());
                		
                		final ListGrid grid = new ListGrid();
                		grid.setSize("100%", "100%");
                		grid.setDataSource(ds);
                		grid.setAutoFetchData(true);
                		
                		grid.addSelectionChangedHandler(new SelectionChangedHandler() {
                
                			@Override
                			public void onSelectionChanged(SelectionEvent event) {
                				if (grid.getRecords().length < 10) {
                					SC.say("Less than 10 records!");
                				}
                			}
                			
                		});
                		
                		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) {
                				Record record = new Record();
                				record.setAttribute("SERVICE_ACCOUNT_NUMBER", form.getValue("SERVICE_ACCOUNT_NUMBER"));
                				ds.addData(record);
                				form.clearValues();
                			}
                			
                		});
                		testLayout.addMember(addBtn);
                		
                		testLayout.show();
                Here is ds.xml - picked one that has nothing fancy.
                Code:
                <DataSource 
                	tableName="SERVICE_ACCOUNTS"
                	ID="service_accounts"
                	serverType="sql"
                	title="Service Account"
                	titleField="SERVICE_ACCOUNT_NUMBER"
                >
                	<fields>
                		<field name="SERVICE_ACCOUNT_PK" type="sequence" sequenceName="SERVICE_ACCOUNTS_SEQ" primaryKey="true" hidden="true"></field>
                		<field name="SERVICE_ACCOUNT_NUMBER" length="255" type="text" required="true">
                			<validators>
                				<validator type="isUnique"/>
                			</validators>
                		</field>
                	</fields>
                </DataSource>
                Last edited by amcculley; 23 Oct 2012, 21:26.

                Comment


                  #9
                  We're not aware of a fundamental problem with the 10/23 build like you describe (everything basically broken out of the box).

                  We're also not sure why you'd be getting this warning about a grid having no dataSource specified if it actually does have a dataSource specified. You shouldn't be seeing that warning just because the DS is client-only and we're not aware of a case where this would behave incorrectly.

                  Anyway we'll look at your standalone test case and let you know what we find.

                  Comment


                    #10
                    Thanks for taking a look. I've been trying to hack around some sort of work-around for a couple of hours with no luck.

                    As for the 10/23 build, I'll try again when I have more time. Was anything changed with the load_skin.js or .css? We use a modified version of the Enterprise 3.1 skin - that is the only thing I can think of that would cause the entire app to throw an exception and not load.

                    Comment


                      #11
                      We see what's causing the class cast exception (Record to ListGridRecord). It's an oddity that would only show up with clientOnly dataSources.
                      We've applied a fix in the framework which should resolve this

                      Why don't you try the next nightly build (Oct 25) and see if this fixes the problem for you and also if the oddities you saw with the Oct 23 build persist. If they do, let us know along with any debugging info you can give us to help get to thew bottom of it and we'll investigate

                      Comment


                        #12
                        Thanks for the quick response. I'll try out the next nightly.

                        Comment


                          #13
                          ClassCast exception is fixed in 10/25 nightly.

                          The app not loading is due to a new bug introduced with Calendar. I posted the bug here:

                          http://forums.smartclient.com/showthread.php?t=24107

                          Comment


                            #14
                            Exceptions in getRecords

                            There is another exception in ListGrid. This happens in version
                            SmartClient Version: v8.3p_2012-11-24/LGPL Development Only (built 2012-11-24)

                            I get the following exception:
                            java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord
                            at com.smartgwt.client.widgets.grid.ListGrid.convertToListGridRecordArray(ListGrid.java:13483)
                            at com.smartgwt.client.widgets.grid.ListGrid.getRecords(ListGrid.java:12893)

                            This happens when I call ListGrid.getRecords() from onDataArrived handler

                            Rottem

                            Comment


                              #15
                              Problem not solved.

                              Nightly build from 29-11-2012.

                              getSelectedRecord() from client only datasource cause exception:

                              Caused by: java.lang.ClassCastException: com.smartgwt.client.data.Record cannot be cast to com.smartgwt.client.widgets.grid.ListGridRecord at com.smartgwt.client.widgets.grid.ListGrid.getSelectedRecord(ListGrid.java)

                              Comment

                              Working...
                              X