Announcement

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

    Custom FormItem issue

    SmartGWT 2.4
    GWT 2.1
    Firefox 3.6.15
    Win XP

    Hi,

    I am defining a custom FormItem and it does not seem to be working for me. I create a DataSource and assign the fully qualified name of the class to the DataSourceField.setEditorType. I have also tried instantiating an instance of the class and assigning that. The target grid displays fine but I get the following error when attempting to edit the row:

    Uncaught JavaScript exception [_4[i] is undefined] in http://127.0.0.1:8888/trackmysports/sc/modules/ISC_Forms.js, line 325

    which is almost certainly caused by the following message that occurred earlier:

    com.smartgwt.client.core.JsObject$SGWT_WARN: 14:30:43.582:TMR8:WARN:DynamicForm:isc_DynamicForm_6:Problem initializing item: {<snip>} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded

    Is there some registration that I need to do that I missed? The cut down version of the FormItem is shown below. The real one will actually have a reason to be a sub-class but I am just trying to get it to work at all at the moment.

    Thanks,
    John

    Code:
    package com.trackmysports.client.util;
    
    import com.google.gwt.core.client.JavaScriptObject;
    import com.smartgwt.client.widgets.form.fields.TextItem;
    
    public class ElapsedTimeItem extends TextItem {
    
        public static ElapsedTimeFormItemValueFormatter formatter = new ElapsedTimeFormItemValueFormatter();
        public static ElapsedTimeFormItemValueParser parser = new ElapsedTimeFormItemValueParser();
    
        public ElapsedTimeItem() {
            super();
            init();
        }
    
        public ElapsedTimeItem(JavaScriptObject jso) {
            super(jso);
            init();
        }
    
        public ElapsedTimeItem(String name) {
            super(name);
            init();
        }
    
        public ElapsedTimeItem(String name, String title) {
            super(name, title);
            init();
        }
    
        private void init() {
            setAttribute("editorType", "com.trackmysports.client.util.ElapsedTimeItem");
            setEditorValueFormatter(formatter);
            setEditorValueParser(parser);
        }
    }

    #2
    Show the complete stack trace (from the Developer Console) - see FAQ.

    Note your post is in the wrong forum. We'll move it.

    Comment


      #3
      Apologies on both counts. Here is the stack trace:

      15:19:19.915:TMR4:WARN:DynamicForm:isc_DynamicForm_9:Problem initializing item: {width: 31,
      record: Obj,
      rowNum: 5,
      colNum: 1,
      name: "FLEXBEAN_NOTES",
      valueMap: undef,
      valueIcons: undef,
      imageURLPrefix: undef,
      imageURLSuffix: undef,
      baseURL: undef,
      imgDir: undef,
      textAlign: "left",
      valueIconLeftPadding: 2,
      valueIconRightPadding: 2,
      autoCompleteCandidates: undef,
      uniqueMatch: undef,
      containerWidget: [GridBody ID:isc_GameMeetDataEntryPanel_1_0_body],
      grid:[ListGrid ID:isc_GameMeetDataEntryPanel_1_0],
      type: "text",
      editorType: "com.trackmysports.client.util.ElapsedTim..."[45],
      canTabToIcons: false,
      validators: Array[2],
      title: "Notes",
      primaryKey: false,
      hidden: false,
      length: 30,
      required: true,
      canEdit: true,
      editorProperties: Obj,
      handleChanged: [o]ComboBoxItem.handleChanged(),
      keyDown: keyDown(),
      inactiveEditorMouseDown: inactiveEditorMouseDown(),
      elementFocus: [o]ComboBoxItem.elementFocus(),
      focusInItem: [o]ComboBoxItem.focusInItem(),
      formatEditorValue: formatEditorValue(),
      parseEditorValue: parseEditorValue()} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded
      15:19:19.919:TMR4:WARN:DynamicForm:isc_DynamicForm_9:Problem initializing item: {width: 146,
      record: Obj,
      rowNum: 5,
      colNum: 9,
      name: "split_mile_7",
      valueMap: undef,
      valueIcons: undef,
      imageURLPrefix: undef,
      imageURLSuffix: undef,
      baseURL: undef,
      imgDir: undef,
      textAlign: "right",
      valueIconLeftPadding: 2,
      valueIconRightPadding: 2,
      autoCompleteCandidates: undef,
      uniqueMatch: undef,
      containerWidget: [GridBody ID:isc_GameMeetDataEntryPanel_1_0_body],
      grid:[ListGrid ID:isc_GameMeetDataEntryPanel_1_0],
      type: "text",
      editorType: "com.trackmysports.client.util.ElapsedTim..."[45],
      canTabToIcons: false,
      validateOnChange: false,
      validateOnExit: true,
      validators: Array[1],
      title: "Mile Split 7",
      primaryKey: false,
      hidden: false,
      length: 255,
      required: false,
      canEdit: true,
      editorProperties: Obj,
      handleChanged: [o]ComboBoxItem.handleChanged(),
      keyDown: keyDown(),
      inactiveEditorMouseDown: inactiveEditorMouseDown(),
      elementFocus: [o]ComboBoxItem.elementFocus(),
      focusInItem: [o]ComboBoxItem.focusInItem(),
      formatEditorValue: formatEditorValue(),
      parseEditorValue: parseEditorValue()} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded
      15:19:19.925:TMR4:WARN:DynamicForm:isc_DynamicForm_9:Problem initializing item: {width: 31,
      record: Obj,
      rowNum: 5,
      colNum: 20,
      name: "won_lost",
      valueMap: undef,
      valueIcons: undef,
      imageURLPrefix: undef,
      imageURLSuffix: undef,
      baseURL: undef,
      imgDir: undef,
      textAlign: "left",
      valueIconLeftPadding: 2,
      valueIconRightPadding: 2,
      autoCompleteCandidates: undef,
      uniqueMatch: undef,
      containerWidget: [GridBody ID:isc_GameMeetDataEntryPanel_1_0_body],
      grid:[ListGrid ID:isc_GameMeetDataEntryPanel_1_0],
      type: "text",
      editorType: "com.trackmysports.client.util.ElapsedTim..."[45],
      canTabToIcons: false,
      validators: Array[1],
      title: "Won/Lost",
      primaryKey: false,
      hidden: false,
      length: 255,
      required: false,
      canEdit: true,
      editorProperties: Obj,
      handleChanged: [o]ComboBoxItem.handleChanged(),
      keyDown: keyDown(),
      inactiveEditorMouseDown: inactiveEditorMouseDown(),
      elementFocus: [o]ComboBoxItem.elementFocus(),
      focusInItem: [o]ComboBoxItem.focusInItem(),
      formatEditorValue: formatEditorValue(),
      parseEditorValue: parseEditorValue()} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded
      15:19:19.927:TMR4:WARN:DynamicForm:isc_DynamicForm_9:Problem initializing item: {width: 31,
      record: Obj,
      rowNum: 5,
      colNum: 21,
      name: "position",
      valueMap: undef,
      valueIcons: undef,
      imageURLPrefix: undef,
      imageURLSuffix: undef,
      baseURL: undef,
      imgDir: undef,
      textAlign: "left",
      valueIconLeftPadding: 2,
      valueIconRightPadding: 2,
      autoCompleteCandidates: undef,
      uniqueMatch: undef,
      containerWidget: [GridBody ID:isc_GameMeetDataEntryPanel_1_0_body],
      grid:[ListGrid ID:isc_GameMeetDataEntryPanel_1_0],
      type: "text",
      editorType: "com.trackmysports.client.util.ElapsedTim..."[45],
      canTabToIcons: false,
      validators: Array[1],
      title: "Position",
      primaryKey: false,
      hidden: false,
      length: 255,
      required: false,
      canEdit: true,
      editorProperties: Obj,
      handleChanged: [o]ComboBoxItem.handleChanged(),
      keyDown: keyDown(),
      inactiveEditorMouseDown: inactiveEditorMouseDown(),
      elementFocus: [o]ComboBoxItem.elementFocus(),
      focusInItem: [o]ComboBoxItem.focusInItem(),
      formatEditorValue: formatEditorValue(),
      parseEditorValue: parseEditorValue()} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded
      15:19:19.929:TMR4:WARN:DynamicForm:isc_DynamicForm_9:Problem initializing item: {width: 31,
      record: Obj,
      rowNum: 5,
      colNum: 22,
      name: "opponent",
      valueMap: undef,
      valueIcons: undef,
      imageURLPrefix: undef,
      imageURLSuffix: undef,
      baseURL: undef,
      imgDir: undef,
      textAlign: "left",
      valueIconLeftPadding: 2,
      valueIconRightPadding: 2,
      autoCompleteCandidates: undef,
      uniqueMatch: undef,
      containerWidget: [GridBody ID:isc_GameMeetDataEntryPanel_1_0_body],
      grid:[ListGrid ID:isc_GameMeetDataEntryPanel_1_0],
      type: "text",
      editorType: "com.trackmysports.client.util.ElapsedTim..."[45],
      canTabToIcons: false,
      validators: Array[1],
      title: "Opponent",
      primaryKey: false,
      hidden: false,
      length: 255,
      required: false,
      canEdit: true,
      editorProperties: Obj,
      handleChanged: [o]ComboBoxItem.handleChanged(),
      keyDown: keyDown(),
      inactiveEditorMouseDown: inactiveEditorMouseDown(),
      elementFocus: [o]ComboBoxItem.elementFocus(),
      focusInItem: [o]ComboBoxItem.focusInItem(),
      formatEditorValue: formatEditorValue(),
      parseEditorValue: parseEditorValue()} - derived FormItem class is: com.trackmysports.client.util.ElapsedTimeItem. Please make sure the relevant module is loaded
      15:19:19.938:TMR4:WARN:Log:TypeError: _4[i] is undefined
      DynamicForm.setValues(_1=>{Obj}, _2=>true)
      DynamicForm.initWidget(=>{Obj}, undefined=>{Obj}, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef, undefined=>undef)
      Canvas.init(_1=>{Obj}, _2=>{Obj}, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef)
      Class.completeCreation(_1=>{Obj}, _2=>{Obj}, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef)
      [c]Class.create(_1=>{Obj}, _2=>{Obj})
      ListGrid.makeEditForm(5, 8)
      ListGrid.showInlineEditor(5, 8, true, true, null)
      ListGrid._startEditing(5)
      [c]Class.fireCallback(_1=>{Obj}, _2=>undef, _3=>[object Array], _4=>{Obj}, _5=>true)
      Timer._fireTimeout("$ir996")
      unnamed()
      unnamed()

      Comment


        #4
        You've somehow introduced a null into the array of FormItems being created for editing ListGrid rows. If you can't figure out how you're doing this, work toward creating a runnable code sample that reproduces the problem.

        Comment


          #5
          Ok, thanks, that is what I will do.

          Comment


            #6
            Here is the test case. I just run it and click on one of the data items in the Custom column of the grid and the error occurs.

            It only let me upload 5 files, I had four classes plus the gwt.xml, so I was not able to upload the web.xml, but there is not much to it. Please let me know if you need anything else.

            Thanks,
            John
            Attached Files

            Comment


              #7
              Sorry we weren't clear: the best way to proceed is to narrow it down to a small test case, eg, a single file. You will either find the bug in your application or demonstrate a bug in SmartGWT.

              Comment


                #8
                Well, OK, but I can't put the gwt.xml, web.xml and the java code in the same file, so I assume you mean a single java file with multiple classes. From my perspective it is not the clearest way to show an issue, but if that is how you want it, that is how I will do it.

                Thanks for your help!
                John

                Comment


                  #9
                  The clearest way to show an issue is minimal code that runs in a standard environment. Work toward creating a single file with no extraneous code that can be dropped into a standard project (we don't need your .gwt.xml etc). Along the way, you may discover that it's just a bug in your application, and just fix that.

                  Comment


                    #10
                    Yes, that does make sense and I am quite confident that the problem is in my code, not yours. Attached is my single file example, which still fails the same way.

                    Thanks for your help,
                    John
                    Attached Files

                    Comment


                      #11
                      Why do you set the editorType within the custom formitem? Try dropping that.

                      Comment


                        #12
                        I set the editorType because if I do not then the form item is instantiated as a TextItem by the ListGrid and none of my code is used.

                        Comment


                          #13
                          Ah, but you got me thinking, in reducing the example to a single file I made the custom form item an inner class, so the name I am setting for the editorType is no longer valid. Since I am getting the same error as before, it seems clear that this is where my problem is.

                          Isomorphic, when creating a custom form item, how do I go about insuring that the ListGrid will instantiate my class rather than a TextItem?

                          Thanks,
                          John

                          Comment


                            #14
                            davidj6 is correct, you should not be calling setAttribute("editorType") and this is not required to cause your custom item's code to be used. Be sure to look at the docs for DataSourceField.setEditorType() - as is explained there, your custom FormItem is like a template for creating FormItems in different components. This means there are special rules for how you add custom behaviors.

                            Comment


                              #15
                              Yes, I have read all that. I understand that the settings are what is being saved and the ListGrid will instatiate an appropriate FormItem and populate it with the saved settings when it needs to. But what I have seen is that it actually instantiates a TextItem rather than my subclass. This means that any changes I make in the subclass (additional methods and/or fields) are not there when the field is edited. I was under the impression that I could specify a sub-class that ListGrid would instatiate as the editor. Is that not the case?

                              Thanks,
                              John

                              Comment

                              Working...
                              X