Announcement

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

    EditorValueFormatter and focus behavior

    Hi guys!

    I have a FormItem on a DynamicForm and I've set it with the following editorType:
    Code:
    public class CustomEditorType extends TextItem {
    
    	public CustomEditorType() {
    		super();
    		this.setEditorValueFormatter(new FormItemValueFormatter() {
    			
    			public String formatValue(Object value, Record record, DynamicForm form, FormItem item) {
    				boolean hasFocusInOurApp = item.getShowIcons();
    				
    				if (hasFocusInOurApp) {
    					return "1";
    				} else {
    					return "2";
    				}
    			}
    		});
    	}
    }
    I would like to show a different value to the user when the formitem has the focus.
    The problem is that this value formatter is only called on a redraw.
    How can this case be solved without a redraw?

    Thank you in advance for any help you can provide.

    #2
    What different value? If you're trying to implement a hint that vanishes when the field gets focus, use showHintInField.

    Comment


      #3
      No, not a hint, but
      the item shows value "3 kilo" or "twenty banana crates" as value (output from FormItemValueFormatter.formatValue) until the item receives focus, at that point (and not when the user is typing) it should change into "3" or "twenty crates" or whatever value. The FormItemValueFormatter.formatValue can handle this, but it doesn't seem to be called when the item receives focus.

      Is there something better to get this behavior?
      thanks,

      Comment


        #4
        The formatter is not going to be invoked unless the value has logically changed. We'll look at what it would take to add a flag saying the formatter should be invoked on focus/blur.

        Comment


          #5
          Which items do you need this on? TextItem only?

          Comment


            #6
            We've gone ahead and added a new attribute formatOnFocusChange to TextItem to handle this case - please give it a try and let us know if it works for you and if it meets your needs.

            It'll be present in the next nightly build.

            Thanks
            Isomorphic Software

            Comment


              #7
              Thanks,
              integrated with the 25-05-2011 build and this works like a charm!

              Comment

              Working...
              X