Announcement

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

    SpinnerItem and getEnteredValue

    Since using SmartGWT 2.5 and ListGridEditorCustomizer I get an error in my SpinnerItems when trying to retrieve the entered data:
    Code:
    com.google.gwt.core.client.JavaScriptException: (TypeError): self.getEnteredValue is not a function:
    While using 2.4 and createRecordComponent() I was able to validate user-typed input in my number fields with this method.

    What happened to this method?


    I'm using SmartGWT 2.5 and GWT 2.3

    #2
    Can you show a minimal, runnable test case that would allow us to reproduce this error?

    Comment


      #3
      the sample is based on your ListGridEditorCustomizer. I simply changed the IntegerItem (5) to a SpinnerItem with a validator, which calls getEnteredValue():
      Code:
      import com.google.gwt.core.client.EntryPoint;
      import com.smartgwt.client.types.ListGridEditEvent;
      import com.smartgwt.client.types.MultipleAppearance;
      import com.smartgwt.client.util.SC;
      import com.smartgwt.client.widgets.form.fields.CheckboxItem;
      import com.smartgwt.client.widgets.form.fields.DateItem;
      import com.smartgwt.client.widgets.form.fields.FormItem;
      import com.smartgwt.client.widgets.form.fields.PasswordItem;
      import com.smartgwt.client.widgets.form.fields.SelectItem;
      import com.smartgwt.client.widgets.form.fields.SliderItem;
      import com.smartgwt.client.widgets.form.fields.SpinnerItem;
      import com.smartgwt.client.widgets.form.fields.TextItem;
      import com.smartgwt.client.widgets.form.validator.CustomValidator;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridEditorContext;
      import com.smartgwt.client.widgets.grid.ListGridEditorCustomizer;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.client.widgets.grid.ListGridRecord;
      import java.util.Date;
      
      public class MainEntryPoint implements EntryPoint {
      
          @Override
          public void onModuleLoad() {
              final ListGrid countryGrid = new ListGrid();
              countryGrid.setWidth(300);
              countryGrid.setHeight(340);
              countryGrid.setShowAllRecords(true);
      
              ListGridField nameField = new ListGridField("name", "Name", 120);
              nameField.setCanEdit(false);
      
              ListGridField valueField = new ListGridField("value", "Value Field", 170);
      
              countryGrid.setFields(nameField, valueField);
      
              countryGrid.setData(getData());
              countryGrid.setEditorCustomizer(new ListGridEditorCustomizer() {
                  @Override
                  public FormItem getEditor(ListGridEditorContext context) {
                      ListGridField field = context.getEditField();
                      if (field.getName().equals("value")) {
                          NameValueRecord record = (NameValueRecord) context.getEditedRecord();
                          int id = record.getID();
                          switch (id) {
                              case 1:
                                  TextItem textItem = new TextItem();
                                  textItem.setShowHint(true);
                                  textItem.setShowHintInField(true);
                                  textItem.setHint("Some Hint");
                                  return textItem;
                              case 2:
                                  return new PasswordItem();
                              case 3:
                                  return new DateItem();
                              case 4:
                                  CheckboxItem cbi = new CheckboxItem();
                                  cbi.setShowLabel(false);
                                  return cbi;
                              case 5:
                                  final SpinnerItem spinnerItem = new SpinnerItem();
                                  spinnerItem.setMin(-10);
                                  spinnerItem.setMax(10);
                                  spinnerItem.setStep(1);
                                  spinnerItem.setValidators(new CustomValidator() {
                                      @Override
                                      public boolean condition(Object value) {
                                          SC.logWarn("condition: " + spinnerItem.getEnteredValue());
                                          return false;
                                      }
                                  });
                                  spinnerItem.setValidateOnExit(true);
                                  return spinnerItem;
                              case 6:
                                  SelectItem selectItemMultipleGrid = new SelectItem();
                                  selectItemMultipleGrid.setShowTitle(false);
                                  selectItemMultipleGrid.setMultiple(true);
                                  selectItemMultipleGrid.setMultipleAppearance(MultipleAppearance.PICKLIST);
                                  selectItemMultipleGrid.setValueMap("Cat", "Dog", "Giraffe", "Goat", "Marmoset", "Mouse");
                                  return selectItemMultipleGrid;
                              case 7:
                                  SliderItem sliderItem = new SliderItem();
                                  sliderItem.setMaxValue(10);
                                  sliderItem.setWidth(160);
                                  return sliderItem;
                              default:
                                  return context.getDefaultProperties();
                          }
                      }
                      return context.getDefaultProperties();
                  }
              });
      
              countryGrid.setCanEdit(true);
              countryGrid.setEditEvent(ListGridEditEvent.CLICK);
              countryGrid.setEditByCell(true);
      
              countryGrid.draw();
          }
      
          private ListGridRecord[] getData() {
              return new ListGridRecord[]{
                      new NameValueRecord(1, "String Editor", "some string"),
                      new NameValueRecord(2, "Password Editor", "donkeykong"),
                      new NameValueRecord(3, "Date Editor", new Date()),
                      new NameValueRecord(4, "Boolean Editor", Boolean.FALSE),
                      new NameValueRecord(5, "Spinner Int Editor", 5),
                      new NameValueRecord(6, "SelectItem Editor", "Dog"),
                      new NameValueRecord(7, "Slider Editor", 7)
              };
          }
          public static class NameValueRecord extends ListGridRecord {
      
              public NameValueRecord(int id, String name, Object value) {
                  setID(id);
                  setName(name);
                  setValue(value);
              }
      
              public final void setID(int id) {
                  setAttribute("ID", id);
              }
      
              public int getID() {
                  return getAttributeAsInt("ID");
              }
      
              public final void setValue(Object value) {
                  setAttribute("value", value);
              }
      
              public Object getValue() {
                  return getAttributeAsObject("value");
              }
      
              public final void setName(String name) {
                  setAttribute("name", name);
              }
      
              public String getName() {
                  return getAttribute("name");
              }
      
          }
      
      }
      Error msg in console when manually entering a value in the SpinnerItem and then exiting the editor:
      Code:
      08:15:35.999:WARN:Log:TypeError: self.getEnteredValue is not a function
          unnamed() @ :53
          unnamed([object GWTJavaObject], 17826066, [object GWTJavaObject]) @ selectrow/hosted.html?selectrow:56
          unnamed({Obj}, {Obj}, 5, {Obj}) @ :25
          [c]Validator.processValidator(_1=>{Obj},  _2=>{Obj},  _3=>5,  _4=>"custom",  _5=>{Obj}) @ selectrow/sc/modules/ISC_Forms.js:1763
          Canvas.validateField({Obj}, [object Array], 5, {Obj}, {Obj}) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:3816
          Canvas.validateFieldAndDependencies({Obj}, [object Array], 5, {Obj}, {Obj}) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:3801
          FormItem.validate() @ selectrow/sc/modules/ISC_Forms.js:1373
          FormItem._performValidateOnEditorExit(5) @ selectrow/sc/modules/ISC_Forms.js:1586
          FormItem.handleEditorExit() @ selectrow/sc/modules/ISC_Forms.js:1580
          FormItem.elementBlur(undef, undef, undef, undef) @ selectrow/sc/modules/ISC_Forms.js:1559
          DynamicForm.bubbleItemHandler({Obj}, "elementBlur") @ selectrow/sc/modules/ISC_Forms.js:659
          DynamicForm.elementBlur([object HTMLInputElement], {Obj}) @ selectrow/sc/modules/ISC_Forms.js:675
          FormItem._nativeElementBlur([object HTMLInputElement], {Obj}) @ selectrow/sc/modules/ISC_Forms.js:1544
          Class.invokeSuper(_1=>null,  _2=>"$12x") @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:282
          Class.Super(_1=>"$12x",  _2=>[object Arguments]) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:274
          TextItem._nativeElementBlur([object HTMLInputElement], {Obj}) @ selectrow/sc/modules/ISC_Forms.js:1922
          FormItem.._nativeBlurHandler([object HTMLInputElement]) @ selectrow/sc/modules/ISC_Forms.js:806
          FormItem._nativeBlurHandler([object Event]) @ selectrow/sc/modules/ISC_Forms.js:804
          unnamed() @ :0
          Canvas.setFocus(true, undef) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:2993
          Canvas.focus() @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:2997
          [c]EventHandler.hideClickMask(_1=>"isc_DynamicForm_1") @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1753
          EventHandler._clickMaskClick({Obj}) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1801
          [c]EventHandler.clickMaskClick(_1=>{Obj}) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1798
          doHandleMouseDownObservation(_1=>[object MouseEvent],  _2=>undef) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1364
          anonymous([object MouseEvent], undef) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:40
          [c]EventHandler.handleMouseDown(_1=>[object MouseEvent]) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1359
          [c]EventHandler.dispatch(_1=>isc_c_EventHandler_handleMouseDown,  _2=>[object MouseEvent]) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:1649
          anonymous([object MouseEvent]) @ selectrow/sc/modules/ISC_Core.js?isc_version=7.1.js:38
          unnamed() @ :0
          unnamed() @

      Comment

      Working...
      X