Lift, Scala and ...
I'm a Liftafarian. I work for Elemica and I use Lift and Scala day and night.
-
Comet actors and Angular JS
March 26, 2013
Different ways to use Comet Actors in Lift (Part III).
AngularJS' turn
On my previous post, I showed how you could write a simple chat application using different techniques. The last technique was using knockoutjs, but recently there have been several posts on the Lift mailing list about AngularJS, and as I wanted to try it out, I thought it would be interesting to see what a chat application using angularJS would look like.
AngularJS
-
Asynchronous snippets in Lift 2.5
March 8, 2013
Asynchronous snippets in Lift 2.5
On my last post I wrote about using
LAFutureson your snippets. And one of the things I said was that the syntax I was looking for was this:val future1: LAFuture[String] = new LAFuture() def render = { "#my-slow-loading-element *" #> future1 }Well, over the last couple of nights I got to what I think is a great syntax:
-
Using LAFutures with snippets in Lift 2.x
March 5, 2013
Using LAFutures with snippets in Lift 2.x
Update
There is a better alternative now on this post
For a while I wanted to do something like this on a Lift snippet:
val future1: LAFuture[String] = new LAFuture() def render = { "#my-slow-loading-element *" #> future1 }And the idea was that the page will load right away, and once the
LAFuturehad a valid value, it would be added to the page.One way to do this kind of tasks, is to convert your snippet into a CometActor. But this isn't always what you want.
The result.

Turns out it wasn't that hard to get it working, while the syntax isn't like the examples above, I think it is still pretty clean.
A full snippet class looks like this:
-
Different ways to use Comet Actors in Lift (Part I)
March 1, 2013
Different ways to use Comet Actors in Lift (Part I).
With some bits of knockout.js
Lift has many great fundamental features, focusing on security at its core is one of them, and another one is the ability to take a feature like its comet support and integrate it with JavaScript (and any JavaScript framework you wish to use).
Background.
When I started using Lift, most of the code I wrote was in scala, but then I needed to add some dynamic magic to them, so I started adding JavaScript in different places. Sadly, I got into the habit of inlining a lot of JAvaScript in my scala code.
-
Different ways to use Comet Actors in Lift (Part II)
March 1, 2013
Different ways to use Comet Actors in Lift (Part II).
With some bits of knockout.js
Update: I have updated the source code on the github branch, and there is part III, using AngularJS.
On my previous post, I gave an introduction of my javascript adventures (kind of). This post is about re-writing the sample chat application that comes with Simply Lift using three different techniques.
Technique I
The first technique is to inline JavaScript in your scala code. I'm keeping the chap application very simple and with some bugs, because the point here is to give you a taste of the different ways you can use JavaScript with Lift
-
Lift running on Raspberry Pi
February 26, 2013
Lift and Raspberry Pi
Several months ago I blogged about controlling a servo motor with an Arduino board and a Lift application running on my computer.
That was a fun little experiment I did, but having to use my regular laptop to send the signals wasn't all that great. So I decided to try something a bit different this time.
The light.
I had successfully run a Lift application on my raspberry pi computer, so I figured to try and control the GPIO pins from the raspberry pi from a Lift application.

-
Status page in Lift
January 12, 2013
Status page for your Lift server.
For the past week I have been building a little Lift application to run on a Raspberry Pi computer. This application is supposed to control the GPIO pins that come on the Raspberry Pi.
But, as this little computer is pretty slow to boot (well, a few seconds), I thought that I should add some kind of status page that I can keep hitting from my laptop, and once I get an OK response, well, Lift is up and I can start controlling the pins.
Lift beauty
I wanted this new page to be:
- Stateless
- Should not require any html template
- Not to be included in the Sitemap
And it was super easy to add. All I had to do was add this entry to the Sitemap definition:
-
Comet Actors in Lift 2.5
January 5, 2013
Comet Actors in Lift.
One of my favorite features in Lift is Comet Actors, I love how easy they are to reason about, and they work great.
I went ahead and recorded a presentation which focuses just on comet actors. They are split into 3 videos and I hope you find them useful.
All 3 videos in a playlist:
Lift Comet Actors presentation
The slides are on Google Drive (they are all 3 parts in one file.)
Thanks
Diego
-
What is T => JsCmd or how you send data from the browser to a Lift server
December 7, 2012
How does T => JsCmd send data to Lift?
I remember my first few interactions with Lift's ajax support, which were also my first few interactions with Scala. It was pretty hard to get my head around some of the method signatures I would find all across Lift's source code.
The one that took me a while to understand was
T => JsCmd. What was hard to understand was, how that type would mean that I can pass information from the browser to the LIft server, and get back a response in the form of JavaScript.I knew it worked because I would copy/paste code samples taken from the mailing list and they worked just as advertised.
Scala bits to clear your mind.
-
How I work with Lift
November 29, 2012
How I work with Lift.
Something I enjoy very much is teaching, specially when Lift is involved. Mainly because I learn a lot by teaching others, and secondly because I have learned a lot thanks to those who spent the time to either teach me directly, or indirectly through blog posts, articles, etc.
Since I joined Elemica about 9 months ago, I have spent a good amount of time sharing what I know about Lift, Scala and web security with my team members. And today I'd like to talk about my work setup. I'll cover some simple tips about SBT and Intellij.
IDE and Build tool.
-
Lift Sitemaps - a better way
November 11, 2012
Lift Sitemap
One of the many things I have recently learned from Tim Nelson is how to better use
Sitemap.You know, most of us declare our site maps in Lift like this:
def sitemap = SiteMap( Menu.i("Home") / "index", Menu.i("About") / "about", Menu.i("user.list") / "user" / "list" >> LoggedIn, Menu.i("user.create") / "user" / "create" >> LoggedIn )To most people this looks just like any other site map they have implemented in the past. And in your snippets, if you need to link to, let's say, the user's list page, you would som something like:
SHtml.link("/user/list", () => someMethodHere(someValueHere))
-
H2 Web Consoler and Lift
September 5, 2012
H2 web console and Lift
At work we use H2 as the default database while we develop our apps. This helps because t's just easy to setup and if anything goes wrong, we just delete the file and restart our application.
All this is nice, but one thing that wasn't so smooth was accessing H2 from outside Lift, and be able to run any queries against it.
Before I joined Elemica, they were using SQuirrelSQL, which I thought was horrible, it may be a great tool, but all I wanted was connect, and run queries.
-
Textile editor and Lift
July 28, 2012
Textile and Lift
One way Lift makes developing applications fun, is by taking care of security for you. Most of the time, you don't have to worry about common hacking attacks like
XSS, this is because Lift doesn't treat your data as plain Strings, it treats them asNodeSeq. Instead of displaying html tags, it will html encode them, before returning them the browser.This happens without you having to enable anything, which is great, so you just focus on your application logic.
But not all is great, well, it is, but it takes some time to get used to. Sooner or later on your career, you are confronted with the task of giving your users access to add html content to your application.
-
Dynamically adding fields to a Lift application
July 22, 2012
Dynamically adding fields to a Lift application
A question that I see on the mailing list from time to time is how to dynamically add fields to a page.
The usual answer is that they cannot really do that, at least in a clean way, but we offer a few work arounds. One of them is to declare x number of fields, and just use jQuery to hide/show them.
This past week I had the same requirement at work. One of our Lift applications sends and email invite, and we want users to be able to add x number of reminder emails to follow up the initial invite email.
-
A distributed Lift Comet Chat Application
July 14, 2012
A distributed Lift Comet Chat Application
Lift has very powerful comet support, and 2.5 is bringing even better support. But one of the things I always wondered about was, how to have comet work across several containers.
A few months ago I had an idea of how to do this, and was planning on talking about it at OSCON, but my talk wasn't accepted. Then I decided I could just blog about it and here we are.
The problem.
On a typical chat application, you store your messages in an object, and singleton. And as messages come in, you send them to all the clients.