diff --git a/chap-lift_components.lyx b/chap-lift_components.lyx index 10b6bdc..b3ffb76 100644 --- a/chap-lift_components.lyx +++ b/chap-lift_components.lyx @@ -77,18 +77,6 @@ Chapter: Components: Plan, Draft, Revise, Edit, Format, Happy \end_layout -\begin_layout Standard -My Notes, since I don't know this yet.: -\end_layout - -\begin_layout Standard -Templates contain snippets -\end_layout - -\begin_layout Standard -Snippets come in various types -\end_layout - \begin_layout Standard Lift uses a combination of technologies to get the XHTML to the user. We'll discuss these methods in this chapter. @@ -99,8 +87,12 @@ In LiftSession._defaultLiftTagProcessing \end_layout \begin_layout Standard -Partials are fun! http://creativekarma.com/ee.php/weblog/comments/scala_function_o -bjects_from_a_java_perspective/ +Partials are fun! +\end_layout + +\begin_layout Standard +http://creativekarma.com/ee.php/weblog/comments/scala_function_objects_from_a_java +_perspective/ \end_layout \begin_layout Standard @@ -355,7 +347,7 @@ surround Example: \family typewriter \emph default - children + children \end_layout \begin_layout Standard @@ -463,18 +455,41 @@ This: \begin_layout Standard \begin_inset listings +lstparams "basicstyle={\footnotesize},language=Java,numbers=left,numberstyle={\tiny}" inline false status open \begin_layout Standard -
+\begin_inset Caption + +\begin_layout Standard +Comet Html template +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +
+\end_layout + +\begin_layout Standard + + Current Time: +\end_layout + +\begin_layout Standard + + Missing Clock \end_layout \begin_layout Standard -Current Time: Missing Clock + \end_layout \begin_layout Standard @@ -493,11 +508,25 @@ Will turn into this after processing: \begin_layout Standard \begin_inset listings +lstparams "basicstyle={\footnotesize},numbers=left,numberstyle={\tiny}" inline false status open \begin_layout Standard +\begin_inset Caption + +\begin_layout Standard +Comet as rendered in the browser +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +
\end_layout @@ -508,8 +537,18 @@ status open \begin_layout Standard -Current Time: Fri Nov 14 17:29:53 EST 2008 + +\end_layout + +\begin_layout Standard + + Current Time: +\end_layout + +\begin_layout Standard + + Fri Nov 14 17:29:53 EST 2008 + \end_layout \begin_layout Standard @@ -524,8 +563,23 @@ status open \begin_layout Standard -function F1226701773224999000_BBP(obj) {lift_ajaxHandler('F1226701773224999000_B -BP='+ encodeURIComponent(JSON.stringify(obj)), null,null);} +function F1226701773224999000_BBP(obj) { +\end_layout + +\begin_layout Standard + + lift_ajaxHandler('F1226701773224999000_BBP='+ encodeURIComponent(JSON.stringify +(obj)), +\end_layout + +\begin_layout Standard + + null, null); +\end_layout + +\begin_layout Standard + +} \end_layout \begin_layout Standard @@ -609,129 +663,203 @@ Example: \end_layout \begin_layout Standard -form and multipart are optional. +The +\family typewriter +form +\family default + and +\family typewriter +multipart +\family default + attributes are optional. + If +\family typewriter +form +\family default + is included the attribute options are +\family typewriter +GET +\family default + and +\family typewriter +POST. + +\family default + The +\family typewriter +type +\family default + attribute resolves to the method call +\family typewriter +ClassName.method +\family default +. + The +\family typewriter +multipart +\family default + attribute is a boolean. \end_layout \begin_layout Standard -form types are GET | POST +Demo example: \end_layout \begin_layout Standard -type resolves to the method call ClassName.method +\begin_inset listings +lstparams "basicstyle={\footnotesize},numbers=left,numberstyle={\tiny}" +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard +Snippet that generates a NodeSeq +\end_layout + +\end_inset + + \end_layout \begin_layout Standard -multipart is a boolean + +def add(xhtml: Group): NodeSeq = \end_layout \begin_layout Standard -Demo example: + + selectedUser.is.openOr(new User).toForm(Empty, saveUser _) ++ \end_layout \begin_layout Standard -Caveats: + + \end_layout \begin_layout Standard -More in section -\begin_inset LatexCommand ref -reference "sec:Snippets" -\end_inset + Cancel +\end_layout +\begin_layout Standard + \end_layout -\begin_layout Section +\begin_layout Standard -\series bold -Snippets -\begin_inset LatexCommand label -name "sec:Snippets" + +\end_layout + +\begin_layout Standard + +\end_layout \end_inset \end_layout -\begin_layout Itemize -Chunks of code that generate pieces of a final output page. - May themselves generate template code that is interpreted -\end_layout +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize},numbers=left,numberstyle={\tiny}" +inline false +status open -\begin_layout Itemize -Generic Scala classes (stateless) -\end_layout +\begin_layout Standard -\begin_layout Itemize -How to deal with state in snippets -\end_layout +\begin_inset Caption -\begin_layout Itemize -RequestVars +\begin_layout Standard +Snippet the generates Nodes to bind... + TODO: Explain the difference better... \end_layout -\begin_layout Itemize -SessionVars +\end_inset + + \end_layout -\begin_layout Itemize -StatefulSnippet +\begin_layout Standard + +def render(in: NodeSeq): NodeSeq = { \end_layout -\begin_deeper -\begin_layout Itemize -extends DispatchSnippet +\begin_layout Standard + + val attr: String = S.attr("name").openOr("N/A") \end_layout -\begin_layout Itemize -register and unregister SnippetForClass +\begin_layout Standard + + val value = CountHolder.is(attr) \end_layout -\begin_layout Itemize -Register the name of the class for the snippet, +\begin_layout Standard + + bind("count", in, "value" -> value, \end_layout -\begin_layout Itemize -Point is to maintain state across requests +\begin_layout Standard + + "incr" -> link("/count", () => CountHolder.is(attr) = value + 1, Text("++")), + \end_layout -\begin_layout Itemize -Example to illustrate the idea, the guess a number game +\begin_layout Standard + + "decr" -> link("/count", () => CountHolder.is(attr) = 0 max (value - + 1), Text("--"))) \end_layout -\end_deeper -\begin_layout Itemize -Snippet +\begin_layout Standard + +} \end_layout -\begin_deeper -\begin_layout Itemize -type DispatchIt = PartialFunction[String, NodeSeq => NodeSeq] +\end_inset + + \end_layout -\begin_layout Itemize -def dispatch: DispatchIt +\begin_layout Standard +Caveats: \end_layout -\end_deeper -\begin_layout Itemize -Using Helpers.bind. - In particular, cover view vs. - forms usage +\begin_layout Standard +More in section +\begin_inset LatexCommand ref +reference "sec:Snippets" + +\end_inset + + \end_layout -\begin_layout Itemize -Using Helpers.chooseTemplate for nested templates +\begin_layout Section + +\series bold +Snippets +\begin_inset LatexCommand label +name "sec:Snippets" + +\end_inset + + \end_layout -\begin_layout Itemize -Assert the concept of Fragment Generation +\begin_layout Standard +Snippets are the most common way of getting markup back to the user. + A Snippet is a special tag that Lift processes/does stuff with to do something + more exciting than your normal tag. + Let's take a quick look at example Snippet: \end_layout \begin_layout Standard \begin_inset listings -lstparams "basicstyle={\small},numbers=left,numberstyle={\tiny}" inline false status open @@ -740,7 +868,7 @@ status open \begin_inset Caption \begin_layout Standard -Default Template Listing +Sample Snippet in index.html \end_layout \end_inset @@ -750,93 +878,114 @@ Default Template Listing \begin_layout Standard - - + \end_layout \begin_layout Standard - +

