Announcement

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

    SelectItem, clearValue() and PickList

    SmartClient Version: v9.1p_2014-11-09/Pro Deployment (built 2014-11-09)
    FF 24.8.1 ESR

    Hello,
    When I call SelectItem.clearValue(), the value is cleared back to the default, however, if I click on the select item to display the pick list, the previously selected items appear checked briefly before being redrawn and cleared. Is there a way I can force the pick list to redraw prior to being made visible so I do not see this flashing effect.
    Thanks

    #2
    Looking in a couple of different browsers, we can't see even a brief flash of the old state of the control.

    Best guess, you are looking in GWT Development Mode which severely slows things down, or you perhaps have some Firefox development tools enabled that are causing the browser to repaint where it normally would not. In either case, it seems that normal end users would not be able to perceive the old state being shown to them.

    Comment


      #3
      Indeed, you are correct, it is a GWT Development Mode quirk. I thought I had seen it in non-development mode, however, I was mistaken.

      One other question here if you do not mind.

      Say you have some pick list properties that under some key press scenario you clear the item value as follows:

      Code:
      ListGrid pickListProperties = new ListGrid();
      pickListProperties.addKeyPressHandler(new KeyPressHandler() {
      
          @Override
          public void onKeyPress(KeyPressEvent event) {
              ...
              selectItem.clearValue();
              ...
          }
      });
      selectItem.setPickListProperties(pickListProperties);
      This results in the form item field value being cleared, however, the still visible drop-down/pick list still shows the selection(s) checked. (multiple=true and multipleAppearance=picklist).

      Can you please recommend how I could get the pick list to immediately redraw with the cleared selection to match the form field?

      Thanks

      Comment


        #4
        We have not been able to reproduce that behavior with this code:
        Code:
        public class Testing implements EntryPoint {
            public void onModuleLoad() {
            	
                DataSource animalXmlDS = AnimalXmlDS.getInstance();  
                
                final DynamicForm form = new DynamicForm();  
                form.setWidth(300);  
          
                ListGrid pickListProperties = new ListGrid();
                pickListProperties.setCanFocus(true);
          
                final SelectItem selectItem = new SelectItem("commonName");
                selectItem.setWidth(240);  
                selectItem.setPickListWidth(450);  
                selectItem.setOptionDataSource(animalXmlDS);  
                selectItem.setPickListProperties(pickListProperties);
                selectItem.setMultiple(true);
                selectItem.setMultipleAppearance(MultipleAppearance.PICKLIST);
                selectItem.setCanFocus(true);
                
                pickListProperties.addKeyPressHandler(new KeyPressHandler() {
        			@Override
        			public void onKeyPress(KeyPressEvent event) {
        					selectItem.clearValue();
        			}
        		});
                        
                form.setItems(selectItem);  
                
                form.draw();
            } 
        }
        Could you please provide a complete test case that reproduces the problem?

        Comment


          #5
          Interesting; I will see what I can do to extract out a test case for you.
          Regards

          Comment


            #6
            Try this slight modification to your example.

            Code:
            public class Testing implements EntryPoint {
                public void onModuleLoad() {
                	
                    DataSource animalXmlDS = AnimalXmlDS.getInstance();  
                    
                    final DynamicForm form = new DynamicForm();  
                    form.setWidth(300);  
              
                    final SelectItem selectItem = new SelectItem("commonName");
                    ListGrid pickListProperties = new ListGrid();
                    pickListProperties.addKeyPressHandler(new KeyPressHandler() {
            			@Override
            			public void onKeyPress(KeyPressEvent event) {
            					selectItem.clearValue();
            			}
            		});
                    pickListProperties.setCanFocus(true);
              
                    selectItem.setWidth(240);  
                    selectItem.setPickListWidth(450);  
                    selectItem.setOptionDataSource(animalXmlDS);  
                    selectItem.setPickListProperties(pickListProperties);
                    selectItem.setMultiple(true);
                    selectItem.setMultipleAppearance(MultipleAppearance.PICKLIST);
                    selectItem.setCanFocus(true);
                            
                    form.setItems(selectItem);  
                    
                    form.draw();
                } 
            }
            NOTE: Strangely, in your original example, I found the onKeyPress event wasn't even being fired for me, so selectItem.clearValue() wasn't being called.

            Comment


              #7
              The issue in the original code is that the keypress handler was being applied to the pickListProperties *after* they'd already been processed by the call to setPickListProperties() - so the keyPress handler wasn't being installed on the formItem at all.

              We'll take another look and update here when we have more information

              Comment


                #8
                We've made a few changes in this area, one of which should address your issue. Please retest with a build dated December 25 or later.

                Comment


                  #9
                  Thank you.

                  Comment

                  Working...
                  X