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 3433018
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:31:21+00:00 2026-05-18T07:31:21+00:00

I was wondering, does Lift have an iteration tag (ex: for, foreach)? When I

  • 0

I was wondering, does Lift have an iteration tag (ex: for, foreach)?
When I was working with JSP, i could easily iterate a List, just with JSP, passing the object to the tag. Something like this, or like this.
I know it’s not really the best example, but you do understand my intentions.
To sum up, does this exist with Lift, or if not, how would I manage to do such thing?

The last thing i want to do is hardcode html.

  • 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-18T07:31:21+00:00Added an answer on May 18, 2026 at 7:31 am

    In short: No. Lift’s design strictly separates logic from design and as such forbids the use of generalised tags in the template markup.

    Have a look at the view first article in order to see how lift can handle iterations.

    An example from the article: Your markup:

    <table>
      <lift:show.users>
        <tr>
          <td><f:first_name>David</f:first_name></td>
          <td><f:last_name>Pollak</f:last_name></td>
        </tr>
      </lift:show.users>
    </table>
    

    Your code:

    class Show {
      def users(xhtml: NodeSeq): NodeSeq = 
        Users.findAll.flatMap(user => 
          bind("f", xhtml, 
            "first_name" -> user.firstName, 
            "last_name" -> user.nameName
          )
        )
    }
    

    Now, what lift does when it sees the tag <lift:show.users> is calling the corresponding method with the tag’s content as the argument. The tag will then be replaced by the return value of the users method.

    The users method does the iteration over all Users and for each user, it binds the values of first and second name to the inner xhtml. All those iterations are then concatenated (through flatMap) and returned.

    When I started with lift, I’d always found this approach a little too rigid; having a tiny loop here and there, how could that possibly hurt? But now that I know how easy it is to call and create your own snippets from the template code, I cannot imagine using anything like jsp anymore. It is weak in comparison and clutters your markup. And of course, you lose much of Scala’s power of validation.

    Notes:

    The reason the template tags are filled with content is for designing purposes. In this case the dummy tags and values are going to be replaced during the bind. The template designers can thus fill the tags with more or less meaningful content which allows the coder to better understand the semantics the designer had in mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just wondering how does apple approve the iPhone app that communicates via
I have the code below. I'm wondering that does the self.value and _value have
Just wondering does the 4GB limit apply to this edition or is it 'fully
I am wondering does VS 2010 have something that I can use to compare
I am wondering does JSP ever get compiled ? The reasons why that I
Simple and short. I was wondering does popular Channel9 have some application interface so
I was just wondering: how does Gmail use the Windows/Mac file chooser to upload
Hello: I have been experimenting with WPF this afternoon, Im wondering does anyone know
Just wondering does anybody know the default location for .mdmp/.hdmp files on Windows Server
I am using gcc 4.4.2 on linux I am just wondering does gcc automatically

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.