net.liftweb.util.BindHelpers

object BindHelpers

object BindHelpers

 extends BindHelpers


BindHelpers can be used to obtain additional information while a {@link bind} call is executing. This informaiton includes node attributes of the current bound node or the entire NodeSeq that is to be bound. Since the context is created during bind execution and destroyed when bind terminates, you can benefit of these helpers in the context of FuncBindParam or FuncAttrBindParam. You can also provide your own implementation of BindParam and your BindParam#calcValue function will be called in the appropriate context. Example:
 bind("hello", xml,
      "someNode" -> {node: NodeSeq => })
 
In function-body you can safely use BindHelpers methods to obtain correctly-scoped information.


Companion: BindHelpers

Source: BindHelpers.scala(75)

 Constructors

def this

 Fields

attr.. object attr
Helpers for obtaining attributes of the current Elem


 extends AttrHelper[Option]
bindNodes.. def bindNodes
A list of NodeSeq that preceeds the NodeSeq passed to bind [details]
The head of the list is the most recent NodeSeq. This returns Empty if it is called outside its context, or Full(Nil) if there are no child nodes but the function is called within the appropriate context.
Box[List[NodeSeq]]
currentNode.. def currentNode
A Box containing the current Elem, the children of which are passed to the bindParam
Box[Elem]

 Methods

