You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Michael Allman <ms...@allman.ms> on 2010/03/29 05:48:50 UTC

data binding question

Hello,

I have two related questions on data binding in Pivot.  After a lot of 
searching and digging, I'm pretty sure the answer is "no" to both of these 
questions.  I just want to confirm so we can move on to step 2---how to 
fix the situation.

So suppose we have some kind of User object with a r/w "name" property and 
a Label declared in some WTKX file.  My questions are:

1.  Is there a simple way to bind the Label's "text" property to the User 
object's "name" property in such a way that as the app user types into the 
text field the value of the latter property is set to the value of the 
former (label.text => user.name)?

2.  Is there a simple way to bind the User object's "name" property to the 
Label's "text" property in such a way that when the value of the former 
property is changed, the value of the Label's "text" property is set to 
the new value of the User object's "name" property?

This is a very important capability for me, and it's one that I think has 
a reasonably simple solution.  But I'd like to get a Pivot expert's 
thoughts first.  Maybe I'm missing something that's already there, or some 
other feature that's more powerful than this.

Cheers,

Michael

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
> I would happily submit a set of patches if I thought they had a good change of being accepted.  Ha.  Don't want to do all that work for nuthin'.
> 
> I will suggest a design for some new functionality to support my beloved event-driven data binding in a follow up message.

Excellent. Looking forward to it.



Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
On Wed, 21 Apr 2010, Greg Brown wrote:

[snippage]

>> One of the goals of MVC was to create an independent model which could 
>> be presented through multiple concurrent views...But, and this is a big 
>> *but*, what if elements and properties of the data model can be changed 
>> through one or more of the tables?
> ...
>> Eh.  You see where I'm going.  "Load-n-store" is going to fall apart 
>> here. Bi-directional event-driven binding between model and view (maybe 
>> through a controller or whatnot) will save the day.
>
> That's where an MVC framework comes in.

I don't see how that helps.  But if you think I'm suggesting some kind of 
MVC framework, then I can certainly understand why you think event-driven 
data binding is a big ugly mess.  Because MVC frameworks produce apps that 
are big ugly messes.

>> Interestingly, I see you *are* using event-driven data binding for 
>> list-based mutations.  But if you change a property of an element of a 
>> list, the list does not dispatch an event.  The view remains ignorant.
>
> This is also true of Flex, as I recall. You need to notify the list that 
> the data has changed.

Not true--not if the changed property is bindable.  A list automatically 
listens for change events from all of its members.  If a bound property 
changes, the member will dispatch a change event, the list will catch it, 
wrap it as a kind of list change event, and dispatch it up the event 
chain.  No assembly required. :)

>> Where I'm coming from (data binding in Flex), doing this stuff with 
>> custom event listeners/dispatchers is a real chore.  Yeah, it can be 
>> done, but it's a *lot* of work writing all that boilerplate.
>
>
> One of the features we added for Pivot 1.5 is a pub/sub event model that 
> is meant to help facilitate application level messaging. You may find it 
> useful.

Hmmmm... I will check it out.

> I'd also recommend looking into some of the client-side MVC frameworks. 
> I haven't done much work with them myself, but I suspect that they may 
> provide some of what you are looking for. On the other hand, if you 
> can't find something that fits the bill, why not create something 
> yourself and submit it as a contribution to the platform?  ;-)

I would happily submit a set of patches if I thought they had a good 
change of being accepted.  Ha.  Don't want to do all that work for 
nuthin'.

I will suggest a design for some new functionality to support my beloved 
event-driven data binding in a follow up message.

Cheers,

Michael

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
> Also, I'm sorry I misspelled your name in my last message.  I've been working with a guy named "Gregg" and now I'm forever confused.

Happens all the time.  ;-)

> Anyway, back to business.  So you say "load-n-store" is what works best for an app that loads data then saves it.  No disagreement there.  But that's far from the entire spectrum of GUI applications.  Many do not fit that mold.  I think the "load/store" paradigm maps more closely to simple database or service driven form-based apps where data is not shared among multiple user interface components.

>From personal experience, I can say that the model also maps well to more complex scenarios. I'm not saying it's a one-size-fits-all solution, but it does work.

> One of the goals of MVC was to create an independent model which could be presented through multiple concurrent views...But, and this is a big *but*, what if elements and properties of the data model can be changed through one or more of the tables? 
...
> Eh.  You see where I'm going.  "Load-n-store" is going to fall apart here. Bi-directional event-driven binding between model and view (maybe through a controller or whatnot) will save the day.

That's where an MVC framework comes in.

> Interestingly, I see you *are* using event-driven data binding for list-based mutations.  But if you change a property of an element of a list, the list does not dispatch an event.  The view remains ignorant.

This is also true of Flex, as I recall. You need to notify the list that the data has changed.

> Where I'm coming from (data binding in Flex), doing this stuff with custom event listeners/dispatchers is a real chore.  Yeah, it can be done, but it's a *lot* of work writing all that boilerplate. 


One of the features we added for Pivot 1.5 is a pub/sub event model that is meant to help facilitate application level messaging. You may find it useful.

I'd also recommend looking into some of the client-side MVC frameworks. I haven't done much work with them myself, but I suspect that they may provide some of what you are looking for. On the other hand, if you can't find something that fits the bill, why not create something yourself and submit it as a contribution to the platform?  ;-)


Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
Greg,

Well, I'm kinda surprised I never responded because you certainly made 
some assertions I strongly disagree with.  :)

Also, I'm sorry I misspelled your name in my last message.  I've been 
working with a guy named "Gregg" and now I'm forever confused.

Anyway, back to business.  So you say "load-n-store" is what works best 
for an app that loads data then saves it.  No disagreement there.  But 
that's far from the entire spectrum of GUI applications.  Many do not fit 
that mold.  I think the "load/store" paradigm maps more closely to simple 
database or service driven form-based apps where data is not shared among 
multiple user interface components.

Now I'm going to lecture a bit.  I'm sorry.  I just don't know how to make 
my point better.

One of the goals of MVC was to create an independent model which could be 
presented through multiple concurrent views.  A "simple" example would be 
a multi-dimensional data set that's displayed in graphs and tables. 
You're feed one "model" to multiple "views".  That's pretty easy to do 
with load and store---you load your data model from the service, then you 
load the data model into your views.  But, and this is a big *but*, what 
if elements and properties of the data model can be changed through one or 
more of the tables?  How is that change, made through one view, propagated 
to and reflected in the other views?  I mean, let's say you change one 
measure of one dimension of your data set from 342.64 to 356.10.  That 
changes how the graphs should be drawn, and maybe some other data in the 
model depends on that particular measure's value, and then the changes in 
that data should be displayed in some other table somewhere.

Eh.  You see where I'm going.  "Load-n-store" is going to fall apart here. 
Bi-directional event-driven binding between model and view (maybe through 
a controller or whatnot) will save the day.

