Hi Thomas,

I did something like that,

boolean normalButtonClicked = false; // class variable

Column<HotelSearchDTO, String> bookCol = new Column<HotelSearchDTO,
> String>(new ButtonCell()) {
>
> @Override
> public String getValue(HotelSearchDTO object) {
> return normalButtonlicked ? "Loading…" : "Normal";;
>


}
> };
> bookCol.setFieldUpdater(new FieldUpdater<HotelSearchDTO, String>() {
>
> @Override
> public void update(int index, HotelSearchDTO object, String value) {
>  normalButtonClicked = true;
>
                            // server operation
                             // on server completion { normalButtonClicked
= false;}
                        }

But its not working. The text of the button is never changed.


Regards
Deepak


On Tue, Nov 6, 2012 at 2:37 PM, Thomas Broyer <[email protected]> wrote:

>
>
> On Monday, November 5, 2012 7:53:59 PM UTC+1, Deepak Singh wrote:
>
> Let's say you have some object that stores "pending requests". To make
> things simple, let's use a Set<HotelSearchDTO>:
>
> final Set<HotelSearchDTO> pendingRequests = new HashSet<HotelSearchDTO>();
>
> Column<HotelSearchDTO, String> bookCol = new Column<HotelSearchDTO,
>> String>(new ButtonCell()) {
>>
>> @Override
>> public String getValue(HotelSearchDTO object) {
>> return "Normal";
>>
>
> return pendingRequests.contains(object) ? "Loading…" : "Normal";
>
>
>>  }
>> };
>> bookCol.setFieldUpdater(new FieldUpdater<HotelSearchDTO, String>() {
>>
>> @Override
>> public void update(int index, HotelSearchDTO object, String value) {
>>  // How to return "Loading..." from this place as this is the only place
>> to handle click event.
>>
>
> if (pendingRequest.add(object)) {
>   // remember, add returns 'true' if the obejct wasn't already there; that
> filters out the case when the user clicks on "Loading…" buttons
>   // Now, do the request, and in the callback make sure you remove the
> HotelSearchDTO from the pendingRequests set and redraw the line
>   foo.do(new SomeCallback() {
>     …
>     void onSuccessOrFailure() {
>       pendingRequests.remove(object);
>       cellTable.redrawRow(index); // you'd better re-compute the index
> here, in case the table has changed pending the response from the server
>     }
>   });
>   // finally, redraw the line so the button now says "Loading…"
>   cellTable.redrawRow(index);
>
>
>> }
>>  });
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-web-toolkit/-/twXiMfyZ6V8J.
>
> 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.
>



-- 
Deepak Singh

-- 
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