tags:

views:

1572

answers:

4

Could you share your experience of using Scala and Wicket together? Do they fit naturally to each other? Do you get advantage of using Scala (and FP) with Wicket over using Java? Why did (would) you prefer Wicket over Lift?

+2  A: 

I've used Scala + Wicket a little bit -- it's a good point to introduce some Scala. Closures with can help to reduce the lines of of code in a Wicket controller, given a few implicit conversions or utility methods. Even Dave Pollak once suggested this combination, if you prefer Wicket to Lift or have an existing Wicket application you want to retrofit Scala with.

Just be careful about the datatypes you use in any stateful Wicket components as they must be serializable. You can sometimes do without this, and use stateless Wicket components.

retronym
+9  A: 

For those interested in looking at code, I re-implemented the Seam "Hotel Booking" demo in Scala + Wicket here: Browse | SVN - the Java + Wicket version is here: Browse | SVN

I used the (not yet final) Scala 2.8 and the NetBeans plugin. Was meaning to blog in detail about it (there's even a Groovy + Wicket implementation in place) but a few high-level impressions below; as an example, here's the same UI code in Java | Scala. Observations:

  • certainly a lot less boilerplate and less 'noise'
  • Scala feels like a very good fit for Wicket when it comes to nesting components
  • for e.g. less work / lines of code to define inner classes / constructors, so can do it mostly in-line and keep nesting without much clutter
  • and at the same time override framework methods as one-liners. nice !
  • Scala seemed to work well with Wicket Generics, compiler seemed to be a lot more stricter at times, maybe this is a good thing. NetBeans plugin helps, but still buggy and slow at times.
  • Not a very complex app, so did not get a chance to apply closures and FP much
  • There are some gotchas you need to be aware of like this: Fighting Scala – Scala to Java List Conversion - for the time being I managed using Java collections for domain object properties.

Haven't run a performance test / comparison yet. Stay tuned :) Do let me know if there's anything you want to know when I get around to posting a detailed blog entry on this. Oh and if you get a chance to look through the code and let me know what can be improved, that would be great !

I haven't looked at Lift yet but here's a blog post that may help the OP: Lift from a Wicket Developer's Perspective

Have to say that I would choose Scala over Groovy by a mile if mixing with Wicket. The "organize imports" IDE feature itself settles the question. The new Groovy inner class support has some gotchas that seriously get in the way when using Wicket. Also experienced some problems like groovy.lang.Reference not Serializable etc.

Peter Thomas
Dude you use the Scala Wicket extension project? http://www.mail-archive.com/[email protected]/msg40899.html ?
Antony Stubbs
+2  A: 

They work really well together. Not to mention all the bonuses of using Scala as your language.

Along my way I took out bits I made that I found useful and created the Scala Wicket Extensions stuff project: http://www.mail-archive.com/[email protected]/msg40899.html Haven't used it for a while, but it should still be good. I'd be really keen to get more people contributing to the project.

The repo is here: https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicketstuff-core/scala-extensions-parent/

It's a shame wicket-stuff (and wicket) is/are not in Github :/

Antony Stubbs