pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Allman <...@allman.ms>
Subject Re: data binding question
Date Wed, 21 Apr 2010 12:33:42 GMT
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
>

Mime
View raw message