Hi All,

I am using a datagrid which has a table listener and when I click on
any cell, I am adding a textbox to that cell by copying the text from
the cell to the textbox. After editing the cell if I press ENTER key
or move the focus from the textbox I am copying the value back to the
cell and invoking the database update.

Here is how my code look like

dataGrid.addTablelistener {
  public void onCellClicked(SourcesTableEvents sender, final int
row,final int cell) {

   //code for copying the cell text to text box
   //having a listener to that textbox

   textBox.addFocusListener(new FocusListenerAdapter() {
       public void onLostFocus(Widget sender) {

          //code for DB update

      }
   });

  textBox.addKeyboardListener(new KeyboardListenerAdapter() {
        public void onKeyPress(Widget sender,char keyCode, int modifiers) {

                    //code for DB update

         }
  });

});



Here my doubt or concern is that...in both onLostFocus and onKeyPress
I am using the same code for Database update.

how can I make that code into a single method and call in both the
places. So that I can avoid redundancy of code in two places.

When I try to do that inside oncellDoubleclicked, the scope is not
read..
When I try to write outside oncellDoubleclicked, then also I am not
getting the method inside these two methods(KeyPress and LostFocus)

Any help or advise would be appreciated

Thanks
Suren
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to