Changes for page Development-WO Component-Code Template and WODs
Last modified by Pascal Robert on 2012/07/19 21:09
From version 4.1
edited by Quinton Dolan
on 2007/07/15 02:49
on 2007/07/15 02:49
Change comment:
There is no comment for this version
To version 9.1
edited by Quinton Dolan
on 2007/07/15 02:51
on 2007/07/15 02:51
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -92,8 +92,16 @@ 92 92 93 93 However, personName has no quotes, and is thus interpreted with Key-Value-Coding (KVC). Key-Value-Coding allows you to string together a series of accessor method calls or field references as a string that WebObjects will dynamically resolve using Java reflection. For instance, in the example above, personName would attempt to find any accessor or field named: ##public String getPersonName(), public String //getPersonName(), public String personName(), public String //personName(), public String personName, public String //personName//##//. So if your Java class had a ##public String getPersonName()## method, the return value of that method would be passed into the ##setValue(..)## method of your WOComponent. Where KVC gets more interesting is that you can construct a series of method calls.// 94 94 95 -For instance, instead of a person, imagine that your WOSession had a ##public Person person()## method, which had a ##public Address address()## method, which had a ##public String zipCode()## method. Your WOD file binding could look like ##value = session.person.address.zipCode;##, which would bind the zipcode of the address of the person in your sesson to value. Even more interesting are the NSArray operations that Foundation provides. For instance, if your session had a ##public NSArray purchaseAmounts()## that returned an array of ##BigDecimal##-s, you could refer to the binding ##value = session.purchaseAmounts.@sum##, which would return the sum of the values of the array. There are several other Array operations available in the Foundation classes, and Project Wonder provides even more in its [[ERXArrayUtilities>>Programming__WebObjects-WOnder-ERXArrayUtilities]] class. For even more advanced KVC capabilities, read the [[WOOgnl>>Programming__WebObjects-Project WONDER-Frameworks-WOOgnl]] section of Project Wonder.95 +For instance, instead of a person, imagine that your WOSession had a ##public Person person()## method, which had a ##public Address address()## method, which had a ##public String zipCode()## method. Your WOD file binding could look like: 96 96 97 +{{code}} 98 + 99 +value = session.person.address.zipCode; 100 + 101 +{{/code}} 102 + 103 +which would bind the zipcode of the address of the person in your sesson to value. Even more interesting are the NSArray operations that Foundation provides. For instance, if your session had a ##public NSArray purchaseAmounts()## that returned an array of ##BigDecimal##-s, you could refer to the binding ##value = session.purchaseAmounts.@sum##, which would return the sum of the values of the array. There are several other Array operations available in the Foundation classes, and Project Wonder provides even more in its [[ERXArrayUtilities>>Programming__WebObjects-WOnder-ERXArrayUtilities]] class. For even more advanced KVC capabilities, read the [[WOOgnl>>Programming__WebObjects-Project WONDER-Frameworks-WOOgnl]] section of Project Wonder. 104 + 97 97 A single WOD entry can contain several binding declarations, and a WOD file can contain many entries. For example, here is an excerpt from a real WOD file: 98 98 99 99 {{code}}