Changes for page WebObjects with Scala

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

From version 350.1
edited by Ravi Mendis
on 2009/10/12 21:31
Change comment: There is no comment for this version
To version 353.1
edited by Ravi Mendis
on 2009/10/13 21:35
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -153,6 +153,25 @@
153 153  
154 154  {{/code}}
155 155  
156 +== How to Use Scala Collections with EOF ==
157 +
158 +One of the benefits of Scala is its very powerful, concurrency-ready collection classes - primarily ##List##, ##Map##, ##Seq## and ##Set##.
159 +Employing these instead of ##NSArray## and ##NSDictionary## in WebObjects/EOF may be challenging.
160 +
161 +But one may modify the EO templates to produce API such as:
162 +
163 +{{code}}
164 +
165 +def movies: NSArray[EOGenericRecord] = {
166 + storedValueForKey(_Studio.Keys.MOVIES).asInstanceOf[NSArray[EOGenericRecord]]
167 +}
168 +
169 +def moviesList: List[EOGenericRecord] = {
170 + movies.objects.toList
171 +}
172 +
173 +{{/code}}
174 +
156 156  == How to Add Scala to a WO Project ==
157 157  
158 158  {{include value="WOL:Adding Scala Support to a WOLips Project"}}{{/include}}
... ... @@ -165,16 +165,18 @@
165 165  
166 166  == WO Scala Example ==
167 167  
168 -The following example is a mixed Java/Scala version of the WO Movies D2W app.
187 +The following example is an almost 100% Scala WO app. In reality it is a mixed Java/Scala app:
169 169  All the EO logic and WO components are in Scala.
170 170  Only the Application class is Java.
171 171  
191 +It is based on the D2W Movies example.
192 +
172 172  {{attachments patterns=".*zip"}}{{/attachments}}
173 173  
174 174  === Setup ===
175 175  
176 176  1. [[Install the Scala eclipse IDE>>http://www.scala-lang.org/node/94]]
177 -1. Install and run the OpenBase OBMovies database.
198 +1. Install and start the OpenBase OBMovies database.
178 178  1. Right-click on Application.java and run as a WOApplication (as usual).
179 179  
180 180  ==== EO Templates ====
... ... @@ -183,5 +183,6 @@
183 183  
184 184  When you create your ##.eogen## file, be sure to make the following changes in the EOGenerator Editor:
185 185  
207 +1. Point to the local .eotemplate files for ##Entity## and ##//Entity//##
186 186  1. Change the File Names Extension to "scala"
187 187  1. Uncheck Java under Options