So that's one argument for event-driven data binding.  I can also just 
state for a fact that I use data binding pervasively in Flex apps.  I 
don't know what I would do without it.  I'd be writing custom event 
listeners and handlers, I guess.  Like in the bad old days of Swing.

Interestingly, I see you *are* using event-driven data binding for 
list-based mutations.  But if you change a property of an element of a 
list, the list does not dispatch an event.  The view remains ignorant.

So in that sense, you are kinda half-way there.

Finally, let me just comment on your last comment.  Where I'm coming from 
(data binding in Flex), doing this stuff with custom event 
listeners/dispatchers is a real chore.  Yeah, it can be done, but it's a 
*lot* of work writing all that boilerplate.  I touched on this more in my 
last post where I reviewed what I believe is the recommended way to 
implement the kind of data binding I'm looking for with Pivot 1.4.  If I'm 
mistaken and it's actually a lot simpler, please advise.

Cheers,

Michael

On Mon, 29 Mar 2010, Greg Brown wrote:

> As you guessed, this type of data binding isn't currently supported. 
> Having worked with data binding systems like this in the past, I find 
> that it can lead to confusing and inefficient code, as too many things 
> are happening in the background when they don't need to be.
>
> The load()/store() model used by Pivot maps more closely to how data 
> binding is used in many practical applications (especially those that 
> are REST-based): after making a server query to retrieve your data, you 
> populate your form using the load() method. When you want to save it 
> back to the server, you store() it into your model and upload it back to 
> the server.
>
> More dynamic updates (like those you describe) can easily be achieved 
> via event listeners. This way, your application has complete control 
> over what is updated and when.
>
> G
>
> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>
>> Hello,
>>
>> I have two related questions on data binding in Pivot.  After a lot of searching and digging, I'm pretty sure the answer is "no" to both of these questions.  I just want to confirm so we can move on to step 2---how to fix the situation.
>>
>> So suppose we have some kind of User object with a r/w "name" property and a Label declared in some WTKX file.  My questions are:
>>
>> 1.  Is there a simple way to bind the Label's "text" property to the User object's "name" property in such a way that as the app user types into the text field the value of the latter property is set to the value of the former (label.text => user.name)?
>>
>> 2.  Is there a simple way to bind the User object's "name" property to the Label's "text" property in such a way that when the value of the former property is changed, the value of the Label's "text" property is set to the new value of the User object's "name" property?
>>
>> This is a very important capability for me, and it's one that I think has a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts first.  Maybe I'm missing something that's already there, or some other feature that's more powerful than this.
>>
>> Cheers,
>>
>> Michael
>

Re: data binding question

Posted by Luiz Gustavo <lu...@gmail.com>.
Greg, thanks very much for the tips!



2010/3/29 Greg Brown <gk...@mac.com>

> > I need to understand a basic case where I search for data in the business
> classes, returning a List of objects, for example, and have to bind this
> list to a TableView.
>
> For this, you can probably just set the "tableData" property of the
> TableView:
>
>  tableView.setTableData(myList);
>
> > Or even when I want to show a selected item on the TableView on the
> fields of the form.
>
> Here, you might want to use data binding. You could load the selected row
> into your form:
>
>  form.load(myList.get(tableView.getSelectedIndex()));
>
> The Stock Tracker tutorial includes some example code that demonstrates
> something similar. I'd suggest looking at the Pivot 1.5 version, since it
> represents current best practices (the 1.4 version goes back a way and is a
> little dated at this point):
>
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/
>
> The tutorial docs haven't been uploaded to the site yet, but if you build
> Pivot from source and run the Ant deploy target, you can read it locally.
>
> Hope this helps,
> G
>
>


-- 
Att,

Luiz Gustavo S. de Souza
Analista de Sistemas - Desenvolvedor Java

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
> I need to understand a basic case where I search for data in the business classes, returning a List of objects, for example, and have to bind this list to a TableView.

For this, you can probably just set the "tableData" property of the TableView:

  tableView.setTableData(myList);

> Or even when I want to show a selected item on the TableView on the fields of the form. 

Here, you might want to use data binding. You could load the selected row into your form:

  form.load(myList.get(tableView.getSelectedIndex()));

The Stock Tracker tutorial includes some example code that demonstrates something similar. I'd suggest looking at the Pivot 1.5 version, since it represents current best practices (the 1.4 version goes back a way and is a little dated at this point):

  http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/stocktracker/

The tutorial docs haven't been uploaded to the site yet, but if you build Pivot from source and run the Ant deploy target, you can read it locally.

Hope this helps,
G


Re: data binding question

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi Greg,

I see that I have to study more these different cases. =)
I need to understand a basic case where I search for data in the business
classes, returning a List of objects, for example, and have to bind this
list to a TableView. Or even when I want to show a selected item on the
TableView on the fields of the form.
I'm still trying to understand that =/
But don't mind if you can't give me this kind of explanation. It's a basic
question, and I can search on my on ;)
Anyway, thanks for answering!

Cheers,

Luiz Gustavo

2010/3/29 Greg Brown <gk...@mac.com>

> Hi Luiz,
>
> You are describing WTKX binding, which is a way to associate WTKX values
> with Java properties. Data binding is a way to map data structure values to
> Pivot component properties. Similar names, but different use cases.
>
> G
>
> On Mar 29, 2010, at 9:26 AM, Luiz Gustavo wrote:
>
> Hi!
>
>
> I'm trying to understand the binding strategy used in pivot, and as I could
> see, it maps components declared in WTKX files directly to properties in the
> class, using name conventions. Is it Right?
>
>
>
> 2010/3/29 Todd Volkert <tv...@gmail.com>
>
>> What he said :-)
>>
>> Michael, I'd add that to your "simple" requierment, WTKX script might be
>> the simplest way to wire up these types of quick event handlers.  You'd need
>> your user object class to fire events the Pivot way (using Pivot's
>> ListenerList).  Then, your WTKX could look something like this:
>>
>> <myPackage:UserData wtkx:id="userData"
>> UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
>> ...
>> <TextInput wtkx:id="textInput"
>> TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
>>
>> -T
>>
>>
>> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
>>
>>> As you guessed, this type of data binding isn't currently supported.
>>> Having worked with data binding systems like this in the past, I find that
>>> it can lead to confusing and inefficient code, as too many things are
>>> happening in the background when they don't need to be.
>>>
>>> The load()/store() model used by Pivot maps more closely to how data
>>> binding is used in many practical applications (especially those that are
>>> REST-based): after making a server query to retrieve your data, you populate
>>> your form using the load() method. When you want to save it back to the
>>> server, you store() it into your model and upload it back to the server.
>>>
>>> More dynamic updates (like those you describe) can easily be achieved via
>>> event listeners. This way, your application has complete control over what
>>> is updated and when.
>>>
>>> G
>>>
>>> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>>>
>>> > Hello,
>>> >
>>> > I have two related questions on data binding in Pivot.  After a lot of
>>> searching and digging, I'm pretty sure the answer is "no" to both of these
>>> questions.  I just want to confirm so we can move on to step 2---how to fix
>>> the situation.
>>> >
>>> > So suppose we have some kind of User object with a r/w "name" property
>>> and a Label declared in some WTKX file.  My questions are:
>>> >
>>> > 1.  Is there a simple way to bind the Label's "text" property to the
>>> User object's "name" property in such a way that as the app user types into
>>> the text field the value of the latter property is set to the value of the
>>> former (label.text => user.name)?
>>> >
>>> > 2.  Is there a simple way to bind the User object's "name" property to
>>> the Label's "text" property in such a way that when the value of the former
>>> property is changed, the value of the Label's "text" property is set to the
>>> new value of the User object's "name" property?
>>> >
>>> > This is a very important capability for me, and it's one that I think
>>> has a reasonably simple solution.  But I'd like to get a Pivot expert's
>>> thoughts first.  Maybe I'm missing something that's already there, or some
>>> other feature that's more powerful than this.
>>> >
>>> > Cheers,
>>> >
>>> > Michael
>>>
>>>
>>
>
>
> --
> Att,
>
> Luiz Gustavo S. de Souza
> Analista de Sistemas - Desenvolvedor Java
>
> http://luizgustavoss.wordpress.com
> http://luizgustavoss.blogspot.com
> http://twitter.com/lugustso
>
>
>


