Version 15.1 by Pascal Robert on 2007/09/03 17:16

Show last authors
1 == Overview ==
2
3 OGNL stands for "Object Graph Navigation Language", and it defines an entire family of key-value coding-like abilities. As Jonathan Rentzsch put it in his CAWUG presentation on Project WOnder, "Think: Key-Value Coding on Steroids". You can get more information on the specifics on OGNL at [[the official OGNL website>>http://www.ognl.org]].
4
5 WOOgnl provides a framework that integrates the OGNL syntax into WO's standard binding resolution. By simply including the WOOgnl framework on your build path and preceding your binding value with a ",,", it will be interpreted by WOOgnl.,,
6
7 Here are some examples that demonstrate just a tiny bit of the really cool things you can do:
8
9 * value=",,Hello Mr. + session.user.firstName";,,
10 * value=",,name.length().(#this>100?2**#this:20+#this)";**,,
11 * value=",,#A=new NSMutableArray(),#A.addObject(name),#A";,,
12
13 Here are some examples provided by Max Muller, WOOgnl's original author:
14
15 {{code}}
16
17 // Calling methods with arguments
18 Repetition1: WORepetition {
19 item = arrayItem;
20 list = "~sort(anArray, \"name\")";
21
22
23
24 {{/code}}
25
26 {{code}}
27
28 // Calling static methods
29 Repetition2: WORepetition {
30 item = arrayItem;
31 list = "~@er.extensions.ERXArrayUtilities@sortedArraySortedWithKey(anArray, \"name\")";
32 }
33
34 {{/code}}
35
36 {{code}}
37
38 // Accessing static ivars
39 String1: WOString {
40 value = "~@ognl.webobjects.WOOgnl@OgnlSpecialCharacters";
41 }
42
43 {{/code}}
44
45 {{code}}
46
47 // Use of conditionals, note that every previous value of the . is
48 // pushed into the ivar #this
49 String2: WOString {
50 value = "~name.length().(#this > 100? 2*#this : 20+#this)";
51 }
52
53
54 {{/code}}
55
56 {{code}}
57
58 // String concat
59 String3: WOString {
60 value = "~\"Hello Max \" + name";
61
62
63
64 {{/code}}
65
66 {{code}}
67
68 // Use of set operator in. can also use in against NSArray and
69 NSSet objects
70 String4: WOString {
71 value = "~name in {\"Main\", \"Something\"} ? \"Yes\" : \"No\"";
72 }
73
74
75 {{/code}}
76
77 {{code}}
78
79 // Variable declaration. Note that commas allow multiple actions
80 // per expression.
81 String5: WOString {
82 value = "~#A=new com.webobjects.foundation.NSMutableArray(),#A.addObject(name), #A.addObjectsFromArray(session.languages), #A";
83 }
84
85
86 {{/code}}