4. some facts
Standard GET/POST support
AJAX and JSON forms support
No HTML form tags needed
Implement as snippet in Scala
Form generated by net.liftweb.http.SHtml
Stateless by default
Extend StatefulSnippet
Use RequestVars for statefull purpose
8. text area - password inputs
Mostly like standard HTML input elements
Generated by Shtml
Overload XML with Pair(String, String)
“attribute” → ”value”
14. (multi) selection
selection
List of options as Pair(value, display)
Only one item may be selected
multiselection
Multiple select or pre-select
Callback function proceeds for every returned value
selectObj
Handles passed objects as Pair(object, display)
15. file upload 1/2
Special case of form submission
SHtml generates file upload
element with callback
File is typed as FileParamHolder
refenced by SHtml
Whole file is loaded into
memory on complete
18. site map - facts
Provides a map for your site
Not only links and basic menu functionality
Nested menus with hierarchies
Grouping menus
Access control mechanism
Request URL rewriting
State-dependent computations for page titles,
page-specific snippets, etc.
20. Basic sitemap 2/2
Creating menu entries with unique Loc
reference
Allow access to any pages with help of
match
Nested menu holds one or more child
menus
21. customize display of menu
Hide menu entries to restrict access
Control menu item text
Render menu title
Customize menu with help of CSS
Add JavaScript functionality
Build menu groups
22. access control
Extending binary control of given request
"matches→display" otherwise don't display
If LocParam
Test Function evaluates given path
Message Function returns failure response
string
User redirected to page with display for error
state
Unless LocParam
Mirrors Test Function of If LocParam
24. The mapper and record
frameworks
- Making things persistent -
25. What is persistence?
“Persistence in computer science refers to the
characteristic of data that outlives the execution
of the program that created it. Without this
capability, data would only exist in RAM, and
would be lost when this RAM loses power, such as
on computer shutdown. This is achieved in
practice by storing the data in non-volatile
storage such as a hard drive or flash memory.
”
Wikipedia
27. record vs. mapper
Mapper is original Lift persistence
framework
Closely tied to JDBC
Record is new refactorization of Mapper
Define own Mapping Strategies (XML, JDBC,
JPA)
Mapper will be deprecated as soon as
Records is stable
Mapper will be used in this presentation
28. Get connected
Extend
net.liftweb.mapper.ConnectionManager
trait
Implement methods: newConnection and
releaseConnection
29. Dbvendor extends connectionManager
name parameter
used to have
multiple databases
newConnection
needs to return a
Box[java.sql.Connecti
on]
releaseConnection
used to have
complete control of
the connection
lifecycle
Declare object in
Boot.scala
Call the
DB.defineConnection
Manager to bind
Manager into the
Mapper
30. make my class persistent
Class Transaction from the PocketChange application
We want to store:
Date
Description with a max length of 100 chars
Amount of money used in a transaction
And a account we want to reference to (described in detail
later)
31. What have I typed here?
Use LongKeyedMapper trait:
Provide primary key for our entity
Key should be long
IdPK trait implements getPrimaryKeyField-method
Defined as object due to MetaMapper, who needs access for
validation
getSingleton defines the MetaObject
32. how to set fields?
Fields are no instance members:
Use apply method to set:
Use is to get:
38. how to query data
findAll returns all instances
Use flag to define criterias to limit search
result (trait QueryParam)
By is used for direct value comparison
BySQL let us use plain SQL as where clause
41. from mapping to html
asHTML is rendering the mapper instance
„as HTML“.
Overriding for own behaviour
eg own date format
42. from mapping to a form
toForm is making it easy to create a form
appropriate to an instance
Third method has a „redo“ snippet parameter
to save status
User do not have to re-enter everything
43. from form to validation
Validate submitted data
User is not allowed to enter dates in the future
Link function to validation
45. Doing it oldschool - sql 1/2
findAllByPreparedStatement
findAllByInsecureSql
Executes the String you submit directly without
any checks
46. Doing it oldschool - sql 2/2
DB.runQuery provides support for non-
entity SQL queries
47. Protouser
ProtoUser trait defines some basic fields for
a user (email, firstName, lastName,
password and superUser)
Already some defs used to format the
fields for display or to provide form labels
48. megaprotouser
Extends the ProtoUser trait
Automatically handle all of the scaffolding
for a complete user management system
User registration page
Login page
Lost password page
Change password page
User edit page
Simple method to generate SiteMap
50. conclusion
Concepts are pretty nice
Getting things done very quick out of box
Scala as scripting language makes it mighty
Would have been better to do presentations
AFTER project
Pretty hard to „give control“ to the framework
(„What is happening in the background?“)
Lift book is bad.
We would still prefer (G)Rails due to better
tooling and experience
51. Disclaimer
All images in this presentation are downloaded from flickr.com and marked with the creativecommons licence for
commercial use.
This presentation is restricted with the creativecommons licence (http://creativecommons.org/licenses/by-
nd/3.0/de/deed.en):