-- 
Att,

Luiz Gustavo S. de Souza
Analista de Sistemas - Desenvolvedor Java

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Hi Luiz,

You are describing WTKX binding, which is a way to associate WTKX values with Java properties. Data binding is a way to map data structure values to Pivot component properties. Similar names, but different use cases.

G

On Mar 29, 2010, at 9:26 AM, Luiz Gustavo wrote:

> Hi!
> 
> 
> I'm trying to understand the binding strategy used in pivot, and as I could see, it maps components declared in WTKX files directly to properties in the class, using name conventions. Is it Right?
> 
> 
> 
> 2010/3/29 Todd Volkert <tv...@gmail.com>
> What he said :-)
> 
> Michael, I'd add that to your "simple" requierment, WTKX script might be the simplest way to wire up these types of quick event handlers.  You'd need your user object class to fire events the Pivot way (using Pivot's ListenerList).  Then, your WTKX could look something like this:
> 
> <myPackage:UserData wtkx:id="userData" UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
> ...
> <TextInput wtkx:id="textInput" TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
> 
> -T
> 
> 
> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
> As you guessed, this type of data binding isn't currently supported. Having worked with data binding systems like this in the past, I find that it can lead to confusing and inefficient code, as too many things are happening in the background when they don't need to be.
> 
> The load()/store() model used by Pivot maps more closely to how data binding is used in many practical applications (especially those that are REST-based): after making a server query to retrieve your data, you populate your form using the load() method. When you want to save it back to the server, you store() it into your model and upload it back to the server.
> 
> More dynamic updates (like those you describe) can easily be achieved via event listeners. This way, your application has complete control over what is updated and when.
> 
> G
> 
> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
> 
> > Hello,
> >
> > I have two related questions on data binding in Pivot.  After a lot of searching and digging, I'm pretty sure the answer is "no" to both of these questions.  I just want to confirm so we can move on to step 2---how to fix the situation.
> >
> > So suppose we have some kind of User object with a r/w "name" property and a Label declared in some WTKX file.  My questions are:
> >
> > 1.  Is there a simple way to bind the Label's "text" property to the User object's "name" property in such a way that as the app user types into the text field the value of the latter property is set to the value of the former (label.text => user.name)?
> >
> > 2.  Is there a simple way to bind the User object's "name" property to the Label's "text" property in such a way that when the value of the former property is changed, the value of the Label's "text" property is set to the new value of the User object's "name" property?
> >
> > This is a very important capability for me, and it's one that I think has a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts first.  Maybe I'm missing something that's already there, or some other feature that's more powerful than this.
> >
> > Cheers,
> >
> > Michael
> 
> 
> 
> 
> 
> -- 
> Att,
> 
> Luiz Gustavo S. de Souza
> Analista de Sistemas - Desenvolvedor Java
> 
> http://luizgustavoss.wordpress.com
> http://luizgustavoss.blogspot.com
> http://twitter.com/lugustso


Re: data binding question

Posted by Luiz Gustavo <lu...@gmail.com>.
Hi!


I'm trying to understand the binding strategy used in pivot, and as I could
see, it maps components declared in WTKX files directly to properties in the
class, using name conventions. Is it Right?



2010/3/29 Todd Volkert <tv...@gmail.com>

> What he said :-)
>
> Michael, I'd add that to your "simple" requierment, WTKX script might be
> the simplest way to wire up these types of quick event handlers.  You'd need
> your user object class to fire events the Pivot way (using Pivot's
> ListenerList).  Then, your WTKX could look something like this:
>
> <myPackage:UserData wtkx:id="userData"
> UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
> ...
> <TextInput wtkx:id="textInput"
> TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
>
> -T
>
>
> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
>
>> As you guessed, this type of data binding isn't currently supported.
>> Having worked with data binding systems like this in the past, I find that
>> it can lead to confusing and inefficient code, as too many things are
>> happening in the background when they don't need to be.
>>
>> The load()/store() model used by Pivot maps more closely to how data
>> binding is used in many practical applications (especially those that are
>> REST-based): after making a server query to retrieve your data, you populate
>> your form using the load() method. When you want to save it back to the
>> server, you store() it into your model and upload it back to the server.
>>
>> More dynamic updates (like those you describe) can easily be achieved via
>> event listeners. This way, your application has complete control over what
>> is updated and when.
>>
>> G
>>
>> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>>
>> > Hello,
>> >
>> > I have two related questions on data binding in Pivot.  After a lot of
>> searching and digging, I'm pretty sure the answer is "no" to both of these
>> questions.  I just want to confirm so we can move on to step 2---how to fix
>> the situation.
>> >
>> > So suppose we have some kind of User object with a r/w "name" property
>> and a Label declared in some WTKX file.  My questions are:
>> >
>> > 1.  Is there a simple way to bind the Label's "text" property to the
>> User object's "name" property in such a way that as the app user types into
>> the text field the value of the latter property is set to the value of the
>> former (label.text => user.name)?
>> >
>> > 2.  Is there a simple way to bind the User object's "name" property to
>> the Label's "text" property in such a way that when the value of the former
>> property is changed, the value of the Label's "text" property is set to the
>> new value of the User object's "name" property?
>> >
>> > This is a very important capability for me, and it's one that I think
>> has a reasonably simple solution.  But I'd like to get a Pivot expert's
>> thoughts first.  Maybe I'm missing something that's already there, or some
>> other feature that's more powerful than this.
>> >
>> > Cheers,
>> >
>> > Michael
>>
>>
>


