How to set ListBox selection with UiBinder?

1,239 views
Skip to first unread message

Thad

unread,
Jul 12, 2011, 7:05:29 PM7/12/11
to Google Web Toolkit
Just that: How do I set a ListBox's selection with UiBinder? I've
tried

<g:ListBox>
<g:item value='1'>
first
</g:item>
<g:item value='2' selected='true'>
second
</g:item>
<g:item value='3'>
third
</g:item>
</g:ListBox>

but selected disappears in the final HTML.

I tried <g:ListBox selectedItem='1'> and got an error when I tried to
load the page.

-sowdri-

unread,
Jul 13, 2011, 1:27:38 AM7/13/11
to google-we...@googlegroups.com
Did you try doing the same with 

 <g:ListBox uifield="myListbox"

  <g:item value='1'> 
    first 
  </g:item> 
  <g:item value='2' selected='true'> 
    second 
  </g:item> 
  <g:item value='3'> 
    third 
  </g:item> 
 </g:ListBox> 

@UiField
Listbox myListbox;


public constructor(){
  //...
  listbox.setSelectedIndex(1);
}

Thad

unread,
Jul 13, 2011, 9:26:56 AM7/13/11
to Google Web Toolkit
Argh! The attribute is selectedIndex, not selectedItem.
Reply all
Reply to author
Forward
0 new messages