Welcome to your project!

\end_layout \begin_layout Standard - - +

\end_layout \begin_layout Standard - + \end_layout \begin_layout Standard - + \end_layout \begin_layout Standard -demo.helloworld:helloworld:1.0-SNAPSHOT + \end_layout \begin_layout Standard - - + \end_layout \begin_layout Standard - +

\end_layout \begin_layout Standard - +
\end_layout -\begin_layout Standard +\end_inset + - \end_layout \begin_layout Standard +Notice the tag , this is a snippet and what it means + to Lift is to lookup the class +\family typewriter +helloWorld +\family default + and execute the method +\family typewriter +howdy. - +\family default + The method +\family typewriter +howdy +\family default + is defined as: \end_layout \begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize}" +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard +Sample Snippet Definition in HelloWorld.scala +\end_layout + +\end_inset + - \end_layout \begin_layout Standard - +package org.test.snippet \end_layout \begin_layout Standard - \end_layout \begin_layout Standard - +class HelloWorld { \end_layout \begin_layout Standard - + def howdy = Welcome to Your Super Rad Site at {new java.util.Date} + \end_layout \begin_layout Standard - +} \end_layout \end_inset @@ -844,94 +993,92 @@ Default Template Listing \end_layout -\begin_layout Section -Built-in Snippets +\begin_layout Standard +So what's happening is when Lift is processing the XML contained in index.html + it will notice the special Lift snippet tag, execute the method and replace + the tag with the XML generated. + There's the sequence of transformations: \end_layout \begin_layout Standard -There are a few built-in snippets that offer some standards functionality, - such as messages and menus. - We'll go over them here and they'll serve as a nice introduction into Snippets - in general. - These builtin Snippets can be overridden by your own code or omitted if - you like. - The reason they exist is that most web apps are going to need to offer - these features anyway.a +The template contains: \end_layout -\begin_layout Subsection -CSS.scala -\end_layout +\begin_layout Standard +\begin_inset listings +inline false +status open \begin_layout Standard -The CSS snippet currently provides a simple way to in the Blueprint CSS - framework. - Please see the -\begin_inset LatexCommand htmlurl -name "BlueprintCSS homepage" -target "http://www.blueprintcss.org/" + +