-- 
Att,

Luiz Gustavo S. de Souza
Analista de Sistemas - Desenvolvedor Java

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Thanks for chiming in, Noel. Though I prefer the load/store model, I agree that there are use cases for both binding styles (automatic vs. push/pull). However, if the Eclipse binding stuff works with Pivot, then there's probably not as strong a case for adding it to the platform. 

Michael, if you do look into it, I'd be interested to hear about your experience.

On Apr 21, 2010, at 12:19 PM, Noel Grandin wrote:

> If you're going to do binding stuff, it is well worth looking at the
> eclipse binding library - in my opinion, it is the best available in
> the Java world at the moment. And its mostly toolkit agnostic, so it
> would be possible to use them in Pivot.
> 
> For myself, I'm using a home-grown binding layer in one of my Swing
> apps, but that was because my efforts pre-dated the Eclipse library.
> 
> Binding is hard.
> Sometimes you want the binding to be bi-directional, sometimes you
> want uni-directional, sometimes a mixture of both.
> Sometimes you want it to be automatic, sometimes you want explicit pull/push.
> 
> -- Noel
> 
> 
> On Wed, Apr 21, 2010 at 16:42, Greg Brown <gk...@mac.com> wrote:
>> Two additional thoughts:
>> 
>> - You'd probably want the binding to be bi-directional, such that when the value changes in the component, it is propagated to the model. So these monitors would also need to listen to the destination object (making "destination" probably not the right term).
>> 
>> - ScriptEngineBindingMonitor is probably not necessary, since a Map could be used to wrap the engine's bind context.
>> 
>> Maybe "context" is a better term for "source" and "target" is a better term for "destination".
>> 
>> On Apr 21, 2010, at 9:51 AM, Greg Brown wrote:
>> 
>>> Of course, in order for the BeanPropertyMonitor to work, the bound bean would need to fire events as you described in your original email.
>>> 
>>> On Apr 21, 2010, at 9:43 AM, Greg Brown wrote:
>>> 
>>>> Moving this to the dev list (if you are not subscribed there, you probably should be).
>>>> 
>>>> I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:
>>>> 
>>>> <Label text="$foo"/>
>>>> 
>>>> This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:
>>>> 
>>>> <Label text="$foo.bar"/>
>>>> 
>>>> I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:
>>>> 
>>>> ScriptEngineBindingMonitor(String key, Object object, String property)
>>>> 
>>>> Assuming that "foo" is a Java bean, the second might look like:
>>>> 
>>>> BeanPropertyMonitor(Object bean, String property, Object object, String property)
>>>> 
>>>> If "foo" is a Map, it might look like:
>>>> 
>>>> MapValueMonitor(Map<String, ?> map, String key, Object object, String property)
>>>> 
>>>> These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).
>>>> 
>>>> Does that make sense?
>>>> 
>>>> 
>>>> On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:
>>>> 
>>>>> On Wed, 21 Apr 2010, Greg Brown wrote:
>>>>> 
>>>>>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>>>>>> 
>>>>>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
>>>>> 
>>>>> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
>>>>> 
>>>>> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
>>>>> 
>>>>> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
>>>>> 
>>>>> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
>>>>> 
>>>>> https://www.allman.ms/
>>>>> 
>>>>> Ciao,
>>>>> 
>>>>> Michael
>>>> 
>>> 
>> 
>> 


Re: data binding question

Posted by Noel Grandin <no...@gmail.com>.
If you're going to do binding stuff, it is well worth looking at the
eclipse binding library - in my opinion, it is the best available in
the Java world at the moment. And its mostly toolkit agnostic, so it
would be possible to use them in Pivot.

For myself, I'm using a home-grown binding layer in one of my Swing
apps, but that was because my efforts pre-dated the Eclipse library.

Binding is hard.
Sometimes you want the binding to be bi-directional, sometimes you
want uni-directional, sometimes a mixture of both.
Sometimes you want it to be automatic, sometimes you want explicit pull/push.

-- Noel


On Wed, Apr 21, 2010 at 16:42, Greg Brown <gk...@mac.com> wrote:
> Two additional thoughts:
>
> - You'd probably want the binding to be bi-directional, such that when the value changes in the component, it is propagated to the model. So these monitors would also need to listen to the destination object (making "destination" probably not the right term).
>
> - ScriptEngineBindingMonitor is probably not necessary, since a Map could be used to wrap the engine's bind context.
>
> Maybe "context" is a better term for "source" and "target" is a better term for "destination".
>
> On Apr 21, 2010, at 9:51 AM, Greg Brown wrote:
>
>> Of course, in order for the BeanPropertyMonitor to work, the bound bean would need to fire events as you described in your original email.
>>
>> On Apr 21, 2010, at 9:43 AM, Greg Brown wrote:
>>
>>> Moving this to the dev list (if you are not subscribed there, you probably should be).
>>>
>>> I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:
>>>
>>> <Label text="$foo"/>
>>>
>>> This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:
>>>
>>> <Label text="$foo.bar"/>
>>>
>>> I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:
>>>
>>> ScriptEngineBindingMonitor(String key, Object object, String property)
>>>
>>> Assuming that "foo" is a Java bean, the second might look like:
>>>
>>> BeanPropertyMonitor(Object bean, String property, Object object, String property)
>>>
>>> If "foo" is a Map, it might look like:
>>>
>>> MapValueMonitor(Map<String, ?> map, String key, Object object, String property)
>>>
>>> These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).
>>>
>>> Does that make sense?
>>>
>>>
>>> On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:
>>>
>>>> On Wed, 21 Apr 2010, Greg Brown wrote:
>>>>
>>>>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>>>>>
>>>>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
>>>>
>>>> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
>>>>
>>>> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
>>>>
>>>> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
>>>>
>>>> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
>>>>
>>>> https://www.allman.ms/
>>>>
>>>> Ciao,
>>>>
>>>> Michael
>>>
>>
>
>

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Two additional thoughts:

- You'd probably want the binding to be bi-directional, such that when the value changes in the component, it is propagated to the model. So these monitors would also need to listen to the destination object (making "destination" probably not the right term).

- ScriptEngineBindingMonitor is probably not necessary, since a Map could be used to wrap the engine's bind context.

Maybe "context" is a better term for "source" and "target" is a better term for "destination".

On Apr 21, 2010, at 9:51 AM, Greg Brown wrote:

