Changes for page WebObjects with Scala

Last modified by Ravi Mendis on 2011/05/10 02:10

From version 338.1
edited by Ravi Mendis
on 2009/12/15 18:08
Change comment: There is no comment for this version
To version 340.1
edited by Ravi Mendis
on 2009/10/13 18:54
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -47,10 +47,8 @@
47 47  Scala doesn't have static variables or methods. However, a class can have a //Companion Object// that will allow you to achieve something equivalent to static variables.
48 48  One of the advantages of this approach is that it is **thread-safe**, so you don't have to worry about synchronizing access to these fields in a concurrent application.
49 49  
50 -The following is an example of the use of a //Companion Object// for Talent in Scala instead of Talent static fields in Java.
50 +In Java:
51 51  
52 -Java:
53 -
54 54  {{code}}
55 55  
56 56  public class _Talent extends EOGenericRecord {
... ... @@ -58,11 +58,11 @@
58 58  
59 59  {{/code}}
60 60  
61 -Scala:
59 +In Scala:
62 62  
63 63  {{code}}
64 64  
65 -object Talent extends EOGenericRecord {
63 +object _Talent extends EOGenericRecord {
66 66   val ENTITY_NAME = "Talent"
67 67  
68 68  {{/code}}
... ... @@ -155,28 +155,6 @@
155 155  
156 156  {{/code}}
157 157  
158 -==== Scala Annotations vs. Generic Accessors ====
159 -
160 -An example of accessing variables in WebObjects with the following languages:
161 -
162 -|= |= Objective-C |= Java |= Scala
163 -|= getter | ##object name## | ##object.name()## | ##object.name##
164 -|= setter | ##object setName:aName## | ##object.setName(aName)## | ##object.name = aName##
165 -
166 -Of course in Java, we may generate WebObjects 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 var username = new String()
175 -@BeanProperty var password = new String()
176 -@BeanProperty var isAssistantCheckboxVisible = false
177 -
178 -{{/code}}
179 -
180 180  == How to Use Scala Collections with EOF ==
181 181  
182 182  One of the benefits of Scala is its very powerful, concurrency-ready collection classes - primarily ##List##, ##Map##, ##Seq## and ##Set##.
... ... @@ -219,21 +219,15 @@
219 219  === Setup ===
220 220  
221 221  1. [[Install the Scala eclipse IDE>>http://www.scala-lang.org/node/94]]
222 -1. Install and start the OpenBase OBMovies database.
198 +1. Install and run the OpenBase OBMovies database.
223 223  1. Right-click on Application.java and run as a WOApplication (as usual).
224 224  
225 225  ==== EO Templates ====
226 226  
203 +See: [[Scala templates>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]]
204 +
227 227  When you create your ##.eogen## file, be sure to make the following changes in the EOGenerator Editor:
228 228  
229 -1. Point to the local [[Scala versions>>http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions]] of the .eotemplate files for ##Entity## and ##//Entity//##
207 +1. Point to the local .eotemplate files for ##Entity## and ##//Entity//##
230 230  1. Change the File Names Extension to "scala"
231 -1. In Destination Paths set the Superclass Package (e.g: base)
232 232  1. Uncheck Java under Options
233 -
234 -== How to Build & Deploy a WebObjects Scala Project with Ant ==
235 -
236 -1. Download an install Scala
237 -1. The ##scala.home## (the location Scala has been installed onto) to the project ##build.properties## file
238 -1. Add the ##scalac## tasks to the ant build.xml file
239 -1. Customise the app classpath file. i.e either ##MacOSClasspath.txt## or ##UNIXClasspath.txt##. You will need to add an entry for ##scala-library.jar##