Skip to content
Timothy Clare edited this page Oct 3, 2011 · 1 revision

Using ZK Scala

The examples project provides some good examples of using ZK and Scala together. You can also accomplish this without the aid of the ZK Scala library. The aim of the ZK Scala lib library is to make usage of ZK more Scala-like. The ZK Scala examples project shows use cases of ZK and Scala which makes it easier for people to visualize and explore interoprability.

Before going any further the reader should understand the basics of ZK, to learn the basics please visit the following links:

  • Tutorial
  • Data-driven development
  • ZK Essentials

Having gained some more background knowledge about ZK, let's investigate the main two constructs present in ZK Scala.

The ZK Scala models

The main usage of ZK Scala boils down to the usage of Models. To explain what this is we have to look into what a model is as it relates to ZK. A model in ZK is a data structure which ZK UI objects understand. Currently, ZK Scala provides two pure scala based models:

  • ListModelList
  • BindingListModelList

Usage is as simple as doing the following:

val contributorListModel = new BindingListModelList[Contributor](myContributorList)

Where myContributorList is a Seq.

I would highly recommend reading the two source files GridAutosortingController and GridDatabindingController to understand how the ZK Scala models. The usage is incredibly simple.

The BindingListModelList is used when binding and ListModelList can be used at any other time. These two classes provide a Scala sugar coated layer on the top of ZK.

The future

There will be more models coming in the future however, ZK 6 is around the corner and with it comes numberous improvements including extensive generics, at this time there will be some design decisions to be regarding how the latest models are implemented.