pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Highley <joshhigh...@gmail.com>
Subject Re: Populate ListButton with enum data binding ?
Date Thu, 14 Apr 2016 17:38:20 GMT
Yes, populating in Java is a last resort.  Where possible, I've been trying
to keep code like that out of the Java code.  I'm converting a QT Jambi
app, and all of the UI definition code in Java makes it a mess trying to
find where functionality is actually implemented.

At this point, my stacktrace isn't really valid since I don't know now to
pass the required Class param to EnumList.  Another path I may explore is
using ArrayList and passing the Paint.Color.values() array -- I'm not sure
if there's a way to do this in bxml....



On Thu, Apr 14, 2016 at 12:20 PM, Roger and Beth Whitcomb <
RogerandBeth@rbwhitcomb.com> wrote:

> That is a really good question, Josh.  My first thought is that you will
> probably have to populate the list in Java code.  My second thought is to
> poke through the BXMLSerializer code to see it I can figure it out.  But,
> what was the complete stack trace of the SerializationException (i.e., the
> cause).  That could point the way to a solution.  But, at the moment I
> don't know the answer.
> Thanks,
> ~Roger
> On 4/13/16 11:26 AM, Josh Highley wrote:
>> I'm having an issue doing data binding with bxml.  My app has a Dialog
>> with a Form that shows a lot of editable fields for an object.  Using
>> form.load(new BeanAdapter(myObject)) is working for most of the fields
>> (TextInput and Checkbox) but I'm having trouble with ListButton.  I want to
>> populate the listData with values from an enum and then set the selected
>> item from a myObject value. I can't figure out how to specify the enum for
>> the list data in the bxml. I think I'm close:
>> (simplified example to mirror actual app)
>> public class Paint {
>>    public enum Color { RED, BLUE, GREEN }
>> }
>> public class Car {
>>     private Paint.Color color;
>>     public Paint.Color getExteriorColor() { return color; }
>>     public void setExteriorColor(Paint.Color color) { this.color = color;
>> }
>> }
>> <ListButton selectedItemKey="exteriorColor">
>>     <listData>
>>         <collections:EnumList>
>>      <!-- how do I specify constructor parameter Paint.Color class here?
>> -->
>>         </collections:EnumList>
>>     </listData>
>> </ListButton>
>> I tried 'enumClass' as an attribute of <EnumList> and a child element,
>> but I always get an "org.apache.pivot.serialization.SerializationException"
>> on the line with <collections:EnumList>
>> Thanks,
>> Josh

View raw message