Hi all, I have just checked in support for this feature. The Property Binding tutorial includes a demonstration:
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/databinding/property_binding.bxml For example: function toUpperCase(value) { return value.toUpperCase(); } <TextInput bxml:id="textInput" Form.label="Text Input"/> <Label Form.label="Uppercase Text" text="${toUpperCase:textInput.text}"/> There is also an example of creating a mapping in Java: http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/databinding/PropertyBinding.java You may notice that I chose to use the "foo:bar" syntax to specify a mapping function rather than "foo(bar)". I did this for the following reasons: 1) It is easier to parse. 2) It doesn't look like a function, whereas "foo(bar)" does. The user might incorrectly assume that "foo(bar)" is an inline function declaration, which it is not (it is never actually evaluated by the script engine - the function referred to by this expression is what is actually evaluated). 3) It may look like a JavaScript function, but it doesn't look like a Groovy closure, for example. If Groovy is being used as the page language, this could be confusing. Let me know if you have any questions or comments. Thanks! Greg On Aug 25, 2010, at 8:10 AM, Greg Brown wrote: > Well, if EL isn't that popular, and a mapping function is sufficient, we > should probably stick with the simpler approach. It will be much easier to > implement, and we can always consider adding or changing expression syntax in > a later release if there appears to be a need for it. > > On Aug 24, 2010, at 5:55 PM, Dirk Moebius wrote: > >> OTOH, everybody hates JSF EL because of its deficiencies: only small subset >> of common language expressions, yet another DSL to learn, no method >> invocations with parameters (solved in JSF 2.0?!? I dunno...) >> >> Dirk. >> >> Greg Brown wrote: >>> That's very interesting. I wasn't aware of EL. Definitely worth looking >>> into. >>> >>> On Aug 24, 2010, at 5:08 PM, Dirk Möbius wrote: >>> >>>> Greg Brown wrote: >>>>> However, there may still be something we can do. Let's give it some >>>>> thought. >>>> >>>> Maybe Pivot should go the JSF route and support EL expressions: >>>> >>>> <PushButton enable="${!listView.selectedRanges.empty}"/> >>>> <PushButton enable="${listView.selectedItems.length> 0}"/> >>>> <PushButton enable="${listView.selectedItem != null}"/> >>>> >>>> Apache commons-el comes to mind. >>>> >>>> Dirk. >>> >> >
