Abstrats a function that is executed on HTTP requests from client.
The CookieHolder class holds information about cookies to be sent during the session, as well as utility methods for adding and deleting cookies.
DispatchHolder holds a partial function that maps a Req to a LiftResponse.
RewriteHolder holds a partial function that re-writes an incoming request.
o != arg0
is the same as !(o == (arg0))
.
o != arg0
is the same as !(o == (arg0))
.
the object to compare against this object for dis-equality.
false
if the receiver object is equivalent to the argument; true
otherwise.
o == arg0
is the same as if (o eq null) arg0 eq null else o.equals(arg0)
.
o == arg0
is the same as if (o eq null) arg0 eq null else o.equals(arg0)
.
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
o == arg0
is the same as o.equals(arg0)
.
o == arg0
is the same as o.equals(arg0)
.
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
Attempt to localize and then format the given string.
Attempt to localize and then format the given string. This uses the String.format method to format the localized string.
the string to localize
the var-arg parameters applied for string formatting
the localized and formatted version of the string
# resourceBundles
String.format
Get a localized string or return the original string.
Get a localized string or return the original string.
the string to localize
the localized version of the string
# resourceBundles
Get a core lift localized and formatted string or return the original string.
Get a core lift localized and formatted string or return the original string.
the string to localize
the var-arg parameters applied for string formatting
the localized version of the string
Get a core lift localized string or return the original string
Get a core lift localized string or return the original string
the string to localize
the localized version of the string
The companion object that generates AFuncHolders from other functions
Add a query analyzer (passed queries for analysis or logging).
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.
# queryLog
# logQuery
You can wrap the handling of an HTTP request with your own wrapper.
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 net.liftweb.http.{ ResourceVar,S } import net.liftweb.util.LoanWrapperThis 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).// 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 } } ) ... } }
LoanWrapper
# addAround ( LoanWrapper )
You can wrap the handling of an HTTP request with your own wrapper.
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).
LoanWrapper
# addAround ( LoanWrapper )
Adds a cleanup function that will be executed at the end of the request pocessing.
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.
The function to execute at the end of the request.
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 net.liftweb.http.provider.HTTPCookieclass 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") ) } }
# responseCookies
# deleteCookie ( String )
# deleteCookie ( Cookie )
net.liftweb.http.provider.HTTPCookie
Associates a name with a function impersonated by AFuncHolder.
Associates a name with a function impersonated by AFuncHolder. These are basically functions that are executed when a request contains the 'name' request parameter.
Adds a dispatch function for the current session, as opposed to a global dispatch through LiftRules.
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.
A name for the dispatch. This can be used to remove it later by name.
The dispatch partial function
# clearHighLevelSessionDispatcher
# removeHighLevelSessionDispatcher
LiftRules.dispatch
LiftRules.DispatchPF
Adds a per-session rewrite function.
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.liftweb ... 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 }
A name for the rewrite function so that it can be replaced or deleted later.
# clearSessionRewriter
# removeSessionRewriter
# sessionRewriter
LiftRules.rewrite
Register a stateful snippet for a given class name.
Register a stateful snippet for a given class name. Only registers if the name is not already set.
Sometimes it's helpful to accumute JavaScript as part of servicing a request.
Sometimes it's helpful to accumute 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 accumulation of Js will be emitted as part of the response.
Sometimes it's helpful to accumute JavaScript as part of servicing a request.
Sometimes it's helpful to accumute 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 accumulation of Js will be emitted as part of the response.
Add a whole list of notices
Add a whole list of notices
This method is used to cast the receiver object to be of type T0
.
This method is used to cast the receiver object to be of type T0
.
Note that the success of a cast at runtime is modulo Scala's erasure semantics. Therefore the expression1.asInstanceOf[String]
will throw a ClassCastException
at runtime, while the expressionList(1).asInstanceOf[List[String]]
will not. In the latter example, because the type argument is erased as
part of compilation it is not possible to check whether the contents of the list are of the requested typed.
the receiver object.
Get the accumulated Elems for the end of the body
Used to get an attribute by its name.
Get a list of current attributes.
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
# prefixedAttrsToMetaData ( String, Map )
# prefixedAttrsToMetaData ( String )
# prefixedAttrsToMap ( String, Map )
# prefixedAttrsToMap ( String )
Converts the S.
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.
# prefixedAttrsToMap ( String, Map )
# prefixedAttrsToMap ( String )
Similar to S.
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"))
The predicate function which is executed for each attribute name. If the function
returns true
, then the attribute is included in the MetaData.
# attrsToMetaData
Converts S.
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
a MetaData instance representing all attributes in S.attrs
# attrsToMetaData ( String = > Boolean )
Build a handler for incoming JSON commands
Build a handler for incoming JSON commands
-- the optional name of the command (placed in a comment for testing)
- function returning a JsCmds
( JsonCall, JsCmd )
Build a handler for incoming JSON commands
Build a handler for incoming JSON commands
- function returning a JsCmds
( JsonCall, JsCmd )
If you bind functions (i.
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.
Clears up the notices
Clears up the notices
Clears the function map.
Clears the function map. potentially very destuctive... use at your own risk!
Clears all custom dispatch functions from the current session.
Clears all custom dispatch functions from the current session. See addHighLevelSessionDispatcher for an example of usage.
# clearHighLevelSessionDispatcher
# addHighLevelSessionDispatcher
LiftRules.dispatch
LiftRules.DispatchPF
Clears the per-session rewrite table.
Clears the per-session rewrite table. See addSessionRewriter for an example of usage.
# removeSessionRewriter
# addSessionRewriter
LiftRules.rewrite
This method creates and returns a copy of the receiver object.
This method creates and returns a copy of the receiver object.
The default implementation of the clone
method is platform dependent.
a copy of the receiver object.
The current container request
The current container request
Returns the HttpSession
Returns the HttpSession
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
the AFuncHolder that you want to wrap with execution context
The current context path for the deployment.
The current context path for the deployment.
Get the cookie value for the given cookie
Get the cookie value for the given cookie
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. You can use the helpful Extractor in net.liftweb.util.JsonCommand
-- the optional name of the command (placed in a comment for testing)
-- the JavaScript to execute client-side if the request is not processed by the server
( 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
-- the JavaScript to execute client-side if the request is not processed by the server
- partial function against a returning a JsCmds
( 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
- partial function against a returning a JsCmds
( JsonCall, JsCmd )
Used to get an attribute by its name from the current snippet element.
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.
Similar to S.
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"))
The predicate function which is executed for each attribute name. If the function
returns true
, then the attribute is included in the MetaData.
# attrsToMetaData
Converts S.
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
a MetaData instance representing all attributes in S.attrs
# attrsToMetaData ( String = > Boolean )
Deletes the cookie from the user's browser.
Deletes the cookie from the user's browser.
the name of the cookie to delete
# deleteCookie ( Cookie )
# addCookie ( Cookie )
net.liftweb.http.provider.HTTPCookie
Deletes the cookie from the user's browser.
Deletes the cookie from the user's browser.
the Cookie to delete
# deleteCookie ( String )
# addCookie ( Cookie )
net.liftweb.http.provider.HTTPCookie
A function that will eagerly evaluate a template.
A function that will eagerly evaluate a template.
Decorates an URL with jsessionid parameter in case cookies are disabled from the container.
Decorates an URL with jsessionid parameter in case cookies are disabled from the container. Also it appends general purpose parameters defined by LiftRules.urlDecorate
This method is used to test whether the argument (arg0
) is a reference to the
receiver object (this
).
This method is used to test whether the argument (arg0
) is a reference to the
receiver object (this
).
The eq
method implements an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence relation] on
non-null instances of AnyRef
:
* It is reflexive: for any non-null instance x
of type AnyRef
, x.eq(x)
returns true
.
* It is symmetric: for any non-null instances x
and y
of type AnyRef
, x.eq(y)
returns true
if and
only if y.eq(x)
returns true
.
* It is transitive: for any non-null instances x
, y
, and z
of type AnyRef
if x.eq(y)
returns true
and y.eq(z)
returns true
, then x.eq(z)
returns true
.
Additionally, the eq
method has three other properties.
* It is consistent: for any non-null instances x
and y
of type AnyRef
, multiple invocations of
x.eq(y)
consistently returns true
or consistently returns false
.
* For any non-null instance x
of type AnyRef
, x.eq(null)
and null.eq(x)
returns false
.
* null.eq(null)
returns true
.
When overriding the equals
or hashCode
methods, it is important to ensure that their behavior is
consistent with reference equality. Therefore, if two objects are references to each other (o1 eq o2
), they
should be equal to each other (o1 == o2
) and they should hash to the same value (o1.hashCode == o2.hashCode
).
the object to compare against this object for reference equality.
true
if the argument is a reference to the receiver object; false
otherwise.
This method is used to compare the receiver object (this
) with the argument object (arg0
) for equivalence.
This method is used to compare the receiver object (this
) with the argument object (arg0
) for equivalence.
The default implementations of this method is an [http://en.wikipedia.org/wiki/Equivalence_relation equivalence
relation]:
* It is reflexive: for any instance x
of type Any
, x.equals(x)
should return true
.
* It is symmetric: for any instances x
and y
of type Any
, x.equals(y)
should return true
if and
only if y.equals(x)
returns true
.
* It is transitive: for any instances x
, y
, and z
of type AnyRef
if x.equals(y)
returns true
and
y.equals(z)
returns true
, then x.equals(z)
should return true
.
If you override this method, you should verify that your implementation remains an equivalence relation.
Additionally, when overriding this method it is often necessary to override hashCode
to ensure that objects
that are "equal" (o1.equals(o2)
returns true
) hash to the same
scala.Int
(o1.hashCode.equals(o2.hashCode)
).
the object to compare against this object for equality.
true
if the receiver object is equivalent to the argument; false
otherwise.
Sets an ERROR notices from a List[FieldError]
Sets an ERROR notices from a List[FieldError]
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
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
Sets an ERROR notice as an XML sequence
Sets an ERROR notice as an XML sequence
Sets an ERROR notice as a plain text
Sets an ERROR notice as a plain text
Returns only ERROR notices
Returns only ERROR notices
Evaluate a template for snippets.
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.
the HTML template to run through the Snippet re-writing process
any snippet mapping specific to this template run
a Full Box containing the processed template, or a Failure if the template could not be found.
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.
The details of when and if the finalize
method are invoked, as well as the interaction between finalize
and non-local returns and exceptions, are all platform dependent.
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.
- the name of the cookie to find
Full ( cookie ) if the cookie exists, Empty otherwise
# deleteCookie ( String )
# deleteCookie ( Cookie )
# addCookie ( Cookie )
# receivedCookies
net.liftweb.http.provider.HTTPCookie
Maps a function with an random generated and name
Maps a function with an random generated and name
Get the accumulated Elems for head
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.
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.
If true
, extend the mapped function lifetime to the life of the session
A function to execute in the context of specified span
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.
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.
Get a map of function name bindings that are used for form and other processing. Using these bindings is considered advanced functionality.
Returns the LiftSession parameter denominated by 'what'.
Returns the LiftSession parameter denominated by 'what'.
# unsetSessionAttribute
# unset
# setSessionAttribute
# set
# getSessionAttribute
Returns the current and "old" notices
Returns the current and "old" notices
Returns a representation that corresponds to the dynamic class of the receiver object.
Returns a representation that corresponds to the dynamic class of the receiver object.
The nature of the representation is platform dependent.
a representation that corresponds to the dynamic class of the receiver object.
Returns the document type that was set for the response.
Returns the document type that was set for the response. The default is XHTML 1.0 Transitional.
DocType
setDocType
Returns the current set value of the given HTTP response header as a Box.
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.
The name of the HTTP header to retrieve
A Full(value) or Empty if the header isn't set
# getRequestHeader ( String )
# getHeaders ( List[ ( String, String ) ] )
# setHeader ( String, String )
Returns the currently set HTTP response headers as a List[(String, String)].
Returns the currently set HTTP response headers as a List[(String, String)]. To retrieve a specific response header, use S.getHeader. If you want to get request headers (those sent by the client), use Req.getHeaders or S.getRequestHeader.
# getRequestHeader ( String )
# getHeader ( String )
# setHeader ( String, String )
Returns the current notices
Returns the current notices
Returns the current value of the given HTTP request header as a Box.
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.
The name of the HTTP header to retrieve
A Full(value) or Empty if the header isn't set
# getHeaders ( List[ ( String, String ) ] )
# setHeader ( String, String )
# getHeader ( String )
Req # header ( String )
Returns the HttpSession parameter denominated by 'what'
Returns the HttpSession parameter denominated by 'what'
# unsetSessionAttribute
# unset
# setSessionAttribute
# set
# get
Test the current request to see if it's a GET.
Test the current request to see if it's a GET. This is a thin wrapper on Req.get_?
true
if the request is a GET, false
otherwise.
Req.get_ ?
Returns a hash code value for the object.
Returns a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)
) yet
not be equal (o1.equals(o2)
returns false
). A degenerate implementation could always return 0
.
However, it is required that if two objects are equal (o1.equals(o2)
returns true
) that they have
identical hash codes (o1.hashCode.equals(o2.hashCode)
). Therefore, when overriding this method, be sure
to verify that the behavior is consistent with the equals
method.
the hash code value for the object.
Return the list of DispatchHolders set for this session.
Return the list of DispatchHolders set for this session.
DispatchHolder
Return a List of the LiftRules.
Return a List of the LiftRules.DispatchPF functions that are set for this session. See addHighLevelSessionDispatcher for an example of how these are used.
# clearHighLevelSessionDispatcher
# removeHighLevelSessionDispatcher ( String )
# addHighLevelSessionDispatcher ( String, LiftRules.DispatchPF )
LiftRules.DispatchPF
The host and path of the request up to and including the context path.
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 hostname to which the request was sent.
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.
Get the current instance of HtmlProperties
Get the current instance of HtmlProperties
Returns the messages that are associated with any id.
Returns the messages that are associated with any id. Messages associated with the same id will be enlisted.
- the function that returns the messages
true
if this response should be rendered in
IE6/IE7 compatibility mode.
Req.isIE
Req.isIE8
Req.isIE7
Req.isIE6
LiftRules.calcIEMode
LiftSession.ieMode
This method returns true if the S object has been initialized for our current scope.
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.
Initialize the current request session.
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).
The Req instance for this request
the LiftSession for this request
Function to execute within the scope of the request and session
Initialize the current request session if it's not already initialized.
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).
the LiftSession for this request
A function to execute within the scope of the session
Returns the 'type' S attribute.
Returns the 'type' S attribute. This corresponds to the current Snippet's name. For example, the snippet:
<lift:Hello.world />
Will return "Hello.world".
This method is used to test whether the dynamic type of the receiver object is T0
.
This method is used to test whether the dynamic type of the receiver object is T0
.
Note that the test result of the test is modulo Scala's erasure semantics. Therefore the expression1.isInstanceOf[String]
will return false
, while the expression List(1).isInstanceOf[List[String]]
will
return true
. In the latter example, because the type argument is erased as part of compilation it is not
possible to check whether the contents of the list are of the requested typed.
true
if the receiver object is an instance of erasure of type T0
; false
otherwise.
Get the accumulated JavaScript
Maps a function with an random generated and name
Maps a function with an random generated and name
Get the lift core resource bundle for the current locale as defined by the LiftRules.
Get the lift core resource bundle for the current locale as defined by the LiftRules.liftCoreResourceName varibale.
LiftRules.liftCoreResourceName
Localize the incoming string based on a resource bundle for the current 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. The
function is applied to the result/
the string or ID to localize
the function that transforms the NodeSeq
A Full box containing the localized XML or Empty if there's no way to do localization
# loc ( String, NodeSeq )
LiftRules.localizationLookupFailureNotice
LiftRules.localizeStringToXml
# resourceBundles
# locale
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.
the string or ID to localize
the default string to return if localization fails
the localized XHTML or default value
# loc ( String )
Localize the incoming string based on a resource bundle for the current 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.
the string or ID to localize
A Full box containing the localized XML or Empty if there's no way to do localization
# loc ( String, NodeSeq )
LiftRules.localizationLookupFailureNotice
LiftRules.localizeStringToXml
# resourceBundles
# locale
Returns the Locale for this request based on the LiftRules.
Returns the Locale for this request based on the LiftRules.localeCalculator method.
java.util.Locale
LiftRules.localeCalculator ( HTTPRequest )
Finds a snippet function by name.
Log a query for the given request.
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. net.liftweb.mapper.DB.queryCollector is a method that can be used as a log function for the net.liftweb.mapper.DB.addLogFunc method to enable logging of Mapper queries. You would set it up in your bootstrap like:
import net.liftweb.mapper.DB import net.liftweb.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.
net.liftweb.mapper.DB.addLogFunc
# addAnalyzer
# queryLog
This method is a convenience accessor for LiftRules.
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.
the value from executing LiftRules.loggedInTest, or false
if a test function
is not defined.
LiftRules.loggedInTest
Similar with addFunctionMap but also returns the name.
Similar with addFunctionMap but also returns the name.
Use fmapFunc(AFuncHolder)(String => T)
Use fmapFunc(AFuncHolder)(String => T)
Similar with addFunctionMap but also returns the name.
Similar with addFunctionMap but also returns the name.
Use fmapFunc(AFuncHolder)(String => T)
Use fmapFunc(AFuncHolder)(String => T)
Attaches to this uri and parameter that has function f associated with.
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.
Associates a name with a snippet function 'func'.
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.
The name of the snippet that you want to map (the part after "<lift:").
The snippet function to map to.
The are times when it's helpful to define snippets for a certain call stack.
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.
Converts a Map[String, String] into a MetaData instance.
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.
The map of attributes
MetaData representing the Map of attributes as unprefixed attributes.
# prefixedAttrsToMetaData ( String, Map )
Returns all messages, associated with any id or not
Returns all messages, associated with any id or not
- the function that returns the messages
Returns the messages provided by list function that are associated with id
Returns the messages provided by list function that are associated with id
- the lookup id
- the function that returns the messages
o.ne(arg0)
is the same as !(o.eq(arg0))
.
o.ne(arg0)
is the same as !(o.eq(arg0))
.
the object to compare against this object for reference dis-equality.
false
if the argument is not a reference to the receiver object; true
otherwise.
Returns the messages that are not associated with any id
Returns the messages that are not associated with any id
- the function that returns the messages
Sets an NOTICE notice as plai text and associates it with an id
Sets an NOTICE notice as plai text and associates it with an id
Sets an NOTICE notice as and XML sequence and associates it with an id
Sets an NOTICE notice as and XML sequence and associates it with an id
Sets an NOTICE notice as an XML sequence
Sets an NOTICE notice as an XML sequence
Sets an NOTICE notice as plain text
Sets an NOTICE notice as plain text
Returns only NOTICE notices
Returns only NOTICE notices
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up a single thread that is waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
Wakes up all threads that are waiting on the receiver object's monitor.
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
Register a stateful snippet for a given class name.
Register a stateful snippet for a given class name. The addSnippetForClass method is preferred
Returns the HTTP parameter having 'n' name
Returns all the HTTP parameters having 'n' name
Returns all the HTTP parameters having 'n' name
Test the current request to see if it's a POST.
Test the current request to see if it's a POST. This is a thin wrapper over Req.post_?
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]
Returns the S attributes that are prefixed by 'prefix' parameter as a Map[String, String]
the prefix to be matched
Map[String, String]
# prefixedAttrsToMetaData ( String, Map )
# prefixedAttrsToMetaData ( String )
# prefixedAttrsToMap ( String, Map )
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
the prefix to be matched
the initial Map
Map[String, String]
# prefixedAttrsToMetaData ( String, Map )
# prefixedAttrsToMetaData ( String )
# prefixedAttrsToMap ( String )
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
Returns the S attributes that are prefixed by 'prefix' parameter as a MetaData.
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"))
the prefix to be matched
the initial Map
MetaData representing the combination of current attributes plus the start Map of attributes
# prefixedAttrsToMetaData ( String )
# prefixedAttrsToMap ( String, Map )
# prefixedAttrsToMap ( String )
Put the given Elem at the end of the body tag.
Put the given Elem at the end of the body tag.
Put the given Elem in the head tag.
Put the given Elem in the head tag. The Elems will be de-dupped so no problems adding the same style tag multiple times
Get a list of the logged queries.
Get a list of the logged queries. These log entries are added via the logQuery method, which has a more detailed explanation of usage.
# addAnalyzer
# logQuery ( String, Long )
Returns the query string for the current request
Returns the query string for the current request
a List of any Cookies that have been set for this Response. If you want a specific cookie, use findCookie.
# deleteCookie ( String )
# deleteCookie ( Cookie )
# addCookie ( Cookie )
# findCookie ( String )
net.liftweb.http.provider.HTTPCookie
Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL.
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.
The new URL to redirect to.
The function to be executed when the redirect is accessed.
# redirectTo ( String )
Redirects the browser to a given URL.
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 => ... }
The new URL to redirect to.
# redirectTo ( String, ( ) => Unit)
ResponseShortcutException
Returns the 'Referer' HTTP header attribute.
Returns the 'Referer' HTTP header attribute.
Removes a custom dispatch function for the current session.
Removes a custom dispatch function for the current session. See addHighLevelSessionDispatcher for an example of usage.
The name of the custom dispatch to be removed.
# clearHighLevelSessionDispatcher
# addHighLevelSessionDispatcher
LiftRules.dispatch
LiftRules.DispatchPF
Removes the given per-session rewriter.
Removes the given per-session rewriter. See addSessionRewriter for an example of usage.
# clearSessionRewriter
# addSessionRewriter
LiftRules.rewrite
Get a Req representing our current HTTP request.
Get a Req representing our current HTTP request.
A Full(Req) if one has been initialized on the calling thread, Empty otherwise.
Req
Get a List of the resource bundles for the current locale.
Get a List of the resource bundles for the current locale. The resource bundles are defined by the LiftRules.resourceNames and LiftRules.resourceBundleFactories variables.
LiftRules.resourceBundleFactories
LiftRules.resourceNames
Use this in DispatchPF for processing REST requests asynchronously.
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.
- 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.
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.
# receivedCookies
net.liftweb.http.provider.HTTPCookie
Find and process a template.
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 TemplateFinder.findAnyTemplate.
The path for the template that you want to process
any snippet mapping specific to this template run
a Full Box containing the processed template, or a Failure if the template could not be found.
TempalateFinder # findAnyTemplate
Redirects the browser to a given URL and registers a function that will be executed when the browser accesses the new URL.
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.
The new URL to redirect to.
The function to be executed when the redirect is accessed.
# seeOther ( String )
Redirects the browser to a given URL.
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 => ... }
The new URL to redirect to.
# seeOther ( String, ( ) => Unit)
ResponseShortcutException
The current LiftSession.
The current LiftSession.
Return the list of RewriteHolders set for this session.
Return the list of RewriteHolders set for this session. See addSessionRewriter for an example of how to use per-session rewrites.
LiftRules # rewrite
RewriteHolder
Sets a LiftSession attribute
Sets a LiftSession attribute
# unsetSessionAttribute
# unset
# setSessionAttribute
# getSessionAttribute
# get
Sets the document type for the response.
Sets the document type for the response. If this is not set, the DocType for Lift responses defaults to XHTML 1.0 Transitional.
DocType
ResponseInfo.docType
getDocType
Sets a HTTP response header attribute.
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") ...
# getHeaders
Sets a HttpSession attribute
Sets a HttpSession attribute
# unsetSessionAttribute
# unset
# set
# getSessionAttribute
# get
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.
The attributes to set temporarily
Use the S.withAttrs method instead
When this is true, Lift will not emit a DocType definition at the start of the response content.
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.
# skipDocType_ =(Boolean)
Sets Lift's DocType behavior.
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.
Set to true
to prevent Lift from emitting a DocType in its response
# skipDocType
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.
Set the skipXmlHeader flag
Set the skipXmlHeader flag
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
Are we currently in the scope of a stateful request
Are we currently in the scope of a stateful request
Execute code synchronized to the current session object
Execute code synchronized to the current session object
Find a template based on the snippet attribute "template"
Find a template based on the snippet attribute "template"
Return the current timezone based on the LiftRules.
Return the current timezone based on the LiftRules.timeZoneCalculator method.
java.util.TimeZone
LiftRules.timeZoneCalculator ( HTTPRequest )
Use AFuncHolder.listStrToAF
Use AFuncHolder.unitToAF
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
a string representation of the object.
Removes a LiftSession attribute
Removes a LiftSession attribute
# unsetSessionAttribute
# setSessionAttribute
# set
# getSessionAttribute
# get
Removes a HttpSession attribute
Removes a HttpSession attribute
# unset
# setSessionAttribute
# set
# getSessionAttribute
# get
The URI of the current request (not re-written).
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")), ...)
net.liftweb.http.provider.HTTPRequest.uri
Req.uri
Sets an WARNING notice as plain text and associates it with an id
Sets an WARNING notice as plain text and associates it with an id
Sets an WARNING notice as an XML sequence and associates it with an id
Sets an WARNING notice as an XML sequence and associates it with an id
Sets an WARNING notice as an XML sequence
Sets an WARNING notice as an XML sequence
Sets an WARNING notice as plain text
Sets an WARNING notice as plain text
Returns only WARNING notices
Returns only WARNING notices
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.
The attributes to set temporarily
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.
see also: ,
LiftFilter
LiftSession