#56

Add lazy loading to Lift

    • Status: Fixed
    • Priority: Normal (3)
    • Component: -
    • Estimate: None/Small/Medium/Large None
    • Required Documentation: -
    Let's say you have a bit of a page like so:

    <lift:SomeSnippet.section>
    <foo:name/>
    <lift:SomeSnippet.section>

    Now, let's assume that computing whatever is bound to <foo:name/>
    takes a long time (maybe it takes a network call, or a long database
    query, or whatever). You don't want to hold up your entire page view
    on that so.....

    <lift:Util.lazyLoad>
    <lift:SomeSnippet.section>
    <foo:name/>
    <lift:SomeSnippet.section>
    </lift:Util.lazyLoad>

    Then in your Util snippet:

    def lazyLoad(xhtml: NodeSeq) = {
    val id = "lazy"+System.currentTimeMillis()
    val (name, exp) = ajaxInvoke(() => { SetHtml(id, xhtml) })
    <div id={id}>
    <img src="/img/ajax_spinner.gif" height="32" width="32" alt="wait"/
    >
    {Script(OnLoad(exp.cmd))}
    </div>
    }

    Feel free to critique if there is a better way of doing this. It's
    working pretty good for me so far though.
  • Followers
     
    Ico-users marius.danciu (Assigned To) , dpp 
     
    Attachments
    No attachments
    Associations
     
    No associations
    Activity
     
    User picture

          on Feb 06, 2010 @ 11:48am UTC * By github.importer

    User picture

          on Feb 07, 2010 @ 11:21pm UTC * By Indrajit Raychaudhuri

    Milestone set to Lift 1.1-M8
    Time Expenditure
    Loading