Using Dummy Data in Lift Templates

One of the awesome features of “view first” web frameworks like Lift and Wicket is that the page templates are stand-alone documents that are viewable without being served by the framework and don’t contain any server-side code.  This makes things much easier for web designers: they can create an XHTML template file using whatever tool they want and then you just sprinkle in some additional elements.  In a Model 2 framework (like Rails or countless others) your templates are rarely viewable right in a web browser: they’re chopped up to pieces and contain lots of logic in Ruby/PHP/Java/whatever.

In the Lift Book and most Lift code samples, the templates aren’t really useful outside of the framework because the Lift elements are all empty.  For example, consider this snippet that displays an account’s balance at a certain time:

  <ledger:balance/> as of <ledger:time/>

When this is displayed in a browser right off of the file system, you don’t really see anything meaningful:


Instead, we can put some dummy data into this template to make it display a little more realistic on its own:

  <ledger:balance>$2500.00</ledger:balance> as of <ledger:time>8 Aug 2009 11:43am</ledger:time>


Typically, a web designer will give you a file more like this one, to which you will add your own lift tags.  But your lift tags are simply ignored by the browser, so viewing the template right off your file system works fine.

If you don’t have web designers involved in your project there probably is no point in using all of this dummy data in the templates.  But if web designers are building the template files, it’s very useful to include it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s