0
Introducing Lift Web Framework       Rishi Khandelwal       Software Consultant       Knoldus Software LLP       Email : r...
Introduction    Lift is a free web application framework.    It was originally created by David Pollack    It provides ...
Design goalsSECURITY : Whenever you make an AJAX call, use Comet, or even build a           simple form, Lift replaces inp...
View-first design    Lift’s view-first approach does the complete opposite of MVC pattern    It first chooses the view a...
Continued...View :     It refers primarily to the HTML content served for a page request.           Within any given Lift ...
Lift Sub-projectsLift is broken down into three top-level subprojects:Lift Core and Lift Web, Lift Persistence, and Lift M...
Continued...  Lift Web             Wizard                     TestKit                          Webkit Lift Core           ...
Continued...LIFT COMMON :    It contains a few base classes that are common to everything else within    Lift.   Probabl...
Continued...LIFT UTILITIES :    Lift Utilities is a collection of classes, traits, and objects that are designed to    sa...
2. Lift Persistence :    It is some kind of backend storage.    It provides you with a number of options for saving your...
Continued...eg. User.find(By(User.email, "foo@bar.com"))    User.find(By(User.birthday, new Date("Jan 4, 1975")))LIFT JPA ...
Continued...Record is a layer that gives users create, read, update, and delete (CRUD)  semantics and a set of helpers for...
Project structureprojectsrc main  scala     bootstrap       liftweb         Boot.scala     code      comet      lib      m...
Boot.scalaclass Boot { def boot {   // where to search snippet   LiftRules.addToPackages("code")  // Build SiteMap  val en...
Continued... // Make the spinny image go away when it ends    LiftRules.ajaxEnd =     Full(() => LiftRules.jsArtifacts.hid...
Index.html<div id="main" class="lift:surround?with=default;at=content">    <form class="lift:Process?form=post">          ...
Process.scalaobject Process { var name = "" var age = "0" def render = {     // define some variables to put our values in...
Continued...// process the form  private def process() =   asInt(age) match {     case Full(a) if a < 13 => S.error("Too y...
Intro lift
Upcoming SlideShare
Loading in...5
×

Intro lift

2,467

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,467
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • &quot;net.liftmodules&quot; %% &quot;widgets&quot; % (liftVersion+&quot;-1.2&quot;) % &quot;compile-&gt;default&quot;,
  • Transcript of "Intro lift"

    1. 1. Introducing Lift Web Framework Rishi Khandelwal Software Consultant Knoldus Software LLP Email : rishi@knoldus.com
    2. 2. Introduction Lift is a free web application framework. It was originally created by David Pollack It provides web application developers tools to make writing security, interacting, scalable web applications easier Lift uses Scala as programming language. It does not use MVC pattern. It uses View first approach.
    3. 3. Design goalsSECURITY : Whenever you make an AJAX call, use Comet, or even build a simple form, Lift replaces input names and URLs with opaque GUIDs that reference specific functions on the server.CONCISENESS : As Lift uses Scala as a programming laguage, and scalas code is very concise. So Lift has this propertyPERFORMANCE : It is very quick. Using the basic Lift project, you can expect upward of 300 requests per second on a machine with only 1 GB of RAM and a middle-of-the-road processor.
    4. 4. View-first design Lift’s view-first approach does the complete opposite of MVC pattern It first chooses the view and then determines what dynamic content needs to be included on that page. The three component parts are view, snippet, and model—VSM for short Execute command Apply / commit Snippet Change Notification Error notices View Model.
    5. 5. Continued...View : It refers primarily to the HTML content served for a page request. Within any given Lift application, you can have two types of view: 1. Template views that bind dynamic content into a predefined markup template 2. Generated views in which dynamic content is created, typically with Scala XML literalsSnippet : Snippets are rendering functions that take XML input from within a given page template and then transform that input based upon the logic within the snippet function.Model : For most applications, it will represent a model of persistence or Data. You ask the model for value x, and it returns it.
    6. 6. Lift Sub-projectsLift is broken down into three top-level subprojects:Lift Core and Lift Web, Lift Persistence, and Lift Modules.1.. Lift Core and Lift Web : The Core consists of four projects that build to separate libraries that you can use both with and without Lift’s Web module. The Web module itself builds upon the Core. The Web module itself is made up of three projects: the base web systems and two additional projects that provide specialized helpers.
    7. 7. Continued... Lift Web Wizard TestKit Webkit Lift Core Utilities JSON Actor Common
    8. 8. Continued...LIFT COMMON : It contains a few base classes that are common to everything else within Lift. Probably most important of all, Lift Common can be used in projectsthat aren’t even web applications.LIFT ACTOR : Actors are a model for concurrent programming whereby asynchronous messaging is used in place of directly working with threads and locks. Lift has its own for the specific domain of web development. Lift Actor provides concrete implementations of the base actor traits that are found within Lift Common
    9. 9. Continued...LIFT UTILITIES : Lift Utilities is a collection of classes, traits, and objects that are designed to save you time or provide convenience mechanisms for dealing with common paradigms.LIFT JSON : Lift JSON provides an almost standalone package for handling JSON in highly performant way. The parser included within Lift JSON is approximately 350 times faster than the JSON parser that’s included in the Scala standard libraryLIFT WEBKIT : The WebKit module is where Lift holds its entire pipeline, from request processing right down to localization and template rendering.
    10. 10. 2. Lift Persistence : It is some kind of backend storage. It provides you with a number of options for saving your data,whether it’s a relational database management system (RDBMS) or one of the new NoSQL solutions. There are three foundations for persistence :LIFT DB AND MAPPER : It provides communication with an RDBMS of some description, Mapper provides you with an object-relational mapping (ORM) implementation that handles all the usual relationship tasks
    11. 11. Continued...eg. User.find(By(User.email, "foo@bar.com")) User.find(By(User.birthday, new Date("Jan 4, 1975")))LIFT JPA : It is Java Persistence API. This module was added to Lift’s persistence options to wrap the JPA API and give it a more idiomatic Scala feelLIFT RECORD : Record was designed with the idea that persistence has common idioms no matter what the actual backend implementation was doing to interact with the data.
    12. 12. Continued...Record is a layer that gives users create, read, update, and delete (CRUD) semantics and a set of helpers for displaying form fields, operating validation, and so forth.Record has 3 backend implementation modules as part of the framework:1. NoSQL document-orientated storage system CouchDB2. second for the NoSQL data store MongoDB3.layer on top of Squeryl ,the highly sophisticated functional persistence library.3. Lift Modules :Lift Modules is where the project houses all the extensions to the core framework.Unlike the other groups of subprojects within Lift, the modules are more organic and have little or no relation to one another.Each module is generally self-contained regarding the functionality it provides.
    13. 13. Project structureprojectsrc main scala bootstrap liftweb Boot.scala code comet lib model snippet view resources webapp WEB-INF/web.xml css images templates-hidden index.html test
    14. 14. Boot.scalaclass Boot { def boot { // where to search snippet LiftRules.addToPackages("code") // Build SiteMap val entries = List( Menu.i("Home") / "index", // the simple way to declare a menu // more complex because this menu allows anything in the // /static path to be visible Menu(Loc("Static", Link(List("static"), true, "/static/index"), "Static Content"))) // set the sitemap. Note if you dont want access control for // each page, just comment this line out. LiftRules.setSiteMap(SiteMap(entries:_*)) //Show the spinny image when an Ajax call starts LiftRules.ajaxStart = Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
    15. 15. Continued... // Make the spinny image go away when it ends LiftRules.ajaxEnd = Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd) // Force the request to be UTF-8 LiftRules.early.append(_.setCharacterEncoding("UTF-8")) // Use HTML5 for rendering LiftRules.htmlProperties.default.set((r: Req) => new Html5Properties(r.userAgent)) //Init the jQuery module, see http://liftweb.net/jquery for more information. LiftRules.jsArtifacts = JQueryArtifacts JQueryModule.InitParam.JQuery=JQueryModule.JQuery172 JQueryModule.init() } }
    16. 16. Index.html<div id="main" class="lift:surround?with=default;at=content"> <form class="lift:Process?form=post"> Name: <input id="name"><br> Age: <input id="age" value="0"><br> <input type="submit" value="Submit" id="submit"> </form></div>default.html<span class="lift:Menu.builder"></span><div class="lift:Msgs?showAll=true"></div><div class="column span-17 last"> <div id="content">The main content will get bound here</div></div>
    17. 17. Process.scalaobject Process { var name = "" var age = "0" def render = { // define some variables to put our values into "#name" #> SHtml.text(name, name = _) & // set the name // set the age variable if we can convert to an Int "#age" #> SHtml.text(age, age = _) & // when the form is submitted, process the variable "#submit" #> SHtml.onSubmitUnit(process) }
    18. 18. Continued...// process the form private def process() = asInt(age) match { case Full(a) if a < 13 => S.error("Too young!") case Full(a) => { S.notice("Name: " + name) S.notice("Age: " + a) } case _ => S.error("Age doesnt parse as a number") }}
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×