I have ValueListBox<A> where  A is my POJO class. So I have editor
with fields:

ValueListBox<A> field1;
ValueListBox<B> field2;
ValueListBox<C> field3;

I also have a POJO D with String properties which are A.code, B.code,
C.code. It is some kind of specification pattern where I specify a
search filter.
So my question is how can I bind only CODE property from classes A,B,C
into my D class?


On 6 lip, 11:17, vinayak kulkarni <[email protected]> wrote:
> Dear,
> Here is how you can achieve this:
> May be a crude solution but it works.
>
> Make your editor as LeafValueEditor<String>
> ie.
> public class MyWidget extends Composite implements LeafValueEditor<String>
>
> @UiField
>   ValueListBox  listOfString;
>
>  private static String selectedValue;
>
> //holds the values
> public final List<String> listBoxValueList = new ArrayList<String>();
>
>  @Override
>   public String  getValue()
>   {
>       return selectedValue;
>  }
>
> @Override
>   public void setValue(String  valueToSet)
>   {
>     // dont do anything.. since, it is an editor of <string> but not editor
> of List<String>
>  }
>
> write your own method
> public void seListValues(List<String> valueList){
>   for (String originStr : valueList)
>     {
>       listOfString.addItem(originStr);
>       listBoxValueList.add(originStr);
>     }
>
> listOfString.addChangeHandler(new ChangeHandler() {
>
>       public void onChange(ChangeEvent event)
>       {
>
>         // get the selected value from the selected index
>         final int selectedIndex = listOfString.getSelectedIndex();
>         selectedValue = listOfString.getValue(selectedIndex);
>
>       }
>     });
>
> }
>
> From presenter,
> call  editorDriver.edit( );  and then seListValues();
>
> editorDriver.flush() would flush the selected string value.
>
> Hope this helps
>
>
>
>
>
>
>
> On Mon, Jun 6, 2011 at 12:52 PM, ricu <[email protected]> wrote:
> > Hi!
>
> > I use ValueListBox field in one of my widget that acts as an editor. I
> > populate this ValueListBox with the list of objects but I would like
> > to bind it to a String property of my object model. For example, I
> > have a list of A objects in the ValueListBox and with the custom
> > renderer I display A.name in the list. When I change the selected item
> > in the list I want to copy (when driver.flush is called) only A.code
> > to the String property of the object that is binded to my widget.
>
> > How can I achieve this and is the editor framework appropriate for
> > such scenarios?
>
> > Marko
>
> > --
> > 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.

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