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 <[email protected]> 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



Reply via email to