Friday, February 1, 2013

Re: How to implement HasValue for ListBox?

Thanks Jens and Thomas! Appreciate your quick response. Always learning new in GWT! 

I am not sure the exact difference between ListBox and ValueListbox. 

I can make a custom ListBox called WrappedListBox which extends ListBox and implements HasValue<String>. I think that is what you are referring here right? 

But I sometimes get confused that I have to inherit bunch of methods for getValue, SetValue and 

addValueChangeHandler. So do I keep the implementation of getvalue, SetValue and addValueChangeHandler  all blank? and just do implementation of addValueChangeHandler and copy the method implementation of ValueListBox. addValueChangeHandler in that?

Please advise. 

On Friday, February 1, 2013 4:00:02 PM UTC-6, Thomas Broyer wrote:
The easiest is to use a ValueListBox but it works a bit differently from a ListBox (API wise; for the same generated DOM).
The reason ListBox is not a HasValue is that some people would like getValue to return the selected index while others would prefer the selected option's value, and a few would want an Option class with a getValue(), getLabel() and getIndex(): https://code.google.com/p/google-web-toolkit/issues/list?can=1&q=ListBox+HasValue
If you can't use a ValueListBox, is relatively easy to make an HasValue around a ListBox; ask if you need it and can't come to doing it yourself.

On Friday, February 1, 2013 9:46:08 PM UTC+1, BM wrote:
I have a custom class which is used to assign single handler to all of my UI text fields. 

Custom Class Watcher:
=================

private ValueChangeHandler<String> reusableChangeHandler;

public void registerHandlers(HasValue<String> element) {

        element.addValueChangeHandler(reusableChangeHandler);

    }

The idea here is I can assign all of my textfields same valueChangeHandler.

myView Class:

===========

TestBox myTextBox = new TextBox();

Watcher.registerHandlers(myTextBox);

But it doesn't work for ListBox. How do I make a overloaded method to accomodate Listbox?

Basically I want to do something when any of my UI elements value changes in a center location. 




 



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

No comments:

Post a Comment