You are previewing Lift Cookbook.
O'Reilly logo
Lift Cookbook

Book Description

If you need help building web applications with the Lift framework, this cookbook provides scores of concise, ready-to-use code solutions. You’ll find recipes for everything from setting up a coding environment to creating REST web services and deploying your application to production.

Table of Contents

  1. Lift Cookbook
  2. Preface
    1. Contributors
    2. Source
    3. Updates
    4. Software Versions
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    8. How to Contact Us
    9. Acknowledgments
  3. 1. Installing and Running Lift
    1. Downloading and Running Lift
      1. Problem
      2. Solution
        1. For Mac and Linux
        2. For Windows
        3. Expected result
      3. Discussion
        1. Simple Build Tool
        2. Running your application
        3. Source code
      4. See Also
    2. Creating a Lift Project from Scratch Using SBT
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. Developing Using a Text Editor
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Incorporating JRebel
      1. Problem
      2. Solutions
      3. Discussion
        1. Purchased licenses
      4. See Also
    5. Developing Using Eclipse
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Developing Using IntelliJ IDEA
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Viewing the lift_proto H2 Database
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Using the Latest Lift Build
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Using a New Version of Scala
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  4. 2. HTML
    1. Testing and Debugging CSS Selectors
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Sequencing CSS Selector Operations
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. Setting Meta Tag Contents
      1. Problem
      2. Solution
      3. Discussion
        1. Appending to a class attribute
      4. See Also
    4. Setting the Page Title
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. HTML Conditional Comments
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Returning Snippet Markup Unchanged
      1. Problem
      2. Solution
      3. Discussion
    7. Snippet Not Found When Using HTML5
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Avoiding CSS and JavaScript Caching
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Adding to the Head of a Page
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    10. Custom 404 Page
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    11. Other Custom Status Pages
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    12. Links in Notices
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    13. Link to Download Data
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    14. Test on a Req
      1. Problem
      2. Solution
      3. Discussion
        1. Data table
      4. See Also
    15. Rendering Textile Markup
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  5. 3. Forms Processing in Lift
    1. Plain Old Form Processing
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Ajax Form Processing
      1. Problem
      2. Solution
      3. Discussion
        1. Submit styling
      4. See Also
    3. Ajax JSON Form Processing
      1. Problem
      2. Solution
      3. Discussion
        1. Additional commands
      4. See Also
    4. Use a Date Picker for Input
      1. Problem
      2. Solution
      3. Discussion
        1. HTML5 date pickers
      4. See Also
    5. Making Suggestions with Autocomplete
      1. Problem
      2. Solution
      3. Discussion
        1. Submitting new values
        2. Alternative autocomplete JavaScript
      4. See Also
    6. Offering Choices with Radio Buttons
      1. Problem
      2. Solution
      3. Discussion
        1. Customising the HTML
        2. String values
    7. Conditionally Disable a Checkbox
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Use a Select Box with Multiple Options
      1. Problem
      2. Solution
      3. Discussion
        1. Selecting no options
        2. Type-safe options
        3. Enumerations
      4. See Also
    9. File Upload
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  6. 4. REST
    1. DRY URLs
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Missing File Suffix
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. Missing .com from Email Addresses
      1. Solution
      2. Discussion
      3. See Also
    4. Failing to Match on a File Suffix
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Accept Binary Data in a REST Service
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Returning JSON
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Google Sitemap
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Calling REST Service from a Native iOS Application
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  7. 5. JavaScript, Ajax, and Comet
    1. Trigger Server-Side Code from a Button
      1. Problem
      2. Solution
      3. Discussion
        1. onEvent: receiving the value of a DOM element
        2. ajaxCall: receiving an arbitrary client-side string
        3. jsonCall: receiving a JSON value
      4. See Also
    2. Call Server When Select Option Changes
      1. Problem
      2. Solution
      3. Discussion
        1. Collecting the value on form submission
      4. See Also
    3. Creating Client-Side Actions in Your Scala Code
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Focus on a Field on Page Load
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Add a CSS Class to an Ajax Form
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Running a Template via JavaScript
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Move JavaScript to End of Page
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Run JavaScript on Comet Session Loss
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Ajax File Upload
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    10. Format a Wired Cell
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  8. 6. Request Pipeline
    1. Debugging a Request
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Running Code When Sessions Are Created (or Destroyed)
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. Run Code When Lift Shuts Down
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Running Stateless
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Catch Any Exception
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Streaming Content
      1. Problem
      2. Solution
      3. Discussion
        1. InMemoryResponse
        2. StreamingResponse
      4. See Also
    7. Serving a File with Access Control
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Access Restriction by HTTP Header
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Accessing HttpServletRequest
      1. Problem
      2. Solution
      3. Discussion
    10. Force HTTPS Requests
      1. Problem
      2. Solution
      3. Discussion
        1. Amazon Load Balancer
  9. 7. Relational Database Persistence with Record and Squeryl
    1. Configuring Squeryl and Record
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Using a JNDI DataSource
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. One-to-Many Relationship
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Many-to-Many Relationship
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Adding Validation to a Field
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Custom Validation Logic
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Modify a Field Value Before It Is Set
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Testing with Specs
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Store a Random Value in a Column
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    10. Automatic Created and Updated Timestamps
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    11. Logging SQL
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    12. Model a Column with MySQL MEDIUMTEXT
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    13. MySQL Character Set Encoding
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  10. 8. MongoDB Persistence with Record
    1. Connecting to a MongoDB Database
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Storing a Hash Map in a MongoDB Record
      1. Problem
      2. Solution
      3. Discussion
        1. What a MongoMapField can contain
      4. See Also
    3. Storing an Enumeration in MongoDB
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Embedding a Document Inside a MongoDB Record
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Linking Between MongoDB Records
      1. Problem
      2. Solution
      3. Discussion
        1. Querying by reference
        2. Updating and deleting
        3. Types of link
      4. See Also
    6. Using Rogue
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Storing Geospatial Values
      1. Problem
      2. Solution
      3. Discussion
        1. Querying
      4. See Also
    8. Running Queries from the Scala Console
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    9. Unit Testing Record with MongoDB
      1. Problem
      2. Solution
      3. Discussion
        1. Database cleanup
        2. Parallel tests
        3. Running tests in IDEs
      4. See Also
  11. 9. Around Lift
    1. Sending Plain-Text Email
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. Logging Email Rather than Sending
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. SMTP Authentication
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Sending Authenticated Email
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. Sending Email with Attachments
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    6. Run a Task Later
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    7. Run Tasks Periodically
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    8. Fetching URLs
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  12. 10. Production Deployment
    1. Deploying to CloudBees
      1. Problem
      2. Solution
      3. Discussion
        1. RDBMS configuration
        2. Host IP and port number
        3. Java version
        4. Container version
        5. ClickStarts
      4. See Also
    2. Deploying to Amazon Elastic Beanstalk
      1. Problem
      2. Solution
      3. Discussion
        1. Multiple instances
        2. Working with a database
      4. See Also
    3. Deploying to Heroku
      1. Problem
      2. Solution
      3. Discussion
        1. Database access in Heroku
      4. See Also
    4. Distributing Comet Across Multiple Servers
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
  13. 11. Contributing, Bug Reports, and Getting Help
    1. You’d Like Some Help
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    2. How to Report Bugs
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    3. Contributing Small Code Changes and ScalaDoc
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    4. Contributing Documentation
      1. Problem
      2. Solution
      3. Discussion
      4. See Also
    5. How to Add a New Recipe to This Cookbook
      1. Problem
      2. Solution
      3. Discussion
        1. Licensing
      4. See Also
    6. Sharing Code in Modules
      1. Problem
      2. Solution
      3. Discussion
        1. Making your module available
        2. Debugging your module
      4. See Also
  14. Index
  15. About the Author
  16. Colophon
  17. Copyright