> Of course, in order for the BeanPropertyMonitor to work, the bound bean would need to fire events as you described in your original email.
> 
> On Apr 21, 2010, at 9:43 AM, Greg Brown wrote:
> 
>> Moving this to the dev list (if you are not subscribed there, you probably should be).
>> 
>> I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:
>> 
>> <Label text="$foo"/>
>> 
>> This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:
>> 
>> <Label text="$foo.bar"/>
>> 
>> I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:
>> 
>> ScriptEngineBindingMonitor(String key, Object object, String property)
>> 
>> Assuming that "foo" is a Java bean, the second might look like:
>> 
>> BeanPropertyMonitor(Object bean, String property, Object object, String property)
>> 
>> If "foo" is a Map, it might look like:
>> 
>> MapValueMonitor(Map<String, ?> map, String key, Object object, String property)
>> 
>> These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).
>> 
>> Does that make sense?
>> 
>> 
>> On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:
>> 
>>> On Wed, 21 Apr 2010, Greg Brown wrote:
>>> 
>>>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>>>> 
>>>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
>>> 
>>> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
>>> 
>>> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
>>> 
>>> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
>>> 
>>> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
>>> 
>>> https://www.allman.ms/
>>> 
>>> Ciao,
>>> 
>>> Michael
>> 
> 


Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Of course, in order for the BeanPropertyMonitor to work, the bound bean would need to fire events as you described in your original email.

On Apr 21, 2010, at 9:43 AM, Greg Brown wrote:

> Moving this to the dev list (if you are not subscribed there, you probably should be).
> 
> I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:
> 
>  <Label text="$foo"/>
> 
> This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:
> 
>  <Label text="$foo.bar"/>
> 
> I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:
> 
>  ScriptEngineBindingMonitor(String key, Object object, String property)
> 
> Assuming that "foo" is a Java bean, the second might look like:
> 
>  BeanPropertyMonitor(Object bean, String property, Object object, String property)
> 
> If "foo" is a Map, it might look like:
> 
>  MapValueMonitor(Map<String, ?> map, String key, Object object, String property)
> 
> These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).
> 
> Does that make sense?
> 
> 
> On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:
> 
>> On Wed, 21 Apr 2010, Greg Brown wrote:
>> 
>>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>>> 
>>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
>> 
>> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
>> 
>> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
>> 
>> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
>> 
>> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
>> 
>> https://www.allman.ms/
>> 
>> Ciao,
>> 
>> Michael
> 


Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Moving this to the dev list (if you are not subscribed there, you probably should be).

I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:

  <Label text="$foo"/>

This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:

  <Label text="$foo.bar"/>

I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:

  ScriptEngineBindingMonitor(String key, Object object, String property)

Assuming that "foo" is a Java bean, the second might look like:

  BeanPropertyMonitor(Object bean, String property, Object object, String property)

If "foo" is a Map, it might look like:

  MapValueMonitor(Map<String, ?> map, String key, Object object, String property)

These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).

Does that make sense?


On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:

> On Wed, 21 Apr 2010, Greg Brown wrote:
> 
>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>> 
>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
> 
> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
> 
> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
> 
> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
> 
> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
> 
> https://www.allman.ms/
> 
> Ciao,
> 
> Michael


Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Moving this to the dev list (if you are not subscribed there, you probably should be).

I have been thinking about this, and I think it might be pretty easy to achieve. Currently, we support the following syntax in WTKXSerializer:

  <Label text="$foo"/>

This means "load the value of the local variable 'foo' into the text property of this Label". I assume that what you would like it to mean is, "load the value of the local variable 'foo' into the 'text' property of this Label, and update 'text' whenever 'foo' changes". Is that correct? Further, I assume that you'd also want to support nested properties, e.g.:

  <Label text="$foo.bar"/>

I think this could be accomplished by a hypothetical set of monitor classes. The first would need to monitor the script engine scope, and would probably look like:

  ScriptEngineBindingMonitor(String key, Object object, String property)

Assuming that "foo" is a Java bean, the second might look like:

  BeanPropertyMonitor(Object bean, String property, Object object, String property)

If "foo" is a Map, it might look like:

  MapValueMonitor(Map<String, ?> map, String key, Object object, String property)

These classes would attach themselves as listeners to their respective sources, and propagate changes to the destination object (in this case, the Label instance).

Does that make sense?


On Apr 21, 2010, at 9:21 AM, Michael Allman wrote:

> On Wed, 21 Apr 2010, Greg Brown wrote:
> 
>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.
>> 
>> I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.
> 
> I have no beef with macro components, as long as they're well-encapsulated with well-defined, minimal interfaces.
> 
> On the other hand, I've seen designs where basically all of the high-level state is stored on a single class.  Major yuck-o.  I've seen "model" classes that are on the order of hundreds or thousands of lines of code. Then there are the global event dispatchers that everything is tied to. Kinda makes it hard to understand a class's interface and behavior when it's calling back to global objects.
> 
> When every object is tied back to some application global data-structure or other object somewhere on high (usually through a reference to a static variable or method), I get nervous.  It looks fragile.
> 
> I gave a 20 minute preso on my thoughts on rich GUI application design earlier this year to my local flex user group.  You might take a look if you feel like it.  It's small.  It's on my home page:
> 
> https://www.allman.ms/
> 
> Ciao,
> 
> Michael


Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
On Wed, 21 Apr 2010, Michael Allman wrote:

> On Wed, 21 Apr 2010, Greg Brown wrote:
>
>>> I am also not a fan of MVC frameworks for GUI applications. Basically, I 
>>> think their fundamental premise (that MVC is a valid approach to global 
>>> application design) is crap, but I'll save it for another time or never.
>> 
>> I used to agree with this, but now I see some value in the concept of a 
>> macro-level MVC design. I don't know that using a framework is necessarily 
>> the right way to accomplish it, but I do think the design pattern is valid. 
>> I also think it works well with the load/store model, since load()/store() 
>> is basically a higher-level get/set, and the event support can be provided 
>> by Pivot's new pub/sub messaging API.
>
> I have no beef with macro components, as long as they're well-encapsulated 
> with well-defined, minimal interfaces.
>
> On the other hand, I've seen designs where basically all of the high-level 
> state is stored on a single class.  Major yuck-o.  I've seen "model" classes 
> that are on the order of hundreds or thousands of lines of code. Then there 
> are the global event dispatchers that everything is tied to. Kinda makes it 
> hard to understand a class's interface and behavior when it's calling back to 
> global objects.
>
> When every object is tied back to some application global data-structure or 
> other object somewhere on high (usually through a reference to a static 
> variable or method), I get nervous.  It looks fragile.
>
> I gave a 20 minute preso on my thoughts on rich GUI application design 
> earlier this year to my local flex user group.  You might take a look if you 
> feel like it.  It's small.  It's on my home page:
>
> https://www.allman.ms/

Oh yeah.  I'll just add that I also link to a simple flex app I wrote for 
the preso on my page.  If you look at the source code you will get a 
better idea for how I use data binding and where I'm coming from.

Michael

Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
On Wed, 21 Apr 2010, Greg Brown wrote:

>> I am also not a fan of MVC frameworks for GUI applications. 
>> Basically, I think their fundamental premise (that MVC is a valid 
>> approach to global application design) is crap, but I'll save it for 
>> another time or never.
>
> I used to agree with this, but now I see some value in the concept of a 
> macro-level MVC design. I don't know that using a framework is 
> necessarily the right way to accomplish it, but I do think the design 
> pattern is valid. I also think it works well with the load/store model, 
> since load()/store() is basically a higher-level get/set, and the event 
> support can be provided by Pivot's new pub/sub messaging API.

