Changes for page WebObjects with Scala
Last modified by Ravi Mendis on 2011/05/10 02:10
From version 371.1
edited by Ravi Mendis
on 2009/12/08 19:04
on 2009/12/08 19:04
Change comment:
There is no comment for this version
To version 373.1
edited by Ravi Mendis
on 2009/12/08 19:09
on 2009/12/08 19:09
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -157,12 +157,29 @@ 157 157 158 158 ==== Scala Annotations vs. Generic Accessors ==== 159 159 160 -An example of accessing variables in the following languages: 160 +An example of accessing variables in WebObjects with the following languages: 161 161 162 162 |= |= Objective-C |= Java |= Scala 163 -|= getter | ##object name## | ##object. getName()## | ##object.name##163 +|= getter | ##object name## | ##object.name()## | ##object.name## 164 164 |= setter | ##object setName:aName## | ##object.setName(aName)## | ##object.name = aName## 165 165 166 +Of course in Java, we may generate EO classes with "get" methods as well in order to stick to convention. 167 +In scala there is an additional convenience we may use to produce "get" and "set" methods in addition to the default Scala accessors - Scala Annotations. 168 + 169 +E.g, in Main.scala we annotate our component keys with ##@BeanProperty## to automatically create public "set" and "get" methods. 170 +These variables can then be accessed via //KVC//. 171 + 172 +{{code}} 173 + 174 + @BeanProperty 175 + var username: String = "" 176 + @BeanProperty 177 + var password: String = "" 178 + @BeanProperty 179 + var isAssistantCheckboxVisible: Boolean = false 180 + 181 +{{/code}} 182 + 166 166 == How to Use Scala Collections with EOF == 167 167 168 168 One of the benefits of Scala is its very powerful, concurrency-ready collection classes - primarily ##List##, ##Map##, ##Seq## and ##Set##.