I have a question : when we need several variables for function, if it's possible, what's the syntax ?

function toUpperCase(value1, value2) {
       return value2.toUpperCase() + " " value2.toUpperCase();
}


Le 27/08/2010 19:26, Olivier Dutrieux a écrit :
 I will test it now :)

Le 27/08/2010 17:15, Greg Brown a écrit :
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:

Reply via email to