I have no beef with macro components, as long as they're well-encapsulated 
with well-defined, minimal interfaces.

On the other hand, I've seen designs where basically all of the high-level 
state is stored on a single class.  Major yuck-o.  I've seen "model" 
classes that are on the order of hundreds or thousands of lines of code. 
Then there are the global event dispatchers that everything is tied to. 
Kinda makes it hard to understand a class's interface and behavior when 
it's calling back to global objects.

When every object is tied back to some application global data-structure 
or other object somewhere on high (usually through a reference to a static 
variable or method), I get nervous.  It looks fragile.

I gave a 20 minute preso on my thoughts on rich GUI application design 
earlier this year to my local flex user group.  You might take a look if 
you feel like it.  It's small.  It's on my home page:

https://www.allman.ms/

Ciao,

Michael

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
> I am also not a fan of MVC frameworks for GUI applications.  Basically, I think their fundamental premise (that MVC is a valid approach to global application design) is crap, but I'll save it for another time or never.

I used to agree with this, but now I see some value in the concept of a macro-level MVC design. I don't know that using a framework is necessarily the right way to accomplish it, but I do think the design pattern is valid. I also think it works well with the load/store model, since load()/store() is basically a higher-level get/set, and the event support can be provided by Pivot's new pub/sub messaging API.


Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
Hi Greg,

I am also not a fan of MVC frameworks for GUI applications.  Basically, I 
think their fundamental premise (that MVC is a valid approach to global 
application design) is crap, but I'll save it for another time or never.

You've brought up the messiness of data binding a couple times.  Just 
can't agree with that experience.  In fact, mine has been the opposite.  I 
started writing apps using a load/store approach and then I switched to 
data binding because

a.  it's simpler

b.  it's more efficient in terms of runtime performance and programmer 
(my) productivity

c.  it makes more complex use cases a lot easier

I'm not digging the "Lists and Maps as data models" idea.  I want behavior 
on my objects.  I want data structures with declared properties.  I'm 
greedy dammit.  Flex gives me all that with event-driven data binding.

Cheerio,

Michael

On Wed, 21 Apr 2010, Greg Brown wrote:

> Hi Michael,
>
> As I mentioned, Pivot does support data binding, just not the same way 
> it is handled in Flex. It uses a load/store model rather than an 
> event-driven one. We think that lends itself to cleaner application 
> design, especially when your application data comes from a REST service. 
> From my experience, event-based data binding just gets messy really 
> fast.
>
> Another common approach is to use an MVC framework such as PureMVC 
> (originally written for Flex but ported to a number of other platforms). 
> I'm not a huge fan of PureMVC specifically, but the fundamental concepts 
> are sound, and there are other alternatives as well.
>
> You might still be able to do what you describe if you take a more 
> loosely-typed approach (which may be what Flex actually does under the 
> hood, since it is ultimately based on a loosely typed language). If you 
> use Maps and Lists as your data structures, the events are already 
> defined for you.
>
> Hope this helps.
>
> Greg
>
> On Apr 21, 2010, at 8:02 AM, Michael Allman wrote:
>
>> Hi Todd,
>>
>> Let me see if I understand what would be involved here.  Suppose I have a crappy bean class that looks like this:
>>
>> class Person {
>> ...
>> public String getName() {...}
>> public void setName(String name) {...}
>> ...
>> }
>>
>> Then, following your example, I create a PersonListener interface that looks like this:
>>
>> interface PersonListener {
>> void nameChanged(Person person);
>> }
>>
>> Then I modify my Person class to add this:
>>
>> class Person {
>> ...
>> public ListenerList<PersonListener> getPersonListeners() {...}
>> ...
>> public String getName() {
>> ...
>> "if the name property has changed and all that shit then call all the PersonListeners"
>> }
>>
>> Is that right?  This looks really painful to me.  All I want to do is bind a property's value between two objects without pressing too many keys. This is a lot of keys to press.  And that's for one property.  Suppose I want to bind 50 properties (not on the same class, but spread around the system)?  500?
>>
>> Basically I want something that looks and works like binding in Flex and MXML, but I think it can be even simpler.
>>
>> I've been doing a bunch of Flex work lately and have come to the following two conclusions:
>>
>> 1.  I hate Flex because it's an unsupported cesspool of bugs and poor software design, except
>>
>> 2.  I like their data binding, and I use it pervasively in my application design.  In fact, I don't know a viable alternative.
>>
>> I'd really like to put Flex in the grave as far as my own career is concerned.  I'm tired of spending 2x - 3x as long as it should to get something done because I have to fix or work around or give up on all the bugs in flash player and flex that Adobe will never fix because they don't give a shit. That may not be very realistic in the short term, but Pivot is by far the most compelling alternative and competitor I have ever seen, and I love coding to the Java platform.
>>
>> I just need to convince Gregg and Co that Pivot needs data binding.  Ha!
>>
>> Cheers,
>>
>> Michael
>>
>> On Mon, 29 Mar 2010, Todd Volkert wrote:
>>
>>> What he said :-)
>>>
>>> Michael, I'd add that to your "simple" requierment, WTKX script might be the
>>> simplest way to wire up these types of quick event handlers.  You'd need
>>> your user object class to fire events the Pivot way (using Pivot's
>>> ListenerList).  Then, your WTKX could look something like this:
>>>
>>> <myPackage:UserData wtkx:id="userData"
>>> UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
>>> ...
>>> <TextInput wtkx:id="textInput"
>>> TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
>>>
>>> -T
>>>
>>> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
>>>
>>>> As you guessed, this type of data binding isn't currently supported. Having
>>>> worked with data binding systems like this in the past, I find that it can
>>>> lead to confusing and inefficient code, as too many things are happening in
>>>> the background when they don't need to be.
>>>>
>>>> The load()/store() model used by Pivot maps more closely to how data
>>>> binding is used in many practical applications (especially those that are
>>>> REST-based): after making a server query to retrieve your data, you populate
>>>> your form using the load() method. When you want to save it back to the
>>>> server, you store() it into your model and upload it back to the server.
>>>>
>>>> More dynamic updates (like those you describe) can easily be achieved via
>>>> event listeners. This way, your application has complete control over what
>>>> is updated and when.
>>>>
>>>> G
>>>>
>>>> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I have two related questions on data binding in Pivot.  After a lot of
>>>> searching and digging, I'm pretty sure the answer is "no" to both of these
>>>> questions.  I just want to confirm so we can move on to step 2---how to fix
>>>> the situation.
>>>>>
>>>>> So suppose we have some kind of User object with a r/w "name" property
>>>> and a Label declared in some WTKX file.  My questions are:
>>>>>
>>>>> 1.  Is there a simple way to bind the Label's "text" property to the User
>>>> object's "name" property in such a way that as the app user types into the
>>>> text field the value of the latter property is set to the value of the
>>>> former (label.text => user.name)?
>>>>>
>>>>> 2.  Is there a simple way to bind the User object's "name" property to
>>>> the Label's "text" property in such a way that when the value of the former
>>>> property is changed, the value of the Label's "text" property is set to the
>>>> new value of the User object's "name" property?
>>>>>
>>>>> This is a very important capability for me, and it's one that I think has
>>>> a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts
>>>> first.  Maybe I'm missing something that's already there, or some other
>>>> feature that's more powerful than this.
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Michael
>>>>
>>>>
>>>
>

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
Hi Michael,