!=.. final def !=(arg0 : Any) Boolean Any
!=.. final def !=(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Object) Boolean AnyRef
==.. final def ==(arg0 : Any) Boolean Any
asInstanceOf.. final def asInstanceOf[T0] T0 Any
bind.. def bind(namespace : String, nodeFailureXform : Box[(NodeSeq) => NodeSeq], paramFailureXform : Box[(PrefixedAttribute) => MetaData], xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML with defined transforms for unbound elements within the specified namespace [details]

For example:

     bind("user",
          Full(xhtml: NodeSeq => Text("Default Value")),
          Empty,
          replace thisreplace with default,
          "hello" -> 

)

will return

Default Value
param
xml - the NodeSeq in which to find elements to be bound.
nodeFailureXform - a box containing the function to use as the default transform for tags in the specified namespace that do not have bindings specified.
paramFailureXform - a box containing the function to use as the default transform for unrecognized attributes in bound elements.
params - the list of BindParam bindings to be applied
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(vals : Map[String, NodeSeq], xml : NodeSeq)
Replace the content of lift:bind nodes with the corresponding nodes found in a map, according to the value of the "name" attribute [details]

Usage:

     bind(Map("a" -> 

), change this) must ==/(

)

param
xml - nodes containing lift:bind nodes
vals - map of name/nodes to replace
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(namespace : String, xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML [details]

For example:

     bind("user", replace this, "hello" -> 

)

will return

param
xml - the NodeSeq in which to find elements to be bound.
params - the list of BindParam bindings to be applied
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bind.. def bind(namespace : String, nodeFailureXform : Box[(NodeSeq) => NodeSeq], paramFailureXform : Box[(PrefixedAttribute) => MetaData], preserveScope : Boolean, xml : NodeSeq, params : BindParam*)
Bind a set of values to parameters and attributes in a block of XML with defined transforms for unbound elements within the specified namespace [details]

For example:

     bind("user",
          Full(xhtml: NodeSeq => Text("Default Value")),
          Empty,
          replace thisreplace with default,
          "hello" -> 

)

will return

Default Value
param
preserveScope: - true if the scope should be preserved, false is the normal setting
params - the list of BindParam bindings to be applied
nodeFailureXform - a box containing the function to use as the default transform for tags in the specified namespace that do not have bindings specified.
paramFailureXform - a box containing the function to use as the default transform for unrecognized attributes in bound elements.
xml - the NodeSeq in which to find elements to be bound.
namespace - the namespace of tags to bind
return
- the NodeSeq that results from the specified transforms
NodeSeq BindHelpers
bindlist.. def bindlist(listvals : List[Map[String, NodeSeq]], xml : NodeSeq)
Bind a list of name/xml maps to a block of XML containing lift:bind nodes (see the bind(Map, NodeSeq) function) [details]
return
- the NodeSeq that results from the specified transforms
Box[NodeSeq] BindHelpers
chooseTemplate.. def chooseTemplate(prefix : String, tag : String, xhtml : NodeSeq)
Finds and returns one of many templates from the children based upon the namespace and tag name: for example, for prefix "choose" and tag name "stuff" this would return the contents of the first tag <choose:stuff> [details]
.. </choose:stuff> in the specified NodeSeq.
param
tag - the tag to choose (e.g., "stuff")
xhtml - the node sequence to search for the specified element
prefix - the prefix (e.g., "choose")
return
- the first matching node sequence
NodeSeq BindHelpers
clone.. protected def clone Object AnyRef
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
finalize.. protected def finalize Unit AnyRef
findNode.. def findNode(in : Elem, nodes : NodeSeq)
Finds and returns the first node in the specified NodeSeq and its children with the same label and prefix as the specified element
Box[Elem] BindHelpers
getClass.. final def getClass Class[Any] AnyRef
hashCode.. def hashCode Int AnyRef
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
mixinAttributes.. def mixinAttributes(out : Elem)(in : NodeSeq)
Takes attributes from the first node of 'in' (if any) and mixes them into 'out' [details]
Curried form can be used to produce a NodeSeq => NodeSeq for bind.
param
out - where to put the attributes
in - where to take the attributes from
return
- 'out' element with attributes from 'in'
NodeSeq BindHelpers
ne.. final def ne(arg0 : Object) Boolean AnyRef
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
processBind.. def processBind(around : NodeSeq, atWhat : Map[String, NodeSeq])
Bind parameters to XML [details]
deprecated
- use the bind function instead
param
atWhat - data to bind
around - XML with lift:bind elements
NodeSeq BindHelpers
strToBPAssoc.. implicit def strToBPAssoc(in : String)
transforms a String to a BindParamAssoc object which can be associated to a BindParam object using the --> operator [details]

Usage: "David" --> "name"

deprecated
- use -> instead
BindParamAssoc BindHelpers
strToSuperArrowAssoc.. implicit def strToSuperArrowAssoc(in : String) SuperArrowAssoc BindHelpers
stripHead.. def stripHead(in : NodeSeq)
Remove all the tags, just leaving the child tags
NodeSeq BindHelpers
symToBPAssoc.. implicit def symToBPAssoc(in : Symbol)
transforms a Symbol to a BindParamAssoc object which can be associated to a BindParam object using the --> operator [details]

Usage: 'David --> "name"

deprecated
- use -> instead
BindParamAssoc BindHelpers
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
template.. def template(xhtml : NodeSeq, prefix : String, tag1 : String, tag2 : String)
Find two of many templates from the children
Box[(NodeSeq, NodeSeq)] BindHelpers
template.. def template(xhtml : NodeSeq, prefix : String, tag : String)
Similar to chooseTemplate, this returns the contents of the element in a Full Box if found or an Empty Box otherwise
Box[NodeSeq] BindHelpers
template.. def template(xhtml : NodeSeq, prefix : String, tag1 : String, tag2 : String, tag3 : String)
Find three of many templates from the children
Box[(NodeSeq, NodeSeq, NodeSeq)] BindHelpers
toString.. def toString String AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
xbind.. def xbind(namespace : String, xml : NodeSeq)(transform : PartialFunction[String, (NodeSeq) => NodeSeq])
Experimental extension to bind which passes in an additional "parameter" from the XHTML to the transform function, which can be used to format the returned NodeSeq [details]
deprecated
- use bind instead
NodeSeq BindHelpers
xmlParam.. def xmlParam(in : NodeSeq, param : String)
Finds the named attribute in specified XML element and returns a Full Box containing the value of the attribute if found [details]
Empty otherwise.
return
- a Full Box containing the value of the attribute if found; Empty otherwise
Box[String] BindHelpers
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.