Lift Web Framework

On this page, we'll allow the user to select a series of <div> tags to display based on the results of a form submission.

<div> number 0 visible
<div> number 1 visible
<div> number 2 visible
<div> number 3 visible
<div> number 4 visible
<div> number 5 visible
This is div 0
This is div 1
This is div 2
This is div 3
This is div 4
This is div 5


The code to store the state of the div tags is:

private var whichDivs: Array[Boolean] = Array(true, true, true, true, true, true)
And to select the div tags:
  def selectDivs(in: NodeSeq): NodeSeq = {
    def calcNum(in: String): Box[Int] = 
      if (in.startsWith("num_")) asInt(in.substring(4))
      else Empty

    for {
      div <- in \\ "div" // select the div tags
      id = (div \ "@id").text // get their id
      num <- calcNum(id) if whichDivs(num) // filter 
    } yield div
  }


Lift is Copyright 2007-2010 WorldWide Conferencing, LLC. Distributed under an Apache 2.0 License.
Lift version 2.3 built on Tue Apr 05 13:24:00 PDT 2011.
Stats: Total Memory: 519,045,120 Free Memory: 469,265,152 Open Sessions: 120
Updated At: Tue Feb 07 22:10:17 PST 2012 Started At: Thu Jul 07 11:17:57 PDT 2011