S

olon.http.S
See theS companion object
trait S extends HasParams, Loggable, UserAgentCalculator

An object representing the current state of the HTTP request and response. It uses the DynamicVariable construct such that each thread has its own local session info without passing a huge state construct around. The S object is initialized by LiftSession on request startup.

Attributes

See also

LiftSession

LiftFilter

Companion
object
Graph
Supertypes
trait Loggable
trait HasParams
class Object
trait Matchable
class Any
Show all
Known subtypes
object S

Members list

Type members

Classlikes

object attr extends AttrHelper[Box]

Used to get an attribute by its name. There are several means to getting attributes:

Used to get an attribute by its name. There are several means to getting attributes:

 // Get a Box for the attribute: val myAttr
\= S.attr("test") openOr "Not found"

// Get an attribute or return a default value: val myAttr = S.attr("name",
"Fred")

// Apply a transform function on the attribute value, or return an Empty:
val pageSize = S.attr("count", _.toInt) openOr 20

// There are also prefixed versions: val prefixedAttr = S.attr("prefix",
"name") openOr "Not found" 

Note that this uses the data held in S.attrs, which means that it will find attributes through the entire snippet nesting stack. For example, given the snippets:

 <lift:MyStuff.snippetA foo="bar">
<lift.MyStuff.snippetB>...</lift.MyStuff.snippetB>
</lift:MyStuff.snippetA> 

Calling S.attr("foo") from snippetB will return Full("bar").

Attributes

Supertypes
trait AttrHelper[Box]
class Object
trait Matchable
class Any
Self type
attr.type
object currentAttr extends AttrHelper[Box]

Used to get an attribute by its name from the current snippet element. There are several means to getting attributes:

Used to get an attribute by its name from the current snippet element. There are several means to getting attributes:

 // Get a Box for the attribute: val myAttr
\= S.currentAttr("test") openOr "Not found"

// Get an attribute or return a default value: val myAttr =
S.currentAttr("name", "Fred")

// Apply a transform function on the attribute value, or return an Empty:
val pageSize = S.currentAttr("count", _.toInt) openOr 20

// There are also prefixed versions: val prefixedAttr =
S.currentAttr("prefix", "name") openOr "Not found" 

Note that this uses the data held in S.currentAttrs, which means that it will only find attributes from the current snippet element. For example, given the snippets:

 <lift:MyStuff.snippetA foo="bar">
<lift.MyStuff.snippetB>...</lift.MyStuff.snippetB>
</lift:MyStuff.snippetA> 

Calling S.currentAttr("foo") from snippetB will return Empty.

Attributes

Supertypes
trait AttrHelper[Box]
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def ?(str: String): String

Get a localized string or return the original string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Get a localized string or return the original string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Value parameters

str

the string to localize

Attributes

Returns

the localized version of the string

See also
def ?(str: String, locale: Locale): String

Get a localized string or return the original string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Get a localized string or return the original string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Value parameters

locale

specific locale that should be used to localize this string

str

the string to localize

Attributes

Returns

the localized version of the string

See also
def ?(str: String, params: Any*): String

Attempt to localize and then format the given string. This uses the String.format method to format the localized string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Attempt to localize and then format the given string. This uses the String.format method to format the localized string. We first try your own bundle resources, if that fails, we try Lift's core bundle.

Value parameters

params

the var-arg parameters applied for string formatting

str

the string to localize

Attributes

Returns

the localized and formatted version of the string

See also

String.format

def addAnalyzer(f: (Box[Req], Long, List[(String, Long)]) => Any): Unit

Add a query analyzer (passed queries for analysis or logging). The analyzer methods are executed with the request, total time to process the request, and the List of query log entries once the current request completes.

Add a query analyzer (passed queries for analysis or logging). The analyzer methods are executed with the request, total time to process the request, and the List of query log entries once the current request completes.

Attributes

See also
def addAround(lw: List[LoanWrapper]): Unit

You can wrap the handling of an HTTP request with your own wrapper. The wrapper can execute code before and after the request is processed (but still have S scope). This allows for query analysis, etc. See S.addAround(LoanWrapper) for an example. This version of the method takes a list of LoanWrappers that are applied in order. This method is NOT intended to change the generated HTTP request or to respond to requests early. LoanWrappers are there to set up and take down state ONLY. The LoanWrapper may be called outside the scope of an HTTP request (e.g., as part of an Actor invocation).

You can wrap the handling of an HTTP request with your own wrapper. The wrapper can execute code before and after the request is processed (but still have S scope). This allows for query analysis, etc. See S.addAround(LoanWrapper) for an example. This version of the method takes a list of LoanWrappers that are applied in order. This method is NOT intended to change the generated HTTP request or to respond to requests early. LoanWrappers are there to set up and take down state ONLY. The LoanWrapper may be called outside the scope of an HTTP request (e.g., as part of an Actor invocation).

Attributes

See also
def addAround(lw: LoanWrapper): Unit

You can wrap the handling of an HTTP request with your own wrapper. The wrapper can execute code before and after the request is processed (but still have S scope). This allows for query analysis, etc. Wrappers are chained, much like servlet filters, so you can layer processing on the request. As an example, let's look at a wrapper that opens a resource and makes it available via a RequestVar, then closes the resource when finished:

You can wrap the handling of an HTTP request with your own wrapper. The wrapper can execute code before and after the request is processed (but still have S scope). This allows for query analysis, etc. Wrappers are chained, much like servlet filters, so you can layer processing on the request. As an example, let's look at a wrapper that opens a resource and makes it available via a RequestVar, then closes the resource when finished:

 import olon.http.{ ResourceVar,S } import
olon.util.LoanWrapper

// Where "ResourceType" is defined by you object myResource extends
ResourceVar[ResourceType](...)

class Boot { def boot { ... S.addAround( new LoanWrapper { def apply[T](f:
\=> T) : T = { myResource(... code to open and return a resource instance
...) f() // This call propagates the request further down the "chain" for
template processing, etc. myResource.is.close() // Release the resource }
} ) ... } } 

This method is NOT intended to change the generated HTTP request or to respond to requests early. LoanWrappers are there to set up and take down state ONLY. The LoanWrapper may be called outside the scope of an HTTP request (e.g., as part of an Actor invocation).

Attributes

See also
def addCleanupFunc(f: () => Unit): Unit

Adds a cleanup function that will be executed at the end of the request pocessing. Exceptions thrown from these functions will be swallowed, so make sure to handle any expected exceptions within your function.

Adds a cleanup function that will be executed at the end of the request pocessing. Exceptions thrown from these functions will be swallowed, so make sure to handle any expected exceptions within your function.

Value parameters

f

The function to execute at the end of the request.

Attributes

def addComet(cometActor: LiftCometActor): Unit

Add a comet to the list of comets that should be registered to receive updates on the page currently being rendered or on the page that invoked the currently running callback.

Add a comet to the list of comets that should be registered to receive updates on the page currently being rendered or on the page that invoked the currently running callback.

Attributes

def addCookie(cookie: HTTPCookie): Unit

Adds a Cookie to the List[Cookies] that will be sent with the Response.

Adds a Cookie to the List[Cookies] that will be sent with the Response.

If you wish to delete a Cookie as part of the Response, use the deleteCookie method.

An example of adding and removing a Cookie is:

 import olon.http.provider.HTTPCookie

class MySnippet { final val cookieName = "Fred"

def cookieDemo (xhtml : NodeSeq) : NodeSeq = { var cookieVal =
S.findCookie(cookieName).map(_.getvalue) openOr ""

def setCookie() { val cookie = HTTPCookie(cookieName,
cookieVal).setMaxAge(3600) // 3600 seconds, or one hour
S.addCookie(cookie) }

bind("cookie", xhtml, "value" -> SHtml.text(cookieVal, cookieVal = _),
"add" -> SHtml.submit("Add", setCookie) "remove" -> SHtml.link(S.uri, ()
\=> S.deleteCookie(cookieName), "Delete Cookie") ) } } 

Attributes

See also
def addFunctionMap(name: String, value: AFuncHolder): Unit

Associates a name with a function impersonated by AFuncHolder. These are basically functions that are executed when a request contains the 'name' request parameter.

Associates a name with a function impersonated by AFuncHolder. These are basically functions that are executed when a request contains the 'name' request parameter.

Attributes

Adds a dispatch function for the current session, as opposed to a global dispatch through LiftRules.dispatch. An example would be if we wanted a user to be able to download a document only when logged in. First, we define a dispatch function to handle the download, specific to a given user:

Adds a dispatch function for the current session, as opposed to a global dispatch through LiftRules.dispatch. An example would be if we wanted a user to be able to download a document only when logged in. First, we define a dispatch function to handle the download, specific to a given user:

 def getDocument(userId : Long)() :
Box[LiftResponse] = { ... } 

Then, in the login/logout handling snippets, we could install and remove the custom dispatch as appropriate:

 def login(xhtml : NodeSeq) : NodeSeq = {
def doAuth () { ... if (user.loggedIn_?) {
S.addHighLevelSessionDispatcher("docDownload", { case Req(List("download",
"docs"), _, _) => getDocument(user.id) } ) } }

def logout(xhtml : NodeSeq) : NodeSeq = { def doLogout () { ...
S.removeHighLevelSessionDispatcher("docDownload") // or, if more than one
dispatch has been installed, this is simpler
S.clearHighLevelSessionDispatcher } } 

It's important to note that per-session dispatch takes precedence over LiftRules.dispatch, so you can override things set there.

Value parameters

disp

The dispatch partial function

name

A name for the dispatch. This can be used to remove it later by name.

Attributes

See also

LiftRules.DispatchPF

LiftRules.dispatch

Adds a per-session rewrite function. This can be used if you only want a particular rewrite to be valid within a given session. Per-session rewrites take priority over rewrites set in LiftRules.rewrite, so you can use this mechanism to override global functionality. For example, you could set up a global rule to make requests for the "account profile" page go back to the home page by default:

Adds a per-session rewrite function. This can be used if you only want a particular rewrite to be valid within a given session. Per-session rewrites take priority over rewrites set in LiftRules.rewrite, so you can use this mechanism to override global functionality. For example, you could set up a global rule to make requests for the "account profile" page go back to the home page by default:

 package bootstrap.olon ... imports ...
class Boot { def boot { LiftRules.rewrite.append { case
RewriteRequest(ParsePath(List("profile")), _, _, _) =>
RewriteResponse(List("index")) } } } 

Then, in your login snippet, you could set up a per-session rewrite to the correct template:

 def loginSnippet (xhtml : NodeSeq) :
NodeSeq = { ... def doLogin () { ... S.addSessionRewriter("profile", {
case RewriteRequest(ParsePath(List("profile")), _, _, _) =>
RewriteResponse(List("viewProfile"), Map("user" -> user.id)) } ... } ... }

And in your logout snippet you can remove the rewrite:

 def doLogout () {
S.removeSessionRewriter("profile") // or S.clearSessionRewriter } 

Value parameters

name

A name for the rewrite function so that it can be replaced or deleted later.

rw

The rewrite partial function

Attributes

See also

Register a stateful snippet for a given class name. Only registers if the name is not already set.

Register a stateful snippet for a given class name. Only registers if the name is not already set.

Attributes

Add javascript to the page rendering that will execute in the global scope. Usually you should use appendJs, so that the javascript runs after the entire dom is available. If you need to declare a global var or you want javascript to execute immediately with no guarantee that the entire dom is available, you may use appendGlobalJs.

Add javascript to the page rendering that will execute in the global scope. Usually you should use appendJs, so that the javascript runs after the entire dom is available. If you need to declare a global var or you want javascript to execute immediately with no guarantee that the entire dom is available, you may use appendGlobalJs.

Attributes

def appendJs(js: JsCmd): Unit

Sometimes it's helpful to accumulate JavaScript as part of servicing a request. For example, you may want to accumulate the JavaScript as part of an Ajax response or a Comet Rendering or as part of a regular HTML rendering. Call S.appendJs(jsCmd). The accumulated Javascript will be emitted as part of the response, wrapped in an OnLoad to ensure that it executes after the entire dom is available. If for some reason you need to run javascript at the top-level scope, use appendGlobalJs.

Sometimes it's helpful to accumulate JavaScript as part of servicing a request. For example, you may want to accumulate the JavaScript as part of an Ajax response or a Comet Rendering or as part of a regular HTML rendering. Call S.appendJs(jsCmd). The accumulated Javascript will be emitted as part of the response, wrapped in an OnLoad to ensure that it executes after the entire dom is available. If for some reason you need to run javascript at the top-level scope, use appendGlobalJs.

Attributes

def appendJs(js: Seq[JsCmd]): Unit

Sometimes it's helpful to accumulate JavaScript as part of servicing a request. For example, you may want to accumulate the JavaScript as part of an Ajax response or a Comet Rendering or as part of a regular HTML rendering. Call S.appendJs(jsCmd). The accumulated Javascript will be emitted as part of the response, wrapped in an OnLoad to ensure that it executes after the entire dom is available. If for some reason you need to run javascript at the top-level scope, use appendGlobalJs.

Sometimes it's helpful to accumulate JavaScript as part of servicing a request. For example, you may want to accumulate the JavaScript as part of an Ajax response or a Comet Rendering or as part of a regular HTML rendering. Call S.appendJs(jsCmd). The accumulated Javascript will be emitted as part of the response, wrapped in an OnLoad to ensure that it executes after the entire dom is available. If for some reason you need to run javascript at the top-level scope, use appendGlobalJs.

Attributes

def appendNotices(list: Seq[(Value, NodeSeq, Box[String])]): Unit

Add a whole list of notices

Add a whole list of notices

Attributes

An exception was thrown during the processing of this request. This is tested to see if the transaction should be rolled back

An exception was thrown during the processing of this request. This is tested to see if the transaction should be rolled back

Attributes

Get the accumulated Elems for the end of the body

Get the accumulated Elems for the end of the body

Attributes

See also

putAtEndOfBody

Get a list of current attributes. Each attribute item is a pair of (key,value). The key is an Either that depends on whether the attribute is prefixed or not. If the attribute is prefixed, the key is a Right((prefix, name)). If the attribute is unprefixed then the key is a Left(name). For example, the following table shows how various tag attributes would be represented:

Get a list of current attributes. Each attribute item is a pair of (key,value). The key is an Either that depends on whether the attribute is prefixed or not. If the attribute is prefixed, the key is a Right((prefix, name)). If the attribute is unprefixed then the key is a Left(name). For example, the following table shows how various tag attributes would be represented:

Snippet Tag Parsed attrs
<lift:MySnippet testname="test" /> List((Left("testname"), "test"))
<lift:MySnippet anchor:name="test" /> List((Right(("anchor", "name")), "test"))

The prefixedAttrsToMap method provides a convenient way to retrieve only attributes with a given prefix. The prefixedAttrsToMetaData method can be used to add attributes onto an XML node

Attributes

See also

Converts the S.attrs to a Map[String, String]. The key of the map depends on whether the attribute is prefixed or not. Prefixed attributes have keys of the form "prefix:name", while unprefixed attributes have keys of the form "name". If you only want attributes for a specific prefix, use prefixedAttrsToMap.

Converts the S.attrs to a Map[String, String]. The key of the map depends on whether the attribute is prefixed or not. Prefixed attributes have keys of the form "prefix:name", while unprefixed attributes have keys of the form "name". If you only want attributes for a specific prefix, use prefixedAttrsToMap.

Attributes

See also

Converts S.attrs attributes to a MetaData object that can be used to add attributes to one or more XML elements. Similar to prefixedAttrsToMetaData, except that it handles both prefixed and unprefixed attributes. This version of the method will use all of the currently set attributes from S.attrs. If you want to filter it, use the attrsToMetaData(String => Boolean) version, which allows you to specify a predicate function for filtering. For example, if you want all of the current attributes to be added to a div tag, you could do:

Converts S.attrs attributes to a MetaData object that can be used to add attributes to one or more XML elements. Similar to prefixedAttrsToMetaData, except that it handles both prefixed and unprefixed attributes. This version of the method will use all of the currently set attributes from S.attrs. If you want to filter it, use the attrsToMetaData(String => Boolean) version, which allows you to specify a predicate function for filtering. For example, if you want all of the current attributes to be added to a div tag, you could do:

 val myDiv = (

 {...} ) %
S.attrsToMetaData 

Attributes

Returns

a MetaData instance representing all attributes in S.attrs

See also
def attrsToMetaData(predicate: String => Boolean): MetaData

Similar to S.attrsToMetaData, but lets you specify a predicate function that filters the generated MetaData. For example, if you only wanted the "id" attribute, you could do:

Similar to S.attrsToMetaData, but lets you specify a predicate function that filters the generated MetaData. For example, if you only wanted the "id" attribute, you could do:

 val myDiv = (

 {...} ) %
S.attrsToMetaData(_.equalsIgnoreCase("id")) 

Value parameters

predicate

The predicate function which is executed for each attribute name. If the function returns true, then the attribute is included in the MetaData.

Attributes

See also
def callOnce[T](f: => T): T

If you bind functions (i.e. using SHtml helpers) inside the closure passed to callOnce, after your function is invoked, it will be automatically removed from functions cache so that it cannot be invoked again.

If you bind functions (i.e. using SHtml helpers) inside the closure passed to callOnce, after your function is invoked, it will be automatically removed from functions cache so that it cannot be invoked again.

Attributes

def clearAttrs[T](f: => T): T

Sometimes, in the course of eager evaluation, it becomes necessary to clear attribtues so they do not polute the eagerly evaluated stuff. When you need to clear the attributes, wrap your code block in clearAttrs and have fun.

Sometimes, in the course of eager evaluation, it becomes necessary to clear attribtues so they do not polute the eagerly evaluated stuff. When you need to clear the attributes, wrap your code block in clearAttrs and have fun.

Type parameters

T

the return type of the code block

Value parameters

f

the call-by-name code block to run where the attributes are clear

Attributes

Returns

the return value of the code block

Clears up the notices

Clears up the notices

Attributes

Clears the function map. potentially very destuctive... use at your own risk!

Clears the function map. potentially very destuctive... use at your own risk!

Attributes

Clears all custom dispatch functions from the current session. See addHighLevelSessionDispatcher for an example of usage.

Clears all custom dispatch functions from the current session. See addHighLevelSessionDispatcher for an example of usage.

Attributes

See also

LiftRules.DispatchPF

LiftRules.dispatch

Clears the per-session rewrite table. See addSessionRewriter for an example of usage.

Clears the per-session rewrite table. See addSessionRewriter for an example of usage.

Attributes

See also

The current container request

The current container request

Attributes

Returns the HttpSession

Returns the HttpSession

Attributes

Wrap an AFuncHolder with the current snippet and Loc context so that for Ajax calls, the original snippets, RequestVars and Loc (location) are populated

Wrap an AFuncHolder with the current snippet and Loc context so that for Ajax calls, the original snippets, RequestVars and Loc (location) are populated

Value parameters

f

the AFuncHolder that you want to wrap with execution context

Attributes

The current context path for the deployment.

The current context path for the deployment.

Attributes

def cookieValue(name: String): Box[String]

Get the cookie value for the given cookie

Get the cookie value for the given cookie

Attributes

def createJsonFunc(f: PFPromoter[JValue[_], JsCmd]): (JsonCall, JsCmd)

Build a handler for incoming JSON commands based on the new Json Parser

Build a handler for incoming JSON commands based on the new Json Parser

Value parameters

f

- partial function against a returning a JsCmds

Attributes

Returns

( JsonCall, JsCmd )

def createJsonFunc(onError: JsCmd, f: PFPromoter[JValue[_], JsCmd]): (JsonCall, JsCmd)

Build a handler for incoming JSON commands based on the new Json Parser

Build a handler for incoming JSON commands based on the new Json Parser

Value parameters

f

- partial function against a returning a JsCmds

onError

-- the JavaScript to execute client-side if the request is not processed by the server

Attributes

Returns

( JsonCall, JsCmd )

def createJsonFunc(name: Box[String], onError: Box[JsCmd], pfp: PFPromoter[JValue[_], JsCmd]): (JsonCall, JsCmd)

Build a handler for incoming JSON commands based on the new Json Parser. You can use the helpful Extractor in olon.util.JsonCommand

Build a handler for incoming JSON commands based on the new Json Parser. You can use the helpful Extractor in olon.util.JsonCommand

Value parameters

f

- partial function against a returning a JsCmds

name

-- the optional name of the command (placed in a comment for testing)

onError

-- the JavaScript to execute client-side if the request is not processed by the server

Attributes

Returns

( JsonCall, JsCmd )

Retrieves the attributes from the most recently executed snippet element.

Retrieves the attributes from the most recently executed snippet element.

For example, given the snippets:

 <lift:MyStuff.snippetA foo="bar">
<lift.MyStuff.snippetB>...</lift.MyStuff.snippetB>
</lift:MyStuff.snippetA> 

S.currentAttrs will return Nil.

If you want a particular attribute, the S.currentAttr helper object simplifies things considerably.

Attributes

Converts S.attrs attributes to a MetaData object that can be used to add attributes to one or more XML elements. Similar to prefixedAttrsToMetaData, except that it handles both prefixed and unprefixed attributes. This version of the method will use all of the currently set attributes from S.attrs. If you want to filter it, use the currentAttrsToMetaData(String => Boolean) version, which allows you to specify a predicate function for filtering. For example, if you want all of the current attributes to be added to a div tag, you could do:

Converts S.attrs attributes to a MetaData object that can be used to add attributes to one or more XML elements. Similar to prefixedAttrsToMetaData, except that it handles both prefixed and unprefixed attributes. This version of the method will use all of the currently set attributes from S.attrs. If you want to filter it, use the currentAttrsToMetaData(String => Boolean) version, which allows you to specify a predicate function for filtering. For example, if you want all of the current attributes to be added to a div tag, you could do:

 val myDiv = (

 {...} ) %
S.attrsToMetaData 

Attributes

Returns

a MetaData instance representing all attributes in S.attrs

See also

Similar to S.attrsToMetaData, but lets you specify a predicate function that filters the generated MetaData. For example, if you only wanted the "id" attribute, you could do:

Similar to S.attrsToMetaData, but lets you specify a predicate function that filters the generated MetaData. For example, if you only wanted the "id" attribute, you could do:

 val myDiv = (

 {...} ) %
S.attrsToMetaData(_.equalsIgnoreCase("id")) 

Value parameters

predicate

The predicate function which is executed for each attribute name. If the function returns true, then the attribute is included in the MetaData.

Attributes

See also

The current raw NodeSeq that resulted in a snippet invocation

The current raw NodeSeq that resulted in a snippet invocation

Attributes

Returns

The current raw NodeSeq that resulted in a snippet invocation

def deleteCookie(cookie: HTTPCookie): Unit

Deletes the cookie from the user's browser.

Deletes the cookie from the user's browser.

Value parameters

cookie

the Cookie to delete

Attributes

See also

olon.http.provider.HTTPCookie

def deleteCookie(name: String): Unit

Deletes the cookie from the user's browser.

Deletes the cookie from the user's browser.

Value parameters

name

the name of the cookie to delete

Attributes

See also

olon.http.provider.HTTPCookie

def disableTestFuncNames[T](f: => T): T

A function that will eagerly evaluate a template.

A function that will eagerly evaluate a template.

Attributes

def encodeURL(url: String): String

Decorates an URL with jsessionid parameter in case cookies are disabled from the container. Also it appends general purpose parameters defined by LiftRules.urlDecorate

Decorates an URL with jsessionid parameter in case cookies are disabled from the container. Also it appends general purpose parameters defined by LiftRules.urlDecorate

Attributes

def error(n: String): Unit

Sets an ERROR notice as a plain text

Sets an ERROR notice as a plain text

Attributes

def error(n: NodeSeq): Unit

Sets an ERROR notice as an XML sequence

Sets an ERROR notice as an XML sequence

Attributes

def error(id: String, n: NodeSeq): Unit

Sets an ERROR notice as an XML sequence and associates it with an id

Sets an ERROR notice as an XML sequence and associates it with an id

Attributes

def error(id: String, n: String): Unit

Sets an ERROR notice as plain text and associates it with an id

Sets an ERROR notice as plain text and associates it with an id

Attributes

def error(vi: List[FieldError]): Unit

Sets an ERROR notices from a List[FieldError]

Sets an ERROR notices from a List[FieldError]

Attributes

def errors: List[(NodeSeq, Box[String])]

Returns only ERROR notices

Returns only ERROR notices

Attributes

def eval(template: NodeSeq, snips: (String, NodeSeq => NodeSeq)*): Box[NodeSeq]

Evaluate a template for snippets. This can be used to run a template from within some other Lift processing, such as a snippet or view.

Evaluate a template for snippets. This can be used to run a template from within some other Lift processing, such as a snippet or view.

Value parameters

snips

any snippet mapping specific to this template run

template

the HTML template to run through the Snippet re-writing process

Attributes

Returns

a Full Box containing the processed template, or a Failure if the template could not be found.

Was an exception thrown during the processing of the current request?

Was an exception thrown during the processing of the current request?

Attributes

def findCookie(name: String): Box[HTTPCookie]

Finds a cookie with the given name that was sent in the request.

Finds a cookie with the given name that was sent in the request.

Value parameters

name

- the name of the cookie to find

Attributes

Returns

Full ( cookie ) if the cookie exists, Empty otherwise

See also
def findOrCreateComet(cometType: String, cometName: Box[String], cometHtml: NodeSeq, cometAttributes: Map[String, String], receiveUpdatesOnPage: Boolean): Box[LiftCometActor]

As with {findOrBuildComet[T]}, but specify the type as a String. If the comet doesn't already exist, the comet type is first looked up via LiftRules.cometCreationFactory, and then as a class name in the comet packages designated by LiftRules.buildPackage("comet").

As with {findOrBuildComet[T]}, but specify the type as a String. If the comet doesn't already exist, the comet type is first looked up via LiftRules.cometCreationFactory, and then as a class name in the comet packages designated by LiftRules.buildPackage("comet").

If receiveUpdates is true, updates to this comet will be pushed to the page currently being rendered or to the page that is currently invoking an AJAX callback. You can also separately register a comet to receive updates like this using {S.addComet}.

Attributes

def findOrCreateComet[T <: LiftCometActor](cometName: Box[String], cometHtml: NodeSeq, cometAttributes: Map[String, String], receiveUpdatesOnPage: Boolean)(implicit cometManifest: ClassTag[T]): Box[T]

Find or build a comet actor of the given type T with the given configuration parameters. If a comet of that type with that name already exists, it is returned; otherwise, a new one of that type is created and set up, then returned.

Find or build a comet actor of the given type T with the given configuration parameters. If a comet of that type with that name already exists, it is returned; otherwise, a new one of that type is created and set up, then returned.

If receiveUpdates is true, updates to this comet will be pushed to the page currently being rendered or to the page that is currently invoking an AJAX callback. You can also separately register a comet to receive updates like this using {S.addComet}.

Attributes

def fmapFunc[T](in: AFuncHolder)(f: String => T): T

Maps a function with an random generated and name

Maps a function with an random generated and name

Attributes

def forHead(): List[Elem]

Get the accumulated Elems for head

Get the accumulated Elems for head

Attributes

See also

putInHead

def formGroup[T](group: Int)(f: => T): T
def functionLifespan[T](span: Boolean)(f: => T): T

Functions that are mapped to HTML elements are, by default, garbage collected if they are not seen in the browser in the last 10 minutes (defined in LiftRules.unusedFunctionsLifeTime). In some cases (e.g., JSON handlers), you may want to extend the lifespan of the functions to the lifespan of the session.

Functions that are mapped to HTML elements are, by default, garbage collected if they are not seen in the browser in the last 10 minutes (defined in LiftRules.unusedFunctionsLifeTime). In some cases (e.g., JSON handlers), you may want to extend the lifespan of the functions to the lifespan of the session.

Value parameters

f

A function to execute in the context of specified span

span

If true, extend the mapped function lifetime to the life of the session

Attributes

See also

LiftRules.unusedFunctionsLifeTime

Returns whether functions are currently extended to the lifetime of the session.

Returns whether functions are currently extended to the lifetime of the session.

Attributes

Returns

true if mapped functions will currently last the life of the session.

Get a map of function name bindings that are used for form and other processing. Using these bindings is considered advanced functionality.

Get a map of function name bindings that are used for form and other processing. Using these bindings is considered advanced functionality.

Attributes

Standard func-name logic. This is the default routine.

Standard func-name logic. This is the default routine.

Attributes

Generates a func-name based on the location in the call-site source code.

Generates a func-name based on the location in the call-site source code.

Attributes

Default func-name logic during test-mode.

Default func-name logic during test-mode.

Attributes

def get(what: String): Box[String]

Returns the LiftSession parameter denominated by 'what'.

Returns the LiftSession parameter denominated by 'what'.

Attributes

See also

Returns the current and "old" notices

Returns the current and "old" notices

Attributes

def getDocType: (Boolean, Box[String])

Returns the document type that was set for the response. The default is XHTML 1.0 Transitional.

Returns the document type that was set for the response. The default is XHTML 1.0 Transitional.

Attributes

See also

setDocType

DocType

Returns the current notices

Returns the current notices

Attributes

def getRequestHeader(name: String): Box[String]

Returns the current value of the given HTTP request header as a Box. This is really just a thin wrapper on Req.header(String). For response headers, see S.getHeaders, S.setHeader, or S.getHeader.

Returns the current value of the given HTTP request header as a Box. This is really just a thin wrapper on Req.header(String). For response headers, see S.getHeaders, S.setHeader, or S.getHeader.

Value parameters

name

The name of the HTTP header to retrieve

Attributes

Returns

A Full(value) or Empty if the header isn't set

See also
def getResponseHeader(name: String): Box[String]

Returns the current set value of the given HTTP response header as a Box. If you want a request header, use Req.getHeader or S.getRequestHeader.

Returns the current set value of the given HTTP response header as a Box. If you want a request header, use Req.getHeader or S.getRequestHeader.

Value parameters

name

The name of the HTTP header to retrieve

Attributes

Returns

A Full(value) or Empty if the header isn't set

See also

Returns the currently set HTTP response headers as a List[(String, String)]. To retrieve a specific response header, use S.getResponseHeader. If you want to get request headers (those sent by the client), use Req.getHeaders or S.getRequestHeader.

Returns the currently set HTTP response headers as a List[(String, String)]. To retrieve a specific response header, use S.getResponseHeader. If you want to get request headers (those sent by the client), use Req.getHeaders or S.getRequestHeader.

Attributes

See also
def getSessionAttribute(what: String): Box[String]

Returns the HttpSession parameter denominated by 'what'

Returns the HttpSession parameter denominated by 'what'

Attributes

See also
def get_?: Boolean

Test the current request to see if it's a GET. This is a thin wrapper on Req.get_?

Test the current request to see if it's a GET. This is a thin wrapper on Req.get_?

Attributes

Returns

true if the request is a GET, false otherwise.

See also

Req.get_ ?

Return the list of DispatchHolders set for this session.

Return the list of DispatchHolders set for this session.

Attributes

See also

DispatchHolder

Return a List of the LiftRules.DispatchPF functions that are set for this session. See addHighLevelSessionDispatcher for an example of how these are used.

Return a List of the LiftRules.DispatchPF functions that are set for this session. See addHighLevelSessionDispatcher for an example of how these are used.

Attributes

See also

The host and path of the request up to and including the context path. This does not include the template path or query string.

The host and path of the request up to and including the context path. This does not include the template path or query string.

Attributes

The hostname to which the request was sent. This is taken from the "Host" HTTP header, or if that does not exist, the DNS name or IP address of the server.

The hostname to which the request was sent. This is taken from the "Host" HTTP header, or if that does not exist, the DNS name or IP address of the server.

Attributes

Get the current instance of HtmlProperties

Get the current instance of HtmlProperties

Attributes

def idMessages(f: => List[(NodeSeq, Box[String])]): List[(String, List[NodeSeq])]

Returns the messages that are associated with any id. Messages associated with the same id will be enlisted.

Returns the messages that are associated with any id. Messages associated with the same id will be enlisted.

Value parameters

f

- the function that returns the messages

Attributes

Attributes

Returns

should failed snippets be ignored and have the original NodeSeq returned?

This method returns true if the S object has been initialized for our current scope. If the S object has not been initialized then functionality on S will not work.

This method returns true if the S object has been initialized for our current scope. If the S object has not been initialized then functionality on S will not work.

Attributes

def init[B](request: Box[Req], session: LiftSession)(f: => B): B

Initialize the current request session. Generally this is handled by Lift during request processing, but this method is available in case you want to use S outside the scope of a request (standard HTTP or Comet).

Initialize the current request session. Generally this is handled by Lift during request processing, but this method is available in case you want to use S outside the scope of a request (standard HTTP or Comet).

Value parameters

f

Function to execute within the scope of the request and session

request

The Req instance for this request

session

the LiftSession for this request

Attributes

def initIfUninitted[B](session: LiftSession)(f: => B): B

Initialize the current request session if it's not already initialized. Generally this is handled by Lift during request processing, but this method is available in case you want to use S outside the scope of a request (standard HTTP or Comet).

Initialize the current request session if it's not already initialized. Generally this is handled by Lift during request processing, but this method is available in case you want to use S outside the scope of a request (standard HTTP or Comet).

Value parameters

f

A function to execute within the scope of the session

session

the LiftSession for this request

Attributes

Returns the 'type' S attribute. This corresponds to the current Snippet's name. For example, the snippet:

Returns the 'type' S attribute. This corresponds to the current Snippet's name. For example, the snippet:

 <lift:Hello.world /> 

Will return "Hello.world".

Attributes

def jsToAppend(clearAfterReading: Boolean): List[JsCmd]

Get the accumulated JavaScript

Get the accumulated JavaScript

Attributes

See also

appendJs

def jsonFmapFunc[T](in: (JValue[_]) => JsCmd)(f: String => T)(implicit dummy: AvoidTypeErasureIssues1): T

Maps a function that will be called with a parsed JValue and should return a JsCmd to be sent back to the browser. Note that if the passed JSON does not parse, the function will not be invoked.

Maps a function that will be called with a parsed JValue and should return a JsCmd to be sent back to the browser. Note that if the passed JSON does not parse, the function will not be invoked.

Attributes

A boolean indicating whether or not the response should be rendered with special accomodations for IE 6 / 7 / 8 compatibility.

A boolean indicating whether or not the response should be rendered with special accomodations for IE 6 / 7 / 8 compatibility.

Attributes

Returns

true if this response should be rendered in IE 6/7/8 compatibility mode.

See also

LiftSession.legacyIeCompatibilityMode

LiftRules.calcIEMode

Req.isIE6

Req.isIE7

Req.isIE8

Req.isIE

def liftCoreResourceBundle: Box[ResourceBundle]

Get the lift core resource bundle for the current locale as defined by the LiftRules.liftCoreResourceName varibale.

Get the lift core resource bundle for the current locale as defined by the LiftRules.liftCoreResourceName varibale.

Attributes

See also

LiftRules.liftCoreResourceName

def loc(str: String): Box[NodeSeq]

Localize the incoming string based on a resource bundle for the current locale. The localized string is converted to an XML element if necessary via the LiftRules.localizeStringToXml function (the default behavior is to wrap it in a Text element). If the lookup fails for a given resource bundle (e.g. a null is returned), then the LiftRules.localizationLookupFailureNotice function is called with the input string and locale.

Localize the incoming string based on a resource bundle for the current locale. The localized string is converted to an XML element if necessary via the LiftRules.localizeStringToXml function (the default behavior is to wrap it in a Text element). If the lookup fails for a given resource bundle (e.g. a null is returned), then the LiftRules.localizationLookupFailureNotice function is called with the input string and locale.

Value parameters

str

the string or ID to localize

Attributes

Returns

A Full box containing the localized XML or Empty if there's no way to do localization

See also

LiftRules.localizeStringToXml

LiftRules.localizationLookupFailureNotice

def loc(str: String, dflt: NodeSeq): NodeSeq

Localize the incoming string based on a resource bundle for the current locale, with a default value to to return if localization fails.

Localize the incoming string based on a resource bundle for the current locale, with a default value to to return if localization fails.

Value parameters

dflt

the default string to return if localization fails

str

the string or ID to localize

Attributes

Returns

the localized XHTML or default value

See also
def loc(str: String, xform: NodeSeq => NodeSeq): Box[NodeSeq]

Localize the incoming string based on a resource bundle for the current locale. The localized string is converted to an XML element if necessary via the LiftRules.localizeStringToXml function (the default behavior is to wrap it in a Text element). If the lookup fails for a given resource bundle (e.g. a null is returned), then the LiftRules.localizationLookupFailureNotice function is called with the input string and locale. The function is applied to the result/

Localize the incoming string based on a resource bundle for the current locale. The localized string is converted to an XML element if necessary via the LiftRules.localizeStringToXml function (the default behavior is to wrap it in a Text element). If the lookup fails for a given resource bundle (e.g. a null is returned), then the LiftRules.localizationLookupFailureNotice function is called with the input string and locale. The function is applied to the result/

Value parameters

str

the string or ID to localize

xform

the function that transforms the NodeSeq

Attributes

Returns

A Full box containing the localized XML or Empty if there's no way to do localization

See also

LiftRules.localizeStringToXml

LiftRules.localizationLookupFailureNotice

def locale: Locale

Returns the Locale for this request based on the LiftRules.localeCalculator method.

Returns the Locale for this request based on the LiftRules.localeCalculator method.

Attributes

See also

LiftRules.localeCalculator ( HTTPRequest )

java.util.Locale

def locateSnippet(name: String): Box[NodeSeq => NodeSeq]

Finds a snippet function by name.

Finds a snippet function by name.

Attributes

See also

LiftRules.snippets

def location: Box[Loc[_]]
def logQuery(query: String, time: Long): ListBuffer[(String, Long)]

Log a query for the given request. The query log can be tested to see if queries for the particular page rendering took too long. The query log starts empty for each new request. olon.mapper.DB.queryCollector is a method that can be used as a log function for the olon.mapper.DB.addLogFunc method to enable logging of Mapper queries. You would set it up in your bootstrap like:

Log a query for the given request. The query log can be tested to see if queries for the particular page rendering took too long. The query log starts empty for each new request. olon.mapper.DB.queryCollector is a method that can be used as a log function for the olon.mapper.DB.addLogFunc method to enable logging of Mapper queries. You would set it up in your bootstrap like:

 import olon.mapper.DB import olon.http.S
class Boot { def boot { ... DB.addLogFunc(DB.queryCollector) ... } }

Note that the query log is simply stored as a List and is not sent to any output by default. To retrieve the List of query log items, use S.queryLog. You can also provide your own analysis function that will process the query log via S.addAnalyzer.

Attributes

See also

olon.mapper.DB.addLogFunc

This method is a convenience accessor for LiftRules.loggedInTest. You can define your own function to check to see if a user is logged in there and this will call it.

This method is a convenience accessor for LiftRules.loggedInTest. You can define your own function to check to see if a user is logged in there and this will call it.

Attributes

Returns

the value from executing LiftRules.loggedInTest, or false if a test function is not defined.

See also

LiftRules.loggedInTest

def mapFuncToURI(uri: String, f: () => Unit): String

Attaches to this uri and parameter that has function f associated with. When this request is submitted to server the function will be executed and then it is automatically cleaned up from functions caches.

Attaches to this uri and parameter that has function f associated with. When this request is submitted to server the function will be executed and then it is automatically cleaned up from functions caches.

Attributes

def mapSnippet(name: String, func: NodeSeq => NodeSeq): Unit

Associates a name with a snippet function 'func'. This can be used to change a snippet mapping on a per-request basis. For example, if we have a page that we want to change behavior on based on query parameters, we could use mapSnippet to programmatically determine which snippet function to use for a given snippet in the template. Our code would look like:

Associates a name with a snippet function 'func'. This can be used to change a snippet mapping on a per-request basis. For example, if we have a page that we want to change behavior on based on query parameters, we could use mapSnippet to programmatically determine which snippet function to use for a given snippet in the template. Our code would look like:

 import scala.xml.{ NodeSeq,Text } class
SnipMap { def topSnippet (xhtml : NodeSeq) : NodeSeq = { if
(S.param("showAll").isDefined) { S.mapSnippet("listing", listing) } else {
S.mapSnippet("listing", { ignore => Text("") } ) }

... }

def listing(xhtml : NodeSeq) : NodeSeq = { ... } 

Then, your template would simply look like:

 <lift:surround with="default"
at="content"> ... <p><lift:SnipMap.topSnippet /></p>
<p><lift:listing /></p> </lift:surround> 

Snippets are processed in the order that they're defined in the template, so if you want to use this approach make sure that the snippet that defines the mapping comes before the snippet that is being mapped. Also note that these mappings are per-request, and are discarded after the current request is processed.

Value parameters

func

The snippet function to map to.

name

The name of the snippet that you want to map (the part after "<lift:").

Attributes

def mapSnippetsWith[T](snips: (String, NodeSeq => NodeSeq)*)(f: => T): T

The are times when it's helpful to define snippets for a certain call stack... snippets that are local purpose. Use doWithSnippets to temporarily define snippet mappings for the life of f.

The are times when it's helpful to define snippets for a certain call stack... snippets that are local purpose. Use doWithSnippets to temporarily define snippet mappings for the life of f.

Attributes

Converts a Map[String, String] into a MetaData instance. This can be used to add attributes to an XML element based on a map of attribute->value pairs. See prefixedAttrsToMetaData(String,Map) for an example.

Converts a Map[String, String] into a MetaData instance. This can be used to add attributes to an XML element based on a map of attribute->value pairs. See prefixedAttrsToMetaData(String,Map) for an example.

Value parameters

in

The map of attributes

Attributes

Returns

MetaData representing the Map of attributes as unprefixed attributes.

See also
def messages(f: => List[(NodeSeq, Box[String])]): List[NodeSeq]

Returns all messages, associated with any id or not

Returns all messages, associated with any id or not

Value parameters

f

- the function that returns the messages

Attributes

def messagesById(id: String)(f: => List[(NodeSeq, Box[String])]): List[NodeSeq]

Returns the messages provided by list function that are associated with id

Returns the messages provided by list function that are associated with id

Value parameters

f

- the function that returns the messages

id

- the lookup id

Attributes

def noIdMessages(f: => List[(NodeSeq, Box[String])]): List[NodeSeq]

Returns the messages that are not associated with any id

Returns the messages that are not associated with any id

Value parameters

f

- the function that returns the messages

Attributes

def notice(n: String): Unit

Sets a NOTICE notice as plain text

Sets a NOTICE notice as plain text

Attributes

def notice(n: NodeSeq): Unit

Sets a NOTICE notice as an XML sequence

Sets a NOTICE notice as an XML sequence

Attributes

def notice(id: String, n: NodeSeq): Unit

Sets a NOTICE notice as and XML sequence and associates it with an id

Sets a NOTICE notice as and XML sequence and associates it with an id

Attributes

def notice(id: String, n: String): Unit

Sets a NOTICE notice as plai text and associates it with an id

Sets a NOTICE notice as plai text and associates it with an id

Attributes

def notices: List[(NodeSeq, Box[String])]

Returns only NOTICE notices

Returns only NOTICE notices

Attributes

def oneShot[T](f: => T): T

All functions created inside the oneShot scope will only be called once and their results will be cached and served again if the same function is invoked

All functions created inside the oneShot scope will only be called once and their results will be cached and served again if the same function is invoked

Attributes

def originalRequest: Box[Req]

If this is an Ajax request, return the original request that created the page. The original request is useful because it has the original path which is helpful for localization purposes.

If this is an Ajax request, return the original request that created the page. The original request is useful because it has the original path which is helpful for localization purposes.

Attributes

Returns

the original request or if that's not available, the current request

Register a stateful snippet for a given class name. The addSnippetForClass method is preferred

Register a stateful snippet for a given class name. The addSnippetForClass method is preferred

Attributes

def param(n: String): Box[String]

Returns the HTTP parameter having 'n' name

Returns the HTTP parameter having 'n' name

Attributes

def params(n: String): List[String]

Returns all the HTTP parameters having 'n' name

Returns all the HTTP parameters having 'n' name

Attributes

Test the current request to see if it's a POST. This is a thin wrapper over Req.post_?

Test the current request to see if it's a POST. This is a thin wrapper over Req.post_?

Attributes

Returns

true if the request is a POST request, false otherwise.

Returns the S attributes that are prefixed by 'prefix' parameter as a Map[String, String] that will be 'merged' with the 'start' Map

Returns the S attributes that are prefixed by 'prefix' parameter as a Map[String, String] that will be 'merged' with the 'start' Map

Value parameters

prefix

the prefix to be matched

start

the initial Map

Attributes

Returns

Map[String, String]

See also

Returns the S attributes that are prefixed by 'prefix' parameter as a Map[String, String]

Returns the S attributes that are prefixed by 'prefix' parameter as a Map[String, String]

Value parameters

prefix

the prefix to be matched

Attributes

Returns

Map[String, String]

See also

Returns the S attributes that are prefixed by 'prefix' parameter as a MetaData. The start Map will be 'merged' with the Map resulted after prefix matching and the result Map will be converted to a MetaData. The MetaData can be used to add attributes back onto XML elements via Scala's '%' method. For example, if we wanted to add attributes prefixed with "anchor" to any <a> elements we create, we could do something like:

Returns the S attributes that are prefixed by 'prefix' parameter as a MetaData. The start Map will be 'merged' with the Map resulted after prefix matching and the result Map will be converted to a MetaData. The MetaData can be used to add attributes back onto XML elements via Scala's '%' method. For example, if we wanted to add attributes prefixed with "anchor" to any <a> elements we create, we could do something like:

 val myLink = (...) %
S.prefixedAttrsToMetaData("anchor", Map("id" -> "myAnchor")) 

Value parameters

prefix

the prefix to be matched

start

the initial Map

Attributes

Returns

MetaData representing the combination of current attributes plus the start Map of attributes

See also

Similar with prefixedAttrsToMetaData(prefix: String, start: Map[String, String]) but there is no 'start' Map

Similar with prefixedAttrsToMetaData(prefix: String, start: Map[String, String]) but there is no 'start' Map

Attributes

def putAtEndOfBody(elem: Elem): Unit

Put the given Elem at the end of the body tag.

Put the given Elem at the end of the body tag.

Attributes

def putInHead(elem: Elem): Unit

Put the given Elem in the head tag. The Elems will be de-dupped so no problems adding the same style tag multiple times

Put the given Elem in the head tag. The Elems will be de-dupped so no problems adding the same style tag multiple times

Attributes

Get a list of the logged queries. These log entries are added via the logQuery method, which has a more detailed explanation of usage.

Get a list of the logged queries. These log entries are added via the logQuery method, which has a more detailed explanation of usage.

Attributes

See also
def queryString: Box[String]

Returns the query string for the current request

Returns the query string for the current request

Attributes

Attributes

Returns

a List of any Cookies that have been set for this Response. If you want a specific cookie, use findCookie.

See also
def redirectTo(where: String): Nothing

Redirects the browser to a given URL. Note that the underlying mechanism for redirects is to throw a ResponseShortcutException, so if you're doing the redirect within a try/catch block, you need to make sure to either ignore the redirect exception or rethrow it. Two possible approaches would be:

Redirects the browser to a given URL. Note that the underlying mechanism for redirects is to throw a ResponseShortcutException, so if you're doing the redirect within a try/catch block, you need to make sure to either ignore the redirect exception or rethrow it. Two possible approaches would be:

 ... try { // your code here
S.redirectTo(...) } catch { case e: Exception if
!e.isInstanceOf[LiftFlowOfControlException] => ... } 

or

 ... try { // your code here
S.redirectTo(...) } catch { case rse: LiftFlowOfControlException => throw
rse case e: Exception => ... } 

Value parameters

where

The new URL to redirect to.

Attributes

See also

ResponseShortcutException

def redirectTo(where: String, func: () => Unit): Nothing

Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL. Otherwise the function is exactly the same as S.redirectTo(String), which has example documentation. Note that if the URL that you redirect to must be part of your web application or the function won't be executed. This is because the function is only registered locally.

Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL. Otherwise the function is exactly the same as S.redirectTo(String), which has example documentation. Note that if the URL that you redirect to must be part of your web application or the function won't be executed. This is because the function is only registered locally.

Value parameters

func

The function to be executed when the redirect is accessed.

where

The new URL to redirect to.

Attributes

See also
def referer: Box[String]

Returns the 'Referer' HTTP header attribute.

Returns the 'Referer' HTTP header attribute.

Attributes

Removes a custom dispatch function for the current session. See addHighLevelSessionDispatcher for an example of usage.

Removes a custom dispatch function for the current session. See addHighLevelSessionDispatcher for an example of usage.

Value parameters

name

The name of the custom dispatch to be removed.

Attributes

See also

LiftRules.DispatchPF

LiftRules.dispatch

Removes the given per-session rewriter. See addSessionRewriter for an example of usage.

Removes the given per-session rewriter. See addSessionRewriter for an example of usage.

Attributes

See also
def render(xhtml: NodeSeq, httpRequest: HTTPRequest): NodeSeq

Returns the logical page_id of the current request. All RequestVars for a current page share this id.

Returns the logical page_id of the current request. All RequestVars for a current page share this id.

Attributes

def request: Box[Req]

Get a Req representing our current HTTP request.

Get a Req representing our current HTTP request.

Attributes

Returns

A Full(Req) if one has been initialized on the calling thread, Empty otherwise.

See also

Req

def resourceBundles: List[ResourceBundle]

Get a List of the resource bundles for the current locale. The resource bundles are defined by the LiftRules.resourceNames and LiftRules.resourceBundleFactories variables. If you do not define an entry for a particular key, we fall back to using Lift's core entries.

Get a List of the resource bundles for the current locale. The resource bundles are defined by the LiftRules.resourceNames and LiftRules.resourceBundleFactories variables. If you do not define an entry for a particular key, we fall back to using Lift's core entries.

Attributes

See also

LiftRules.resourceNames

LiftRules.resourceBundleFactories

def resourceBundles(loc: Locale): List[ResourceBundle]
def respondAsync(f: => Box[LiftResponse]): () => Box[LiftResponse]

Use this in DispatchPF for processing REST requests asynchronously. Note that this must be called in a stateful context, therefore the S state must be a valid one.

Use this in DispatchPF for processing REST requests asynchronously. Note that this must be called in a stateful context, therefore the S state must be a valid one.

Value parameters

f

- the user function that does the actual computation. This function takes one parameter which is the function that must be invoked for returning the actual response to the client. Note that f function is invoked asynchronously in the context of a different thread.

Attributes

Attributes

Returns

a List of any Cookies that have been added to the response to be sent back to the user. If you want the cookies that were sent with the request, see receivedCookies.

See also

olon.http.provider.HTTPCookie

Run any configured exception handlers and make sure errors in the handlers are ignored

Run any configured exception handlers and make sure errors in the handlers are ignored

Attributes

def runSnippetsWithIgnoreFailed[T](ignore: Boolean)(f: => T): T

Set the ignore snippet error mode. In this mode, any snippet failures (usually snippets not being invocable) will be ignored and the original NodeSeq will be returned.

Set the ignore snippet error mode. In this mode, any snippet failures (usually snippets not being invocable) will be ignored and the original NodeSeq will be returned.

This is useful if you want to do an initial pass of a page with a white-list of snippets, but not run every snippet on the page.

Type parameters

T

the return type of the code block

Value parameters

f

the code block to execute

ignore

sets the ignore flag

Attributes

Returns

the return of the code block

def runTemplate(path: List[String], snips: (String, NodeSeq => NodeSeq)*): Box[NodeSeq]

Find and process a template. This can be used to load a template from within some other Lift processing, such as a snippet or view. If you just want to retrieve the XML contents of a template, use Templates.apply.

Find and process a template. This can be used to load a template from within some other Lift processing, such as a snippet or view. If you just want to retrieve the XML contents of a template, use Templates.apply.

Value parameters

path

The path for the template that you want to process

snips

any snippet mapping specific to this template run

Attributes

Returns

a Full Box containing the processed template, or a Failure if the template could not be found.

See also

TempalateFinder # apply

def seeOther[T](where: String): T

Redirects the browser to a given URL. Note that the underlying mechanism for redirects is to throw a ResponseShortcutException, so if you're doing the redirect within a try/catch block, you need to make sure to either ignore the redirect exception or rethrow it. Two possible approaches would be:

Redirects the browser to a given URL. Note that the underlying mechanism for redirects is to throw a ResponseShortcutException, so if you're doing the redirect within a try/catch block, you need to make sure to either ignore the redirect exception or rethrow it. Two possible approaches would be:

 ... try { // your code here
S.seeOther(...) } catch { case e: Exception if
!e.instanceOf[LiftFlowOfControlException] => ... } 

or

 ... try { // your code here
S.seeOther(...) } catch { case rse: LiftFlowOfControlException => throw
rse case e: Exception => ... } 

Value parameters

where

The new URL to redirect to.

Attributes

See also

ResponseShortcutException

def seeOther[T](where: String, func: () => Unit): T

Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL. Otherwise the function is exactly the same as S.seeOther(String), which has example documentation. Note that if the URL that you redirect to must be part of your web application or the function won't be executed. This is because the function is only registered locally.

Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL. Otherwise the function is exactly the same as S.seeOther(String), which has example documentation. Note that if the URL that you redirect to must be part of your web application or the function won't be executed. This is because the function is only registered locally.

Value parameters

func

The function to be executed when the redirect is accessed.

where

The new URL to redirect to.

Attributes

See also
def session: Box[LiftSession]

The current LiftSession.

The current LiftSession.

Attributes

def sessionFuture[T](task: => T, scheduler: LAScheduler): LAFuture[T]

Creates LAFuture instance aware of the current request and session. Each LAFuture returned by chained transformation method (e.g. map, flatMap) will be also request/session-aware. However, it's important to bear in mind that initial session or request are not propagated to chained methods. It's required that current execution thread for chained method has request or session available in scope if reading/writing some data to it as a part of chained method execution.

Creates LAFuture instance aware of the current request and session. Each LAFuture returned by chained transformation method (e.g. map, flatMap) will be also request/session-aware. However, it's important to bear in mind that initial session or request are not propagated to chained methods. It's required that current execution thread for chained method has request or session available in scope if reading/writing some data to it as a part of chained method execution.

Attributes

Return the list of RewriteHolders set for this session. See addSessionRewriter for an example of how to use per-session rewrites.

Return the list of RewriteHolders set for this session. See addSessionRewriter for an example of how to use per-session rewrites.

Attributes

See also

RewriteHolder

LiftRules # rewrite

def set(name: String, value: String): Unit

Sets a LiftSession attribute

Sets a LiftSession attribute

Attributes

See also
def setDocType(what: Box[String]): Unit

Sets the document type for the response. If this is not set, the DocType for Lift responses defaults to XHTML 1.0 Transitional.

Sets the document type for the response. If this is not set, the DocType for Lift responses defaults to XHTML 1.0 Transitional.

Attributes

See also

getDocType

ResponseInfo.docType

DocType

def setHeader(name: String, value: String): Unit

Sets a HTTP response header attribute. For example, you could set a "Warn" header in your response:

Sets a HTTP response header attribute. For example, you could set a "Warn" header in your response:

 ... S.setHeader("Warn", "The cheese is
old and moldy") ... 

Attributes

See also
def setResponseHeader(name: String, value: String): Unit

Synonym for S.setHeader. Exists to provide the converse to S.getResponseHeader.

Synonym for S.setHeader. Exists to provide the converse to S.getResponseHeader.

Attributes

def setSessionAttribute(name: String, value: String): Unit

Sets a HttpSession attribute

Sets a HttpSession attribute

Attributes

See also

When this is true, Lift will not emit a DocType definition at the start of the response content. If you're sending XHTML and this is set to true, you need to include the DocType in your template.

When this is true, Lift will not emit a DocType definition at the start of the response content. If you're sending XHTML and this is set to true, you need to include the DocType in your template.

Attributes

See also
def skipDocType_=(skip: Boolean): Unit

Sets Lift's DocType behavior. If this is set to true, Lift will not emit a DocType definition at the start of the response content. If you're sending XHTML and this is set to true, you need to include the DocType in your template.

Sets Lift's DocType behavior. If this is set to true, Lift will not emit a DocType definition at the start of the response content. If you're sending XHTML and this is set to true, you need to include the DocType in your template.

Value parameters

skip

Set to true to prevent Lift from emitting a DocType in its response

Attributes

See also

If true, then the xml header at the beginning of the returned XHTML page will not be inserted.

If true, then the xml header at the beginning of the returned XHTML page will not be inserted.

Attributes

Set the skipXmlHeader flag

Set the skipXmlHeader flag

Attributes

Given a snippet class name, return the cached or predefined stateful snippet for that class

Given a snippet class name, return the cached or predefined stateful snippet for that class

Attributes

Are we currently in the scope of a stateful request

Are we currently in the scope of a stateful request

Attributes

def statelessInit[B](request: Req)(f: => B): B
def synchronizeForSession[T](f: => T): T

Execute code synchronized to the current session object

Execute code synchronized to the current session object

Attributes

Find a template based on the snippet attribute "template"

Find a template based on the snippet attribute "template"

Attributes

def timeZone: TimeZone

Return the current timezone based on the LiftRules.timeZoneCalculator method.

Return the current timezone based on the LiftRules.timeZoneCalculator method.

Attributes

See also

LiftRules.timeZoneCalculator ( HTTPRequest )

java.util.TimeZone

def unset(name: String): Unit

Removes a LiftSession attribute

Removes a LiftSession attribute

Attributes

See also

Removes a HttpSession attribute

Removes a HttpSession attribute

Attributes

See also
def uri: String

The URI of the current request (not re-written). The URI is the portion of the request URL after the context path. For example, with a context path of "myApp", Lift would return the following URIs for the given requests:

The URI of the current request (not re-written). The URI is the portion of the request URL after the context path. For example, with a context path of "myApp", Lift would return the following URIs for the given requests:

HTTP request URI
http://foo.com/myApp/foo/bar.html /foo/bar.html
http://foo.com/myApp/test/ /test/
http://foo.com/myApp/item.html?id=42 /item.html

If you want the full URI, including the context path, you should retrieve it from the underlying HTTPRequest. You could do something like:

 val fullURI =
S.request.map(_.request.getRequestURI) openOr ("Undefined") 

The URI may be used to provide a link back to the same page as the current request:

 bind(..., "selflink" -> SHtml.link(S.uri,
{ () => ... }, Text("Self link")), ...) 

Attributes

See also

Req.uri

olon.http.provider.HTTPRequest.uri

def userAgent: Box[String]

The user agent of the current request, if any.

The user agent of the current request, if any.

Attributes

def warning(n: String): Unit

Sets a WARNING notice as plain text

Sets a WARNING notice as plain text

Attributes

def warning(n: NodeSeq): Unit

Sets a WARNING notice as an XML sequence

Sets a WARNING notice as an XML sequence

Attributes

def warning(id: String, n: NodeSeq): Unit

Sets a WARNING notice as an XML sequence and associates it with an id

Sets a WARNING notice as an XML sequence and associates it with an id

Attributes

def warning(id: String, n: String): Unit

Sets a WARNING notice as plain text and associates it with an id

Sets a WARNING notice as plain text and associates it with an id

Attributes

def warnings: List[(NodeSeq, Box[String])]

Returns only WARNING notices

Returns only WARNING notices

Attributes

def withAttrs[T](attrs: MetaData)(f: => T): T

Temporarily adds the given attributes to the current set, then executes the given function.

Temporarily adds the given attributes to the current set, then executes the given function.

Value parameters

attrs

The attributes to set temporarily

Attributes

def withCurrentSnippetNodeSeq[T](ns: NodeSeq)(f: => T): T

The code block is executed while setting the current raw NodeSeq for access elsewhere

The code block is executed while setting the current raw NodeSeq for access elsewhere

Type parameters

T

the type that f returns

Value parameters

f

the call-by-name value to return (the code block to execute)

ns

the current NodeSeq

Attributes

Returns

the value the the expression returns

Inherited methods

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Attributes

Inherited from:
UserAgentCalculator

Inherited fields

lazy val chromeVersion: Box[Double]

Attributes

Inherited from:
UserAgentCalculator
lazy val firefoxVersion: Box[Double]

Attributes

Inherited from:
UserAgentCalculator
lazy val ieIE10: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val ieVersion: Box[Int]

Attributes

Inherited from:
UserAgentCalculator
lazy val isChrome2: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isChrome3: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isChrome4: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isChrome5: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isChrome6: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isFirefox2: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isFirefox3: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isFirefox35: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isFirefox36: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isFirefox40: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE11: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE6: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE7: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE8: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIE9: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isIPad: Boolean

Is the Req coming from an iPad

Is the Req coming from an iPad

Attributes

Inherited from:
UserAgentCalculator
lazy val isIPhone: Boolean

Is the Req coming from an iPhone

Is the Req coming from an iPhone

Attributes

Inherited from:
UserAgentCalculator
lazy val isOpera9: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isSafari3: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isSafari4: Boolean

Attributes

Inherited from:
UserAgentCalculator
lazy val isSafari5: Boolean

Attributes

Inherited from:
UserAgentCalculator
protected val logger: Logger

Attributes

Inherited from:
Loggable
lazy val safariVersion: Box[Int]

Attributes

Inherited from:
UserAgentCalculator

Implicits

Implicits

implicit def stuff2ToUnpref(in: (Symbol, Any)): UnprefixedAttribute
implicit def tuple2FieldError(t: (FieldIdentifier, NodeSeq)): FieldError