As I mentioned, Pivot does support data binding, just not the same way it is handled in Flex. It uses a load/store model rather than an event-driven one. We think that lends itself to cleaner application design, especially when your application data comes from a REST service. From my experience, event-based data binding just gets messy really fast. 

Another common approach is to use an MVC framework such as PureMVC (originally written for Flex but ported to a number of other platforms). I'm not a huge fan of PureMVC specifically, but the fundamental concepts are sound, and there are other alternatives as well.

You might still be able to do what you describe if you take a more loosely-typed approach (which may be what Flex actually does under the hood, since it is ultimately based on a loosely typed language). If you use Maps and Lists as your data structures, the events are already defined for you.

Hope this helps.

Greg

On Apr 21, 2010, at 8:02 AM, Michael Allman wrote:

> Hi Todd,
> 
> Let me see if I understand what would be involved here.  Suppose I have a crappy bean class that looks like this:
> 
> class Person {
> ...
> public String getName() {...}
> public void setName(String name) {...}
> ...
> }
> 
> Then, following your example, I create a PersonListener interface that looks like this:
> 
> interface PersonListener {
> void nameChanged(Person person);
> }
> 
> Then I modify my Person class to add this:
> 
> class Person {
> ...
> public ListenerList<PersonListener> getPersonListeners() {...}
> ...
> public String getName() {
> ...
> "if the name property has changed and all that shit then call all the PersonListeners"
> }
> 
> Is that right?  This looks really painful to me.  All I want to do is bind a property's value between two objects without pressing too many keys. This is a lot of keys to press.  And that's for one property.  Suppose I want to bind 50 properties (not on the same class, but spread around the system)?  500?
> 
> Basically I want something that looks and works like binding in Flex and MXML, but I think it can be even simpler.
> 
> I've been doing a bunch of Flex work lately and have come to the following two conclusions:
> 
> 1.  I hate Flex because it's an unsupported cesspool of bugs and poor software design, except
> 
> 2.  I like their data binding, and I use it pervasively in my application design.  In fact, I don't know a viable alternative.
> 
> I'd really like to put Flex in the grave as far as my own career is concerned.  I'm tired of spending 2x - 3x as long as it should to get something done because I have to fix or work around or give up on all the bugs in flash player and flex that Adobe will never fix because they don't give a shit. That may not be very realistic in the short term, but Pivot is by far the most compelling alternative and competitor I have ever seen, and I love coding to the Java platform.
> 
> I just need to convince Gregg and Co that Pivot needs data binding.  Ha!
> 
> Cheers,
> 
> Michael
> 
> On Mon, 29 Mar 2010, Todd Volkert wrote:
> 
>> What he said :-)
>> 
>> Michael, I'd add that to your "simple" requierment, WTKX script might be the
>> simplest way to wire up these types of quick event handlers.  You'd need
>> your user object class to fire events the Pivot way (using Pivot's
>> ListenerList).  Then, your WTKX could look something like this:
>> 
>> <myPackage:UserData wtkx:id="userData"
>> UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
>> ...
>> <TextInput wtkx:id="textInput"
>> TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
>> 
>> -T
>> 
>> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
>> 
>>> As you guessed, this type of data binding isn't currently supported. Having
>>> worked with data binding systems like this in the past, I find that it can
>>> lead to confusing and inefficient code, as too many things are happening in
>>> the background when they don't need to be.
>>> 
>>> The load()/store() model used by Pivot maps more closely to how data
>>> binding is used in many practical applications (especially those that are
>>> REST-based): after making a server query to retrieve your data, you populate
>>> your form using the load() method. When you want to save it back to the
>>> server, you store() it into your model and upload it back to the server.
>>> 
>>> More dynamic updates (like those you describe) can easily be achieved via
>>> event listeners. This way, your application has complete control over what
>>> is updated and when.
>>> 
>>> G
>>> 
>>> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>>> 
>>>> Hello,
>>>> 
>>>> I have two related questions on data binding in Pivot.  After a lot of
>>> searching and digging, I'm pretty sure the answer is "no" to both of these
>>> questions.  I just want to confirm so we can move on to step 2---how to fix
>>> the situation.
>>>> 
>>>> So suppose we have some kind of User object with a r/w "name" property
>>> and a Label declared in some WTKX file.  My questions are:
>>>> 
>>>> 1.  Is there a simple way to bind the Label's "text" property to the User
>>> object's "name" property in such a way that as the app user types into the
>>> text field the value of the latter property is set to the value of the
>>> former (label.text => user.name)?
>>>> 
>>>> 2.  Is there a simple way to bind the User object's "name" property to
>>> the Label's "text" property in such a way that when the value of the former
>>> property is changed, the value of the Label's "text" property is set to the
>>> new value of the User object's "name" property?
>>>> 
>>>> This is a very important capability for me, and it's one that I think has
>>> a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts
>>> first.  Maybe I'm missing something that's already there, or some other
>>> feature that's more powerful than this.
>>>> 
>>>> Cheers,
>>>> 
>>>> Michael
>>> 
>>> 
>> 


Re: data binding question

Posted by Michael Allman <ms...@allman.ms>.
Hi Todd,

Let me see if I understand what would be involved here.  Suppose I have a 
crappy bean class that looks like this:

class Person {
...
public String getName() {...}
public void setName(String name) {...}
...
}

Then, following your example, I create a PersonListener interface that 
looks like this:

interface PersonListener {
void nameChanged(Person person);
}

Then I modify my Person class to add this:

