Announcement

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

    ComboBoxItem.getEnteredValue() not a function?

    Hi,

    SC_SNAPSHOT-2011-03-24/EVAL Deployment
    FireFox 3.6.16

    In my custom editor, which extends ComboBoxItem, I'm calling the getEnteredValue() and I'm getting the below error.

    I have added a standalone test case. Type in "test%" as soon as you hit '%' the error is shown.

    Originally posted by javadoc

    String ComboBoxItem.getEnteredValue()

    Returns the raw text value typed into this form field, which can differ from FormItem.getValue() in various cases - for example:
    for items that constrain the value range, such as a DateItem with enforceDate:true, or a ComboBoxItem with addUnknownValues:false
    for items with a defined valueMap or edit value formatter and parser functions which converts display value to data value
    while the item has focus if changeOnKeypress is false


    Returns:
    type: String - current entered value
    Code:
    public class Standalone implements EntryPoint {
    		
    	private static Canvas masterPanel = null;
    	
    	boolean pickerShowing = false;
    	
    	public void onModuleLoad() {
    		 
    		 devConsole = new Button("DEV Console");
    		 devConsole.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
    
    				public void onClick(ClickEvent event) {
    						SC.showConsole();
    				}
    		});	 
    	  		
    		//masterPanel should be a Layout
    		masterPanel = new Canvas(); 
    		masterPanel.setHeight100();
    		masterPanel.setWidth100();
    		masterPanel.setStyleName("pageBackground"); //background style from skin
    		
    		masterPanel.addChild(testCase14());
    		masterPanel.draw();	
    	}
    
    	    public DynamicForm testCase14() {   
    		  	  
    	        DataSource dataSource = new DataSource();   
    	  
    	        DataSourceField myTestField = new DataSourceField();   
    	        myTestField.setName("textField");   
    	        myTestField.setTitle("textField");   
    	        myTestField.setType(new MyComboBoxItem());   
    	        myTestField.setEditorType(new MySimpleComboBoxEditor());
    	  
    	        dataSource.setFields(myTestField);   
    	          
    	        DynamicForm form = new DynamicForm();   
    	        form.setHeight(170);   
    	        form.setWidth(500);
    	        form.setDataSource(dataSource);
    	   
    			return form;
    	    }
    }
    
    public class MyComboBoxItem extends SimpleType {   
        public MyComboBoxItem() {   
            super("myComboBoxType", FieldType.ANY);   
    
        }  
    
    }
    
    public class MySimpleComboBoxEditor extends ComboBoxItem {
    	
    	public MySimpleComboBoxEditor() {
    		super();
    		
    		setChangeOnKeypress(false);
    		setCompleteOnTab(true);
    		setSelectOnFocus(true);
    		setAddUnknownValues(false);
    		
    		addKeyPressHandler(new KeyPressHandler() {
    			
    			public void onKeyPress(KeyPressEvent event) {
    				
    				if(event.getCharacterValue() != null && event.getCharacterValue().equals((int) '%')){
    					//to avoid null pointers in grid
    					MySimpleComboBoxEditor editor = (MySimpleComboBoxEditor) event.getSource();
    					String enteredValue = editor.getEnteredValue();
    					
    //					String enteredValue = MySimpleComboBoxEditor.this.getEnteredValue();
    					SC.logWarn("entered value is: " + enteredValue);
    				}
    				
    			}
    		});
    	}
    The below error is generated in our app, not the stand alone test case.
    But you should get the same.

    Code:
    Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): self.getEnteredValue is not a function
     fileName: http://127.0.0.1:8888
     lineNumber: 107
     stack: ()@http://127.0.0.1:8888:107
    @:0
    ([object GWTJavaObject],5111972,[object GWTJavaObject])@http://127.0.0.1:8888/silkroad/hosted.html?silkroad:56
    ([object Object],[object Object],"`",37)@http://127.0.0.1:8888:93
    ((function () {var param = {item: arguments[0], form: arguments[1], keyName: arguments[2], characterValue: arguments[3]};var event = __gwt_makeJavaInvoke(1)(null, 5505119, param);__gwt_makeJavaInvoke(1)(selfJ, 5111972, event);var ret = __gwt_makeJavaInvoke(0)(event, 1507334);return !ret;}),[object Object],[object Object])@http://127.0.0.1:8888:65
    @:0
    (null,106,(function () {var param = {item: arguments[0], form: arguments[1], keyName: arguments[2], characterValue: arguments[3]};var event = __gwt_makeJavaInvoke(1)(null, 5505119, param);__gwt_makeJavaInvoke(1)(selfJ, 5111972, event);var ret = __gwt_makeJavaInvoke(0)(event, 1507334);return !ret;}),[object Object],[object Object])@http://127.0.0.1:8888/silkroad/hosted.html?silkroad:56
    ([object Object],[object Object],"`",37)@http://127.0.0.1:8888:16
    ([object Object],[object Object],"`",37)@http://127.0.0.1:8888:13
    isc_FormItem__fireKeyPressHandlers([object Object],[object Object],"`",37)@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Forms.js:1549
    isc_FormItem_handleKeyPress([object Object],[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Forms.js:1548
    isc_c_Class_invokeSuper(null,"handleKeyPress")@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:305
    isc_c_Class_Super("handleKeyPress",[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:297
    isc_TextItem_handleKeyPress([object Object],[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Forms.js:1856
    isc_c_Class_invokeSuper(null,"handleKeyPress")@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:305
    isc_c_Class_Super("handleKeyPress",[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:297
    isc_ComboBoxItem_handleKeyPress([object Object],[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Forms.js:2528
    isc_c_EventHandler_bubbleEvent([object Object],"keyPress",[object Object])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:1573
    isc_c_EventHandler_handleKeyPress([object KeyboardEvent])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:1333
    isc_c_EventHandler__handleNativeKeyPress([object KeyboardEvent])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:1328
    isc_c_EventHandler_dispatch(isc_c_EventHandler__handleNativeKeyPress,[object KeyboardEvent])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:1636
    anonymous([object KeyboardEvent])@http://127.0.0.1:8888/silkroad/sc/modules/ISC_Core.js:63
    
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:237)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:129)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.smartgwt.client.widgets.form.fields.ComboBoxItem.getEnteredValue(ComboBoxItem.java)
    Last edited by bade; 17 Apr 2011, 09:30.

    #2
    Hi,

    Any update on this?

    Regards,
    Bart

    Comment


      #3
      No resolution yet. We see the issue and will let you know when we have a solution or workaround.

      Comment


        #4
        I hate to be a pain, but is there a resolution yet?

        thanx
        Bart

        Comment


          #5
          Hi Bart
          A workaround: Instead of using event.getSource() - try event.getItem()
          This will give you back a TextItem instance but you can call the getEnteredValue() API on that object.
          Also note that you may need to use 'keyUp' rather than 'keyPress' - the enteredValue is updated at the end of the keyPress thread so during the keyPress handler it will reflect the value without the keyPress character.

          Comment


            #6
            Thanks... that seems to be working for the KeyPress event.

            You are right, using the KeyUp event would be a lot better, only one big problem... what is the keyName for '%'?
            '%' is a combination of two keys (shift + ù) => so it doesn't work with keyUp, as the KeyUpEvent doesn't have
            a getCharacterValue() like the Keypress event :-(

            My next step was to implement more or less the same logic in the "onEditor" exit. But sadly enough the 'enteredValue' is no longer available in the onBlur
            when setAddUnknownValues(false). If setAddUnknownValues(true), the enteredValue is available in the onBlur.

            Maybe it's best that I explain the idea behind all of this...

            User can initiate a search in three ways:
            1) typing a value and pressing '%' (hence the onKeyPress)
            2) Typing the exact value and tabbing out => exact search is initiated.
            If there's a result good, otherwise an error is shown 'not a valid value'.
            3) Double clicking an empty field, search window is shown

            Options 1 + 3 are working.
            For option 2, I wanted to use the "enteredValue" and check if it exists in the underlying valueMap if so, great.
            If not try to find an exact match (initiate search).

            Regards,
            Bart
            Last edited by bade; 6 Apr 2011, 04:46.

            Comment


              #7
              Probably a couple of ways this could be achieved.

              1) For catching "%" when the character value is not available you could use the keyName + EventHandler.shiftKeyDown(). This might allow you to use keyUp and keep your current approach

              2) An alternative might be to get rid of addUnknownValues(false) and instead have just completeOnTab(true) and have either a changedHandler or editorExitHandler perform the search based on the entered value.

              Will either of these get you what you need?

              Comment

              Working...
              X