+\end_layout \end_inset - for more details. -\end_layout -\begin_layout LyX-Code -Usage: \end_layout -\begin_layout Subsection -Menu.scala +\begin_layout Standard +The method definition is: \end_layout \begin_layout Standard -Reference 1.6, general builder stuff here. - It's all different now. -\end_layout +\begin_inset listings +inline false +status open -\begin_layout LyX-Code -Usage: +\begin_layout Standard + +

Welcome to Your Super Rad Site at {new java.util.Date}

\end_layout -\begin_layout Subsection -Msg.scala +\end_inset + + \end_layout \begin_layout Standard -A snippet for rendering messages close to other elements, for example validation - errors on a submission form. +And the final XML sent back to the browser will be: \end_layout -\begin_layout LyX-Code -Usage: +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize}" +inline false +status open + +\begin_layout Standard + +

Welcome toYour Super Rad Site at Tue Nov 18 10:40:55 EST 2008

\end_layout -\begin_layout Subsection -Msgs.scala +\end_inset + + \end_layout \begin_layout Standard -Default snippet for displaying messages generated from S.error, S.warning - and S.notice. +Using Snippets and bind you can generate XML in a different way. \end_layout -\begin_layout LyX-Code -Usage: +\begin_layout Standard +The html template would look like this: \end_layout -\begin_layout Section - -\series bold -SiteMap -\begin_inset Note Note +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize}" +inline false status open \begin_layout Standard -\series bold -Is Derek handling this? +\begin_inset Caption + +\begin_layout Standard +Alternate Snippet Definition \end_layout \end_inset @@ -939,230 +1086,1019 @@ Is Derek handling this? \end_layout -\begin_layout Itemize -http://groups.google.com/group/liftweb/browse_thread/thread/6c1cd13c3f2f7178?hl=en -# -\end_layout +\begin_layout Standard -\begin_deeper -\begin_layout Itemize -dpp redid this whole thing recently. + \end_layout -\end_deeper -\begin_layout Itemize -Performs two primary duties: generates the menu for your site (customizable) - and performs per-page access control -\end_layout +\begin_layout Standard -\begin_layout Itemize -Cover Menu, Loc objects to define paths and superpaths (my term for paths - that match anything under them) + \end_layout -\begin_layout Itemize -Support for grouping via LocGroup object +\begin_layout Standard + + City \end_layout -\begin_layout Itemize +\begin_layout Standard -\series bold - snippets: + Country \end_layout -\begin_deeper -\begin_layout Itemize -content (http://groups.google.com/group/liftweb/browse -_thread/thread/5f18df13cd735c51?hl=en#) -\end_layout +\begin_layout Standard -\begin_layout Itemize -binding to +   + \end_layout -\begin_layout Itemize -Loc("...",) (http://groups.google.com/group/liftweb/browse_thread/thread/dbdf6a17b970 -4c99/30f5168e87161f74?hl=en&lnk=gst&q=new+sitemap%2Fmenu+features) -\end_layout +\begin_layout Standard -\begin_layout Itemize -Customizing content and attributes on menus + \end_layout -\end_deeper -\begin_layout Itemize +\begin_layout Standard -\series bold -Additional attributes + \end_layout -\begin_deeper -\begin_layout Itemize -If -\end_layout +\end_inset + -\begin_layout Itemize -Unless \end_layout -\begin_layout Itemize -Test +\begin_layout Standard +And the method definition would be: \end_layout -\begin_layout Itemize -Title +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize}" +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard +Alternate Snippet Method Definition \end_layout -\begin_layout Itemize -Finding the current Loc for a page (RequestState.location) +\end_inset + + \end_layout -\end_deeper -\begin_layout Section +\begin_layout Standard -\series bold -Views +package org.test.snippet \end_layout \begin_layout Standard -As discussed a template is a page that is built with both a static component - and a dynamic component. - Lift offers the option to generate a page entirely from scala code. - This is accomplished by using a LiftView. - + \end_layout \begin_layout Standard -There are two types of views, InsecureLiftView and LiftView. + +class HelloWorld { \end_layout \begin_layout Standard -With an InsecureLiftView if you have a URI such as /foo/bar, Lift will look - for the class foo and execute the method bar. - This is discouraged as a malicious user could simply type /foo/deleteWorld - and if that method exists it will be executed. + + def myForm(xhtml: Group) = { \end_layout \begin_layout Standard -The recommended method is to use LiftView instead. - LiftView has all the same security measures as Snippets in that you must - build a dispatch list and define that if the user hits /foo/index, that - is mapped to Foo.render. - You get control over what method is executed when. + + var city = "" \end_layout -\begin_layout Quotation -Why should you use a View instead of a Template? Building an RSS or Atom - feed. - Building a pure XML response. +\begin_layout Standard + + var country = "" \end_layout -\begin_layout Itemize -Chunks of code intended to generate a complete page +\begin_layout Standard + + \end_layout -\begin_layout Itemize -Can be shoehorned to process template code via processSurroundAndInclude - +\begin_layout Standard + + Helpers.bind("sampleBind", xhtml, \end_layout -\begin_layout Itemize -Re-cover how views are located/dispatched +\begin_layout Standard + + "city" -> SHtml.text(name, name = _), \end_layout -\begin_layout Itemize -Path-based (/my/view) +\begin_layout Standard + + "country" -> SHtml.text(country, country = _)) \end_layout -\begin_layout Itemize -addDispatchBefore/After +\begin_layout Standard + + } \end_layout -\begin_layout Itemize -What are the use cases for snippets vs. - views? +\begin_layout Standard + + } \end_layout -\begin_layout Section -SHtml Generators +\begin_layout Standard + +} \end_layout -\begin_layout Description -ajaxButton An with onClick connected to an AjaxCall \end_layout -\begin_layout Description -a An tag with a function associated with it +\begin_layout Subsection +Stateful Snippets \end_layout -\begin_layout Description -span A with onClick connected to a JsCmd. +\begin_layout Standard +Lift also has a the concept of a stateful snippet. + All of our previous examples, while simple, were stateless. + That is to say, from request to request, there is no saved state on the + server-side. + Stateless snippets are useful in the sense that many requirements for a + web applications need no state to be \end_layout -\begin_layout Description -toggleKids +\begin_layout Subsection +Snippet Notes \end_layout -\begin_layout Description -ajaxCheckbox An +\family default + rather than +\family typewriter + +\family default +Lift will look for the method named +\family typewriter +render +\family default + in the class +\family typewriter +CSS +\family default +. +\end_layout -checkbox -\begin_inset Quotes erd -\end_inset +\begin_layout Standard +Important Functions to trace: +\end_layout -> with onClick connected to an AjaxCall +\begin_layout Standard +LiftSession processes all the tags (like snippet, comet, embed, etc) and + if it matches snippet, then it invokes LiftSession.processSnippet \end_layout -\begin_layout Description -ajaxSelect +\begin_layout Standard +LiftSession.processSnippet calls => \end_layout -\begin_layout Description -select A +, +\begin_inset Quotes eld +\end_inset + +fooMethod +\begin_inset Quotes erd +\end_inset + +) +\end_layout + +\begin_layout Standard +What is S.doSnippet all about?? +\end_layout + +\begin_layout Standard +Stateless and stateful Snippet: +\end_layout + +\begin_layout Standard +Stateless are the default type of snippet when generating pages. + The Class/Method lookup occurs within the statelessDispatchTable +\begin_inset Note Note +status open + +\begin_layout Standard +Confirm. +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +Stateful Snippets are used as a way to utilize the same snippet instance + over the same page rendering session. + This is useful for many events on the web, such as a multi-page form where + data is is needed throughout the steps or when submitting a form and you'd + like to keep the values the user has entered in the event of validation + error. + +\end_layout + +\begin_layout Standard +Stateful Snippets use +\end_layout + +\begin_layout Itemize +Chunks of code that generate pieces of a final output page. + May themselves generate template code that is interpreted +\end_layout + +\begin_layout Itemize +Generic Scala classes (stateless) +\end_layout + +\begin_layout Itemize +How to deal with state in snippets +\end_layout + +\begin_layout Itemize +RequestVars +\end_layout + +\begin_layout Itemize +SessionVars +\end_layout + +\begin_layout Itemize +StatefulSnippet +\end_layout + +\begin_deeper +\begin_layout Itemize +extends DispatchSnippet +\end_layout + +\begin_layout Itemize +register and unregister SnippetForClass +\end_layout + +\begin_layout Itemize +Register the name of the class for the snippet, +\end_layout + +\begin_layout Itemize +Point is to maintain state across requests +\end_layout + +\begin_layout Itemize +Example to illustrate the idea, the guess a number game +\end_layout + +\end_deeper +\begin_layout Itemize +Snippet +\end_layout + +\begin_deeper +\begin_layout Itemize +type DispatchIt = PartialFunction[String, NodeSeq => NodeSeq] +\end_layout + +\begin_layout Itemize +def dispatch: DispatchIt +\end_layout + +\end_deeper +\begin_layout Itemize +Using Helpers.bind. + In particular, cover view vs. + forms usage +\end_layout + +\begin_layout Itemize +Using Helpers.chooseTemplate for nested templates +\end_layout + +\begin_layout Itemize +Assert the concept of Fragment Generation +\end_layout + +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize},numbers=left,numberstyle={\tiny}" +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard +Default Template Listing +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + +demo.helloworld:helloworld:1.0-SNAPSHOT +\end_layout + +\begin_layout Standard + + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\begin_layout Standard + + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Section +Built-in Snippets +\end_layout + +\begin_layout Standard +There are a few built-in snippets that offer some standard functionality, + such as messages and menus. + We'll go over them here and they'll serve as a nice introduction into Snippets + in general. + These builtin Snippets can be overridden by your own code or omitted if + you like. + The reason they exist is that most web apps are going to need to offer + these features anyway.a +\end_layout + +\begin_layout Subsection +CSS.scala +\end_layout + +\begin_layout Standard +The CSS snippet currently provides a simple way to in the Blueprint CSS + framework. + Please see the +\begin_inset LatexCommand htmlurl +name "BlueprintCSS homepage" +target "http://www.blueprintcss.org/" + +\end_inset + + for more details. +\end_layout + +\begin_layout LyX-Code +Usage: +\end_layout + +\begin_layout Subsection +Menu.scala +\end_layout + +\begin_layout Standard +Reference 1.6, general builder stuff here. + It's all different now. +\end_layout + +\begin_layout LyX-Code +Usage: +\end_layout + +\begin_layout Subsection +Msg.scala +\end_layout + +\begin_layout Standard +A snippet for rendering messages close to other elements, for example validation + errors on a submission form. +\end_layout + +\begin_layout LyX-Code +Usage: +\end_layout + +\begin_layout LyX-Code + +\end_layout + +\begin_layout LyX-Code + +\end_layout + +\begin_layout Subsection +Msgs.scala +\end_layout + +\begin_layout Standard +Default snippet for displaying messages generated from S.error, S.warning + and S.notice. +\end_layout + +\begin_layout LyX-Code +Usage: +\end_layout + +\begin_layout Section + +\series bold +SiteMap +\begin_inset Note Note +status open + +\begin_layout Standard + +\series bold +Is Derek handling this? +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Itemize +http://groups.google.com/group/liftweb/browse_thread/thread/6c1cd13c3f2f7178?hl=en +# +\end_layout + +\begin_deeper +\begin_layout Itemize +dpp redid this whole thing recently. +\end_layout + +\end_deeper +\begin_layout Itemize +Performs two primary duties: generates the menu for your site (customizable) + and performs per-page access control +\end_layout + +\begin_layout Itemize +Cover Menu, Loc objects to define paths and superpaths (my term for paths + that match anything under them) +\end_layout + +\begin_layout Itemize +Support for grouping via LocGroup object +\end_layout + +\begin_layout Itemize + +\series bold + snippets: +\end_layout + +\begin_deeper +\begin_layout Itemize +content (http://groups.google.com/group/liftweb/browse +_thread/thread/5f18df13cd735c51?hl=en#) +\end_layout + +\begin_layout Itemize +binding to +\end_layout + +\begin_layout Itemize +Loc("...",) (http://groups.google.com/group/liftweb/browse_thread/thread/dbdf6a17b970 +4c99/30f5168e87161f74?hl=en&lnk=gst&q=new+sitemap%2Fmenu+features) +\end_layout + +\begin_layout Itemize +Customizing content and attributes on menus +\end_layout + +\end_deeper +\begin_layout Itemize + +\series bold +Additional attributes +\end_layout + +\begin_deeper +\begin_layout Itemize +If +\end_layout + +\begin_layout Itemize +Unless +\end_layout + +\begin_layout Itemize +Test +\end_layout + +\begin_layout Itemize +Title +\end_layout + +\begin_layout Itemize +Finding the current Loc for a page (RequestState.location) +\end_layout + +\end_deeper +\begin_layout Section + +\series bold +Views +\end_layout + +\begin_layout Standard +As discussed a template is a page that is built with both a static component + and a dynamic component. + Lift offers the option to generate a page entirely from scala code. + This is accomplished by using a LiftView. + +\end_layout + +\begin_layout Standard +There are two types of views, InsecureLiftView and LiftView. +\end_layout + +\begin_layout Standard +With an InsecureLiftView if you have a URI such as /foo/bar, Lift will look + for the class foo and execute the method bar. + This is discouraged as a malicious user could simply type /foo/deleteWorld + and if that method exists it will be executed. +\end_layout + +\begin_layout Standard +The recommended method is to use LiftView instead. + LiftView has all the same security measures as Snippets in that you must + build a dispatch list and define that if the user hits /foo/index, that + is mapped to Foo.render. + You get control over what method is executed when. +\end_layout + +\begin_layout Quotation +Why should you use a View instead of a Template? Building an RSS or Atom + feed. + Building a pure XML response. +\end_layout + +\begin_layout Itemize +Chunks of code intended to generate a complete page +\end_layout + +\begin_layout Itemize +Can be shoehorned to process template code via processSurroundAndInclude + +\end_layout + +\begin_layout Itemize +Re-cover how views are located/dispatched +\end_layout + +\begin_layout Itemize +Path-based (/my/view) +\end_layout + +\begin_layout Itemize +addDispatchBefore/After +\end_layout + +\begin_layout Itemize +What are the use cases for snippets vs. + views? +\end_layout + +\begin_layout Section +SHtml Generators +\end_layout + +\begin_layout Standard +def mapFunc(in: AFuncHolder): String = mapFunc( +\begin_inset Quotes eld +\end_inset + +F +\begin_inset Quotes erd +\end_inset + + + System.nanoTime + +\begin_inset Quotes eld +\end_inset + +_ +\begin_inset Quotes erd +\end_inset + + + randomString(3), in) +\end_layout + +\begin_layout Standard +def mapFunc(name: String, inf: AFuncHolder): String = { +\end_layout + +\begin_layout Standard +addFunctionMpa(name, inf) +\end_layout + +\begin_layout Standard +name +\end_layout + +\begin_layout Standard +} +\end_layout + +\begin_layout Description +swappable A swappable visual element. + +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard + +swappable example +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +def renderSwappable = { +\end_layout + +\begin_layout Standard + + swappable(Click to edit: , + +\end_layout + +\begin_layout Standard + + ajaxText("", v => DisplayMessage("messages", Text("You entered some + text: "+v), 4 seconds, 1 second) +\end_layout + +\begin_layout Standard + + & SetHtml("the_text", Text(v)))) +\end_layout + +\begin_layout Standard + +} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Description +ajaxButton An with onClick connected to an AjaxCall +\end_layout + +\begin_layout Standard +\begin_inset listings +lstparams "basicstyle={\footnotesize},language=Java,numbers=left,numberstyle={\tiny}" +inline false +status open + +\begin_layout Standard + +\begin_inset Caption + +\begin_layout Standard +ajaxButton example +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +def renderAjaxButton(in: NodeSeq): NodeSeq = SHtml.ajaxButton("Validate", + () => { +\end_layout + +\begin_layout Standard + + LoginStuff(true) +\end_layout + +\begin_layout Standard + + S.notice("Your session is validated") +\end_layout + +\begin_layout Standard + + RedirectTo("/login/index") +\end_layout + +\begin_layout Standard + +}) +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Description +a An tag with a function associated with it : {body} +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Standard + + a(() => {cnt = cnt + 1; SetHtml("cnt_id", Text( cnt.toString))}, Click + me to increase the count (currently 0)) + +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Description +span A with onClick connected to a JsCmd. + span(body, cmd) +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Standard + +{body} +\end_layout + +\end_inset + + \end_layout \begin_layout Description -ajaxText +select A +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Standard + +def renderSelect(in: NodeSeq): NodeSeq = { +\end_layout + +\begin_layout Standard + + select(List(String, String), Full(defaultValue), FunctionToDoSomething) +\end_layout + +\begin_layout Standard + +} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Description +text An +\end_layout + +\begin_layout Standard +\begin_inset listings +inline false +status open + +\begin_layout Standard + +def renderText(in: NodeSeq): NodeSeq = { +\end_layout + +\begin_layout Standard + + text("This is the default text", FunctionToDoSomething) +\end_layout + +\begin_layout Standard + +} +\end_layout + +\end_inset + + \end_layout \begin_layout Description textarea A