pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Lanham <li...@sael.com.au>
Subject Re: TableViewRowEditor and New Records
Date Mon, 14 Sep 2009 22:14:24 GMT
I have modified ListButton to simply accept -1 as a valid index and everything 
works great on that front. But there is another problem. If a new row is added 
to the TableView via the associated Dictionary and the TablieViewRowEditor is 
immediately invoked on that new row the error below occurs:

Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException
        at org.apache.pivot.collections.ArrayList.get(Unknown Source)
        at org.apache.pivot.wtk.Container.validate(Unknown Source)
        at org.apache.pivot.wtk.Display$ValidateCallback.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at 
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at 
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at 
org.apache.pivot.wtk.content.TableViewRowEditor$2$1.selectedIndexChanged(Unknown 
Source)
        at 
org.apache.pivot.wtk.CardPane$CardPaneListenerList.selectedIndexChanged(Unknown 
Source)
        at org.apache.pivot.wtk.CardPane.setSelectedIndex(Unknown Source)
        at 
org.apache.pivot.wtk.skin.CardPaneSkin$1.transitionCompleted(Unknown Source)
        at org.apache.pivot.wtk.effects.Transition$1.run(Unknown Source)
        at 
org.apache.pivot.wtk.ApplicationContext$ScheduledCallback$1.run(Unknown 
Source)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at 
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at 
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at 
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

On Mon, 14 Sep 2009 09:07:18 pm Todd Volkert wrote:
> 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 <lists@sael.com.au> 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 <lists@sael.com.au>
> >
> > 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.


Mime
View raw message