I only know a bad way to do this, so I'd like someone else to show me
a better way to do this.

As with most GWT Cells, as soon as I want to do something different, I
have to create my own. So I suggest you look up the code for
EditTextCell, copy and paste it into a new MyEditTextCell and then
change the commit() method to do what you want.

In my case, I needed EditTextCell to use a textarea instead of a
textbox, so I had already copied and pasted the code out to make it
use a textarea. When the requirement came down that I needed to give
people a confirm when they changed the text (sigh), I modified the
commit method similar to:

        private void commit(final Context context, final Element parent,
final ViewData viewData, final ValueUpdater<String> valueUpdater) {
                if(Window.confirm("Really update value?")) {
                        String value = updateViewData(parent, viewData, false);
                        clearInput(getInputElement(parent));
                        setValue(context, parent, viewData.getOriginal());
                        if (valueUpdater != null) {
                                valueUpdater.update(value);
                        }
                }
        }

I'd be happy if someone could point out a way to do things like this
in a way that allows me to not have to copy/paste GWT Cell code into
my own project.

On Apr 4, 5:04 pm, Ankur <ankurn...@gmail.com> wrote:
> Hello,
>
> I am using CellTable to retrive data from server. I have a
> EditTextCell. When I try to validate EditTextCell I cannot restore to
> my previous data. I tried to use cellTable.redraw(). Also I tried
> using EditTextCell et.SetViewData(Key,ViewData). I am not able to set
> view data for this function. Can some one help me out.
>
> here is my code:
> Here I get error that View Data is not visible.
> columnDN.setFieldUpdater(new FieldUpdater<FieldPoolMsg, String>() {
>
>                         @Override
>                         public void update(int index, FieldPoolMsg object, 
> String value) {
>                                 if (value.isEmpty()) {
>                                         Window.alert("Display Name cannot be 
> blank.");
>
>                                         
> displayNameCell.setViewData(KEY_PROVIDER.getKey(object),
>                                                         
> displayNameCell.getViewData(KEY_PROVIDER.getKey(object)));
>                                         cellTable.redraw();
>                                         return;
>                                 }
>                                 object.setFieldDisplayName(value);
>                                 object.setPendingUpdate(true);
>                                 cellTable.redraw();
>                         }
>                 });

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to