The update I made to ListButton should be preventing that case - did you
make sure to rebuild the Pivot jars?
public void setSelectedItem(Object item) {
int index = -1;
if (item != null) {
index = ((List<Object>)listData).indexOf(item);
if (index == -1) {
throw new IllegalArgumentException("\"" + item + "\" is not
a valid selection.");
}
}
setSelectedIndex(index);
}
If you're getting ["null" is not a valid selection.] with the above code,
then it means that your bind context has the actual String, "null", as the
value to load...
-T
On Mon, Sep 14, 2009 at 12:20 AM, Scott Lanham <[email protected]> wrote:
> Digging a little deeper the ListButton is asking its list data, a custom
> Dictionary, which index the "null" item belongs to. As the list data
> doesn't
> have a null item, my Dictionary replies -1.
>
> On Mon, 14 Sep 2009 01:58:32 pm Scott Lanham wrote:
> > Okay, made sure SVN is up to date and no blonde moment occuring ( much ).
> >
> > What I get now is:
> >
> > java.lang.IllegalArgumentException: "null" is not a valid selection.
> > at org.apache.pivot.wtk.ListButton.setSelectedItem(Unknown
> Source)
> > at org.apache.pivot.wtk.ListButton.load(Unknown Source)
> > at org.apache.pivot.wtk.Container.load(Unknown Source)
> > at org.apache.pivot.wtk.content.TableViewRowEditor.edit(Unknown
> > Source)
> >
> > On Mon, 14 Sep 2009 11:51:59 am Todd Volkert wrote:
> > > One problem stems from the fact that ListButton.setSelectedItem(null)
> was
> > > explicitly throwing IllegalArgumentException, when it probably should
> > > have been translating to setSelectedIndex(-1). I just checked in a fix
> > > for this, so that might fix you up.
> > >
> > > So you're creating blank rows, and immediately opening an editor on the
> > > row for the user to populate it with initial values?
> > >
> > > Let me know if that check-in fixes the issue.
> > >
> > > -T
> > >
> > > On Sun, Sep 13, 2009 at 9:22 PM, Scott Lanham <[email protected]>
> wrote:
> > > > Howdy Hi,
> > > >
> > > > I have a TableView which displays data from a database table. That
> data
> > > > is bound to the TableView using a custom Dictionary. It all works
> fine
> > > > until it is
> > > > time to add a new record using the TableView and in place editing it
> > > > using TableViewRowEditor. Several of the fields in a TableView row
> have
> > > > ListButtons
> > > > assocated with them to restrict the field values. When the field
> value
> > > > is initially Null, as with a new record, the ListButtons don't like
> it
> > > > because Null can't be found in the lists data.
> > > >
> > > > Is there any way I can get ListButton to not throw an exception in
> this
> > > > case?
> > > >
> > > > Thanks,
> > > >
> > > > Scott.
>
>