class Person {
...
public ListenerList<PersonListener> getPersonListeners() {...}
...
public String getName() {
...
"if the name property has changed and all that shit then call all the 
PersonListeners"
}

Is that right?  This looks really painful to me.  All I want to do is bind 
a property's value between two objects without pressing too many keys. 
This is a lot of keys to press.  And that's for one property.  Suppose I 
want to bind 50 properties (not on the same class, but spread around the 
system)?  500?

Basically I want something that looks and works like binding in Flex and 
MXML, but I think it can be even simpler.

I've been doing a bunch of Flex work lately and have come to the following 
two conclusions:

1.  I hate Flex because it's an unsupported cesspool of bugs and poor 
software design, except

2.  I like their data binding, and I use it pervasively in my application 
design.  In fact, I don't know a viable alternative.

I'd really like to put Flex in the grave as far as my own career is 
concerned.  I'm tired of spending 2x - 3x as long as it should to get 
something done because I have to fix or work around or give up on all the 
bugs in flash player and flex that Adobe will never fix because they don't 
give a shit. That may not be very realistic in the short term, but Pivot 
is by far the most compelling alternative and competitor I have ever seen, 
and I love coding to the Java platform.

I just need to convince Gregg and Co that Pivot needs data binding.  Ha!

Cheers,

Michael

On Mon, 29 Mar 2010, Todd Volkert wrote:

> What he said :-)
>
> Michael, I'd add that to your "simple" requierment, WTKX script might be the
> simplest way to wire up these types of quick event handlers.  You'd need
> your user object class to fire events the Pivot way (using Pivot's
> ListenerList).  Then, your WTKX could look something like this:
>
> <myPackage:UserData wtkx:id="userData"
> UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
> ...
> <TextInput wtkx:id="textInput"
> TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>
>
> -T
>
> On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:
>
>> As you guessed, this type of data binding isn't currently supported. Having
>> worked with data binding systems like this in the past, I find that it can
>> lead to confusing and inefficient code, as too many things are happening in
>> the background when they don't need to be.
>>
>> The load()/store() model used by Pivot maps more closely to how data
>> binding is used in many practical applications (especially those that are
>> REST-based): after making a server query to retrieve your data, you populate
>> your form using the load() method. When you want to save it back to the
>> server, you store() it into your model and upload it back to the server.
>>
>> More dynamic updates (like those you describe) can easily be achieved via
>> event listeners. This way, your application has complete control over what
>> is updated and when.
>>
>> G
>>
>> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>>
>>> Hello,
>>>
>>> I have two related questions on data binding in Pivot.  After a lot of
>> searching and digging, I'm pretty sure the answer is "no" to both of these
>> questions.  I just want to confirm so we can move on to step 2---how to fix
>> the situation.
>>>
>>> So suppose we have some kind of User object with a r/w "name" property
>> and a Label declared in some WTKX file.  My questions are:
>>>
>>> 1.  Is there a simple way to bind the Label's "text" property to the User
>> object's "name" property in such a way that as the app user types into the
>> text field the value of the latter property is set to the value of the
>> former (label.text => user.name)?
>>>
>>> 2.  Is there a simple way to bind the User object's "name" property to
>> the Label's "text" property in such a way that when the value of the former
>> property is changed, the value of the Label's "text" property is set to the
>> new value of the User object's "name" property?
>>>
>>> This is a very important capability for me, and it's one that I think has
>> a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts
>> first.  Maybe I'm missing something that's already there, or some other
>> feature that's more powerful than this.
>>>
>>> Cheers,
>>>
>>> Michael
>>
>>
>

Re: data binding question

Posted by Todd Volkert <tv...@gmail.com>.
What he said :-)

Michael, I'd add that to your "simple" requierment, WTKX script might be the
simplest way to wire up these types of quick event handlers.  You'd need
your user object class to fire events the Pivot way (using Pivot's
ListenerList).  Then, your WTKX could look something like this:

<myPackage:UserData wtkx:id="userData"
UserDataListener.fooChanged="textInput.setText(userData.getFoo())"/>
...
<TextInput wtkx:id="textInput"
TextInputTextListener.textChanged="userData.setFoo(textInput.getText())"/>

-T

On Mon, Mar 29, 2010 at 8:47 AM, Greg Brown <gk...@mac.com> wrote:

> As you guessed, this type of data binding isn't currently supported. Having
> worked with data binding systems like this in the past, I find that it can
> lead to confusing and inefficient code, as too many things are happening in
> the background when they don't need to be.
>
> The load()/store() model used by Pivot maps more closely to how data
> binding is used in many practical applications (especially those that are
> REST-based): after making a server query to retrieve your data, you populate
> your form using the load() method. When you want to save it back to the
> server, you store() it into your model and upload it back to the server.
>
> More dynamic updates (like those you describe) can easily be achieved via
> event listeners. This way, your application has complete control over what
> is updated and when.
>
> G
>
> On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:
>
> > Hello,
> >
> > I have two related questions on data binding in Pivot.  After a lot of
> searching and digging, I'm pretty sure the answer is "no" to both of these
> questions.  I just want to confirm so we can move on to step 2---how to fix
> the situation.
> >
> > So suppose we have some kind of User object with a r/w "name" property
> and a Label declared in some WTKX file.  My questions are:
> >
> > 1.  Is there a simple way to bind the Label's "text" property to the User
> object's "name" property in such a way that as the app user types into the
> text field the value of the latter property is set to the value of the
> former (label.text => user.name)?
> >
> > 2.  Is there a simple way to bind the User object's "name" property to
> the Label's "text" property in such a way that when the value of the former
> property is changed, the value of the Label's "text" property is set to the
> new value of the User object's "name" property?
> >
> > This is a very important capability for me, and it's one that I think has
> a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts
> first.  Maybe I'm missing something that's already there, or some other
> feature that's more powerful than this.
> >
> > Cheers,
> >
> > Michael
>
>

Re: data binding question

Posted by Greg Brown <gk...@mac.com>.
As you guessed, this type of data binding isn't currently supported. Having worked with data binding systems like this in the past, I find that it can lead to confusing and inefficient code, as too many things are happening in the background when they don't need to be.

The load()/store() model used by Pivot maps more closely to how data binding is used in many practical applications (especially those that are REST-based): after making a server query to retrieve your data, you populate your form using the load() method. When you want to save it back to the server, you store() it into your model and upload it back to the server.

More dynamic updates (like those you describe) can easily be achieved via event listeners. This way, your application has complete control over what is updated and when.

G

On Mar 28, 2010, at 11:48 PM, Michael Allman wrote:

> Hello,
> 
> I have two related questions on data binding in Pivot.  After a lot of searching and digging, I'm pretty sure the answer is "no" to both of these questions.  I just want to confirm so we can move on to step 2---how to fix the situation.
> 
> So suppose we have some kind of User object with a r/w "name" property and a Label declared in some WTKX file.  My questions are:
> 
> 1.  Is there a simple way to bind the Label's "text" property to the User object's "name" property in such a way that as the app user types into the text field the value of the latter property is set to the value of the former (label.text => user.name)?
> 
> 2.  Is there a simple way to bind the User object's "name" property to the Label's "text" property in such a way that when the value of the former property is changed, the value of the Label's "text" property is set to the new value of the User object's "name" property?
> 
> This is a very important capability for me, and it's one that I think has a reasonably simple solution.  But I'd like to get a Pivot expert's thoughts first.  Maybe I'm missing something that's already there, or some other feature that's more powerful than this.
> 
> Cheers,
> 
> Michael