pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerrick Bivins <gbiv...@objectreservoir.com>
Subject Re: more databinding questions ...nested beans
Date Fri, 24 Dec 2010 02:36:23 GMT
yes. ok, I think I understand this now. I'll try this out. One other related
question.  So if I populate the list with my "class A"s (ie RangeProperty)
and I allow the user to edit the data in the UI, will all
the change events from the Bean be triggered appropriately?
Thanks for all the pointers here while I'm trying to evaluate/learn.
Gerrick


On Thu, Dec 23, 2010 at 8:00 PM, Greg Brown <gk_brown@verizon.net> wrote:

> I think I understand the disconnect. You don't want to use load() here. A
> table view is driven by an instance of List. Each item in the list is
> generally either a bean or an instance of Dictionary. I believe Flex uses a
> data provider for this. You could probably wrap your beans in a dictionary
> whose get() method calls the appropriate bean getters. I'd suggest taking a
> look at the table view tutorial if you have not already done so. Hope this
> helps.
> G
>
> ----- Reply message -----
> From: "Gerrick Bivins" <gbivins@objectreservoir.com>
> Date: Thu, Dec 23, 2010 5:30 pm
> Subject: more databinding questions ...nested beans
> To: <user@pivot.apache.org>
>
> Sorry for the typos.
> Each of the classes A,B and C should extend MyBaseBean.
> A concrete example of class A is:
>
> RangeProperty<T extends Number> extends MyBaseBean
> {
>    T minimum;
>    T maximum;
>    T currentValue;
>    String name;
>
>    //bean getter/setters
>    ...
>
> }
>
> A concrete example of class "B" is:
>
> Intervals extends MyBaseBean
> {
>      RangeProperty<Double> aInterval
>      RangeProperty<Double> bInterval;
>      RangeProperty<Double> cInterval;
>
>      //getter/setters
>      RangeProperty getAInterval(){...};
>      void setAInterval(RangeProperty<Double> a){...};
>     ...
> }
>
> *//Setup code*
> Intervals myInt  = new Intervals() ;
>
> RangeProperty<Double> intervalA = new RangeProperty<Double>();
> intervalA.setName("First Interval");
> intervalA.setMinimum(0);
> intervalA.setCurrentValue(.5);
> intervalA.setMaximum(1);
> myInt.setAInterval(intervalA);
>
> RangeProperty<Double> intervalB = new RangeProperty<Double>();
>
> intervalA.setName("Second Interval");
> intervalB.setMinimum(-1.0);
> intervalB.setCurrentValue(0.0);
> intervalB.setMaximum(1);
>
> myInt.setBInterval(intervalB);
>
> RangeProperty<Double> intervalC = new RangeProperty<Double>();
>
> intervalA.setName("Third Interval");
> intervalC.setMinimum(0);
> intervalC.setCurrentValue(1.0);
> intervalC.setMaximum(2.0);
>
> myInt.setCInterval(intervalC);
>
>
> A TableView that calls load(new BeanAdapter(myInt)) would display:
>
> *name                   |   Minimum | Current Value | Maximum*
> *-----------------------------------------------------------------*
> *First Interval       |      0            |          .5              |
>  1.0*
> *-----------------------------------------------------------------*
> *Second Interval |      -1.0        |          0.0            |  1.0*
> *-----------------------------------------------------------------*
> *Third Interval      |      0            |          1.0             |  2.0
> *
>
> The same table view that used SuspectDescription class ("C" )
>
> SuspectDescription extends MyBaseBean
> {
>      RangeProperty< Integer > ageRange;
>      RangeProperty< Integer > heightRange;
>
>      //getter/setters
>      RangeProperty getAgeRange(){...};
>      void setAgeRange(RangeProperty< Integer > a){...};
>     ...
> }
>
> SuspectDescription personUncertainty  = new SuspectDescription() ;
> RangeProperty< Integer > age = new RangeProperty<Integer>();
> age.setName("Possible Age");
> age.setMinimum(12);
> age.setCurrentValue(16);
> age.setMaximum(18);
> personUncertainty.setAgeRange(age);
>
> RangeProperty<Integer> height = new RangeProperty<Integer>();
> height.setName("Possible Height");
> height.setMinimum(60);
> height.setCurrentValue(68);
> height.setMaximum(74);
> personUncertainty.setHeightRange(height);
> tableView.load(new BeanAdapter(personUncertainty));
>
> *
> *
> *name                           |   Minimum | Current Value | Maximum*
> *
> ------------------------------------------------------------------------------------
> *
> *Possible Age   (yrs)   |      12         |          16             |  18*
> *
> ------------------------------------------------------------------------------
> *
> *Possible Height (in.)  |    60           |          68             |  74*
> *
> *
> *
> *
> What I think I would need is a function/callback that I could set  for each
> column that had access to the bound object and row index of the table. With
> that, I could populate the table the way I want( I think).
>
> My initial thought was a custom *BindMapping but
> I think I would need more parameters than what is exposed on the interfaces
> I've seen.
>
> Is this more clear?
> Gerrick
>
> On Thu, Dec 23, 2010 at 12:37 PM, Greg Brown <gk_brown@verizon.net> wrote:
>
>> Still not sure I completely understand. I think you mean that you want two
>> columns in your table, and that each row could be either a B or a C. Is that
>> correct? If so, that would certainly work, but the property names of each
>> bean would have to be the same, so that they match the column names. For
>> example, let's say the column names are "foo" and "bar". Then your B and C
>> beans can define properties like this:
>>
>> B : MyBean {
>>   foo: A
>>   bar: A
>> }
>>
>> C : MyBean {
>>   foo: A
>>   bar: A
>> }
>>
>> Does that help?
>>
>> On Dec 23, 2010, at 1:27 PM, Gerrick Bivins wrote:
>>
>> Hi Greg,
>> I'd like the table to display each "A" property for class B or class C in
>> a row.  The columns would be the properties of A.
>> If an instance of B is bound to the table, the table would look like this
>> (assuming propb1 == 0, propb2 == 1)
>>
>> name    | property
>> -------------------------
>> propb1  |   0
>> -------------------------
>> propb2  |   1
>>
>>
>> So the table knows how to display n# of  "A" properties of Beans B or C
>>  in rows.
>> Does that make sense?
>> Gerrick
>>
>>
>> On Thu, Dec 23, 2010 at 11:51 AM, Greg Brown <gk_brown@verizon.net>wrote:
>>
>>> In this scenario, what columns are you trying to display in your table,
>>> and what class would you be using for your row data?
>>>
>>> On Dec 23, 2010, at 12:11 PM, Gerrick Bivins wrote:
>>>
>>> > Hi all,
>>> > I have another question about data binding.  Let's say I have a java
>>> Bean which contains some other Beans as it properties.
>>> > For example( not the exact code but I tried to simplify for this
>>> example):
>>> >
>>> > //base Bean
>>> > class MyBaseBean
>>> > {
>>> >    //custom class that contains some base functionality for handling
>>> change/veto events of beans
>>> >    // but not listed here to try and simplify the example
>>> > }
>>> >
>>> > class A<T extends Number> extends BaseBean{
>>> >    T getProperty();
>>> >    void setProperty(T property) throws VetoException;
>>> >    String getPropertyName();
>>> >    void setPropertyName(String name) throws VetoException;
>>> > }
>>> >
>>> > class B extends MyBean
>>> > {
>>> >     A propb1;
>>> >     A propb2;
>>> >    ...
>>> >    A getPropb1(){...};
>>> >    void setPropb1(A pb1) throws VetoException{...};
>>> >
>>> >    A getPropb2(){...};
>>> >    void setPropb2(A pb2) throws VetoException{...};
>>> >    ...
>>> > }
>>> >  and some other similar Beans
>>> > ...
>>> > class C extends MyBaseBean
>>> > {
>>> >    A propc1;
>>> >     A propc2;
>>> >    ...
>>> >    A getPropc1(){...};
>>> >    void setPropc1(A pc1) throws VetoException{...};
>>> >
>>> >    A getPropc2(){...};
>>> >    void setPropc2(A pc2) throws VetoException{...};
>>> >    ...
>>> > }
>>> >
>>> > What I'm trying to do is display the data of  class C and B in a table
>>> without having to write a separate table for each. Seems like I should be
>>> able to accomplish this
>>> > since to display classes C and B I just need to drill down to each of
>>> their properties of type "class A" and pluck the data off each property for
>>> the row.
>>> > In Flex (sorry for the reference but it's the world I'm coming from), I
>>> could define a callback function that gave access to the bound object and
>>> the row,column index of
>>> > the table, which allowed me to get at the appropriate data for the
>>> cell.
>>> >
>>> > I tried looking through some of the binding tutorials and most of them
>>> described how to use what I call the "dot notation" to set up the bindings,
>>> > which works if I want to create a separate table for each class (C and
>>> B).
>>> > I can't claim to fully understand the *BindMapping functionality in
>>> Pivot yet so maybe I'm missing something there.
>>> > Thanks for any pointers/help here. Hopefully my question is clear
>>> enough.
>>> > Gerrick
>>> >
>>>
>>>
>>
>>
>

Mime
View raw message