This presentation is about doing Scala with Wicket. The basics of Scala are handled with a simple Hello World application. After that I explain some functional concepts and show a basic Wicket application written in Scala.
Daan van Etten gave this presentation at the ApacheCon Wicket meetup in Amsterdam, March 24, 2009. You can find the mentioned source code at http://stuq.nl/weblog/2009-03-24/amsterdam-wicket-meetup-2009
110. +
class HelloWorld extends WebApplication {
def main(args: Array[String]) {
println(quot;Hello, world!quot;)
}
}
Wednesday, March 25, 2009
111. +
class HelloWorld extends WebApplication {
}
Wednesday, March 25, 2009
112. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
Wednesday, March 25, 2009
113. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
}
Wednesday, March 25, 2009
114. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
}
Wednesday, March 25, 2009
115. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
}
Wednesday, March 25, 2009
116. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
}
Wednesday, March 25, 2009
117. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
add(form)
}
Wednesday, March 25, 2009
118. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
add(form)
form.add(new TextField(quot;namequot;,
}
Wednesday, March 25, 2009
119. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
add(form)
form.add(new TextField(quot;namequot;,
new PropertyModel(this, quot;namequot;)))
}
Wednesday, March 25, 2009
120. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
add(form)
form.add(new TextField(quot;namequot;,
new PropertyModel(this, quot;namequot;)))
form.add(new Label(quot;helloworldquot;,
}
Wednesday, March 25, 2009
121. +
class HelloWorld extends WebApplication {
def getHomePage = classOf[HomePage]
}
class HomePage extends WebPage {
var name = quot;quot;
val form = new Form(quot;formquot;)
add(form)
form.add(new TextField(quot;namequot;,
new PropertyModel(this, quot;namequot;)))
form.add(new Label(quot;helloworldquot;,
new PropertyModel(this, quot;namequot;)))
}
Wednesday, March 25, 2009
122. +
<body>
<p><b>Hello, Wicket World!</b></p>
<form wicket:id=quot;formquot;>
What's your name? <br/>
<input wicket:id=quot;namequot;/>
<input type=quot;submitquot; value = quot;OKquot; />
<p>Your name is:
<b><span wicket:id=quot;helloworldquot;/></b>
</p>
</form>
</body>
Wednesday, March 25, 2009
192. Java Scala
public interface SomeInterface {
void doSomething(String argument);
}
class SomeImplementation extends SomeInterface {
def doSomething(argument: String):Unit = {
println(argument)
}
}
Wednesday, March 25, 2009
193. Java Scala
public interface SomeInterface {
void doSomething(String argument);
}
class SomeImplementation extends SomeInterface {
}
Wednesday, March 25, 2009
194. Java Scala
Error: class SomeImplementation needs to be abstract
since method doSomething in trait SomeInterface of
type (java.lang.String)Unit is not defined.
Wednesday, March 25, 2009
195. Java Scala
Java and Scala combined:
Circular dependencies
Wednesday, March 25, 2009
211. Multiple articles covering a
feature by feature comparison
of Scala and Java
http://blogs.sun.com/sundararajan/entry/scala_for_java_programmers
Wednesday, March 25, 2009
212. Series of 6 great articles
covering a lot of Scala.
Aimed at Java developers.
http://www.codecommit.com/blog/scala/roundup-scala-for-java-refugees
Wednesday, March 25, 2009
Pizza is an open-source superset of the Java programming language with the following new features:
Generics
Function pointers
Class cases and pattern matching (a.k.a Algebraic types)
Started designing Scala in 2001
In 2001, the design for Scala started
Scala, whose design began in 2001, and which was first released in 2003. Scala is not an extension of Java, but it is completely interoperable with it. Scala translates to Java bytecodes, and the efficiency of its compiled programs usually equals Java's. A second implementation of Scala compiles to .NET. (this version is currently out of date, however).
Scala was designed to be both object-oriented and functional. It is a pure object-oriented language in the sense that every value is an object. Objects are defined by classes, which can be composed using mixin composition. Scala is also a functional language in the sense that every function is a value. Functions can be nested, and they can operate on data using pattern matching.
2003, first release of Scala
From the start, Scala is functional and object oriented, like Java
From the start, Scala is purely functional.
functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data.
Like Java, unlike Groovy
This also works with functions
def sayHello = System.out.println(\"hello world\")
This also works with functions
def sayHello = System.out.println(\"hello world\")
This also works with functions
def sayHello = System.out.println(\"hello world\")
This also works with functions
def sayHello = System.out.println(\"hello world\")
The + is a method defined in class Int
The + is a method defined in class Int
The name Scala stands for “scalable language.” The language is so named because it was designed to grow with the demands of its users. You can apply Scala to a wide range of programming tasks, from writing small scripts to building large systems.
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Functional programming languages generally avoid state and try to have immutability
The + is a method defined in class Int
The + is a method defined in class Int
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Higher order functions accept functions as parameters and return functions too.
Higher order functions accept functions as parameters and return functions too.
Higher order functions accept functions as parameters and return functions too.
Higher order functions accept functions as parameters and return functions too.
Higher order functions accept functions as parameters and return functions too.
Higher order functions accept functions as parameters and return functions too.
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).
Erlang,[2] OCaml,[3] Haskell,[4] Scheme[5][6] and domain-specific programming languages like R (statistics),[7] Mathematica (symbolic math),[8] J and K (financial analysis), and XSLT (XML).