Search code examples
javagwtgxtonblur

GXT field value update onblur


Let's talk about the GXT v3 Fields.

There are two frames A & B.

Frame A has a set of fields and a submit button SA. Submit button reads the Fields in Frame A. Frame B has only a submit button SB, which reads the Fields in Frame A.

Perform the following steps.

  1. Enter data into a field F1 in Frame A.
  2. Click on an region in Frame A or click on submit button of Frame A.
  3. Debug on F1 getCell() will show that it has a value.

Perform the following alternate steps.

  1. Enter data into a field F1 in Frame A.
  2. Click on button in Frame B.
  3. Debug on F1 getCell() will show that it does not have a value.

This is problematic for me. Therefore, I wish to know the difference in the onblur actions of the fields in Frame A between clicking on button SA and button SB.

What actions does onblur of Field F1 performs when clicking on Frame A that the onblur of Field F1 does not perform when clicking on Frame B?

If I know that difference, then I would be able to execute that difference.


Solution

  • The solution was simple.

    Simply choose any two fields in frame A.

    public void focusA(){
      frameA.getField1().focus();
      frameA.getField2().focus();
      frameA.focus();
    }
    

    The button click handler in Frame B should call focusA() before flushing the field values.

    What focusA() does is

    • focus on any other field would trigger update from DOM to Field Editor value, except the field being focused.
    • in which case, trigger another random field to trigger update of first field.
    • then prevent focus from sticking to the last field being focused (to prevent inadvertent field editing by user) by focusing on the container.