Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6930317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:25:54+00:00 2026-05-27T11:25:54+00:00

I’m starting out with Lift and been reading a few tutorials and books that

  • 0

I’m starting out with Lift and been reading a few tutorials and books that are available online. Coming from a JSP (or GWT) background, it’s a huge leap, especially since I’m still learning Scala too.

Anyway… I’ve created the basic site by downloading the lift tar.gz stuff from their site, copied the lift_blank” directory and renamed it to “test”. Did the whole “sbt update ~jetty-run” thing etc etc.

What I want to do is modify the “index.html” page to simply have a text field for input, and a button that says “search”. Basic idea, you type your firstname, hit “Search”, a database query is executed for finding records with a firstname of “what-you-entered-in-the-text-field”, and then the results are formatted and displayed on the web page; after the page has refreshed, the text field needs to contain the name that was entered as well.. You type in a different name, hit “search”, and new results are displayed on the page. Initially (first time visiting the page), the results are of course empty. Simple stuff…

However, the examples I’ve all seen use html forms and POST backs etc; I really dislike this, for example users get all flustered when refreshing the page and they get a firefox popup “To display this page, Iceweasel must send information that will repeat any action (such as a search or order confirmation) that was performed earlier.”… the page is also refreshed which is something I’d like to avoid.

Previously when I would build this in JSP, I would use all javascript; no “form” tags or anything, just a simple field with javascript events for hitting enter or hitting a “button”… events thaen get channeled to a main javascript function “onQuery” which then creates an AJAX request; when the result comes back from the server, javascript would modify a wrapper “div” element by changing the “innerHTML” value etc. The nice thing here is that the page doesn’t refresh, just a tiny subsection of it does, the “table” (actually a div) which holds the results.

How would I re-create a very similar thing in Lift? I’m kind of lost here. I’ve followed a few examples in the past few days, but again they all use POST / forms. I can handle the scala database querying, and I understand how Lift’s templates works, it’s just the snippet / comet stuff that I could use a few pointers on.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:25:55+00:00Added an answer on May 27, 2026 at 11:25 am

    Below is what I ended up using. The one thing I dislike about Lift is all the “magic” that needs to be inserted at various points. I can understand most of this, but the whole ” ++ hidden” thing could use some explaining…

    The “index.html” page, everything including the “body” tag:

    <body class="lift:content_id=main">
        <div id="main" class="lift:surround?with=default;at=page">
                <lift:Search.search>
                        Search Query: <query:text/>&nbsp;<query:button/><br/>
                        <div id="results">
                        </div>
                </lift:Search.search>
        </div>
    </body>
    

    The “Snippet” code, in a class called “Search.scala” (some of the import statements are unused, a leftover result of attempting different approaches):

    package code
    package snippet
    
    import scala.xml.{NodeSeq, Text}
    import net.liftweb.util._
    import net.liftweb.common._
    import java.util.Date
    import code.lib._
    import Helpers._
    import common.Main
    import common.solr.{Hitlist, Solr}
    import net.liftweb.http.{S, StatefulSnippet, SHtml}
    import net.liftweb.http.js.JsCmds.SetHtml
    
    import _root_.net.liftweb.http.SHtml._
    import _root_.net.liftweb.util.Log
    import net.liftweb.http.js.JsCmd
    import net.liftweb.http.js.JE.JsRaw
    
    object Search {
        def search(xhtml:NodeSeq):NodeSeq = {
            var queryText = "(initial)"
    
            def runQuery() = {
                println("\n\nQuery: " + queryText)
                SetHtml("results", <span>Query: {queryText}</span>)
            }//runQuery
    
            ajaxForm(
                bind("query", xhtml,
                    "text" -> text(queryText, queryText = _),
                    "button" -> submit("Post", runQuery)
                ) ++ hidden(runQuery _)
            )
        }//search
    }//Search
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.