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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:26:24+00:00 2026-05-16T04:26:24+00:00

there’s a simple form in Lift framework and a Class with render method that

  • 0

there’s a simple form in Lift framework and a Class with render method that handles the form:

 def render(xhtml:NodeSeq) = {
        var name = ""
        var role = ""
        var human = ""
        def register = {
            val person = new Person
            person.name = name
            person.role = role
            person.human = if (human == "yes") "true" else "false"
            model.create(person)
            S.redirectTo("/index")
        }
        bind("user",
        xhtml,
        ("name" -> SHtml.text(name, name = _)),
        ("role" -> SHtml.text(role, role = _)),
        ("human" -> SHtml.text(human,human = _)),
        ("submit" -> SHtml.submit("Register",register)))
    }

When I run this example, eg. I access the url which is binded to the according form, I get following error:

Message: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
...
...
...
    epsilon.sjbs.CrudModel$class.create(Sjbs.scala:14)
    epsilon.sjbs.PersonModel.create(Sjbs.scala:7)
    epsilon.snippet.PersonSnippet.register$1(Snippet.scala:33)
    epsilon.snippet.PersonSnippet.render(Snippet.scala:41)

this looks like that the register method is ran even there’s no click on submit, just accessing the url. Why?
EDIT:this is my original entity

@NamedQuery(name = "findAll", query = "select x from Person x")
@Entity class Person extends Id with Name{
    @OneToMany(mappedBy="person", cascade=Array(CascadeType.REMOVE))
    var participated:java.util.List[Participant] = new java.util.ArrayListParticipant
    var role:String = Role.User
    var human:String = _
}

  • 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-16T04:26:25+00:00Added an answer on May 16, 2026 at 4:26 am

    I think that Person.human is a Boolean, not a String…

    It looks like you’re using something that looks like Mapper. If you were using Mapper, I’d do it like so:

    def render(xhtml:NodeSeq) = {
      val person = Person.create
      bind(
        "user",
        xhtml,
        "name" -> SHtml.text(person.name, person.name(_)),
        "role" -> SHtml.text(person.role, person.role(_)),
        "human" -> SHtml.text(
          if (person.human) ? "yes" else "no",
          (human) => person.human(if (human == "yes") true else false)
        ),
        "submit" -> SHtml.submit("Register", () => {
          person.save
          S.redirectTo("/index")
        })
      )
    }
    

    Just personal preference of course, but that way you’re not using an explicit vars and can easily reuse it to edit an existing Person…

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

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
There is a class that's a fully fledged UIViewController and when that page loads
There is a moment in my app, that I need to force to show
There is a column that exists in 2 tables. In table 1, this column
There are a lot of blogs saying that a hasOwnProperty check should be used
There is any way to set the generic type (T) of class in the
There are a TextField , a ListBox and a TextArea inside my Form .
There is a website called Gild.com that has different coding puzzles/challenges for users to
There is a div (form) which opens on the click of a button. There
There is no doubt that MonoTouch is one of the great cross-compiler(s). Similarly, SenchaTouch

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.