Thanks Jim,

It works. I tried putting it inside the tableListener earlier. Thats
the reason it didnt work for me :-)

Thanks again
Suren

On May 25, 6:35 pm, Jim <[email protected]> wrote:
> dataGrid.addTablelistener {
>   public void onCellClicked(SourcesTableEvents sender, final int
> row,final int cell) {
>    textBox.addFocusListener(new FocusListenerAdapter() {
>        public void onLostFocus(Widget sender) {
>               callDB(...);//pass whatever you want based on sender
>       }
>    });
>
>   textBox.addKeyboardListener(new KeyboardListenerAdapter() {
>         public void onKeyPress(Widget sender,char keyCode, int
> modifiers) {
>                 callDB(...);//pass whatever you want
>          }
>   });
>
> });
>
> private void callDB(...) {//must be outside of
> dataGrid.addTablelistener
>
> }
>
> Please see the above code. If you are not satisfied with the above
> code, you can use one class that implements FocusListener and
> KeyboardListener.
>
> Jim
>
> http://www.gwtorm.com- GWT ORMhttp://code.google.com/p/dreamsource-orm/
>
> On May 25, 8:51 am, Suren <[email protected]> wrote:
>
>
>
> > 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- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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