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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:13:10+00:00 2026-05-23T03:13:10+00:00

I am trying to perform some custom validation with play framework but I don’t

  • 0

I am trying to perform some custom validation with play framework but I don’t seem to be able to get the error from the template.

The controller code is :


        User user = User.findByEmail(email);

        if(user != null) {
            Logger.warn("User account already created for email %s", email);
            validation.addError("email", "This email address already in use.");
            params.flash();
            flash.error("Please correct the error below!");
            signup();
        }

and the signup.html template:

#{error 'email' /}

I can see that the controller sees the duplicate email but the error message does not appear in the template.

Is the code above correct?

  • 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-23T03:13:11+00:00Added an answer on May 23, 2026 at 3:13 am

    Because you are going to a different view (i.e. you are redirecting back to the signup view), Play performs a redirect, which means that the errors are no longer in scope, as the signup view is treated as a new request.

    To get around this, you need to keep the validation messages available for the next request, which is achieved by using the validation.keep() function.

    So, change your code, so that just before you call signup(), you call validation.keep().

    Your code should look like

    if(user != null) {
        Logger.warn("User account already created for email %s", email);
        validation.addError("email", "This email address already in use.");
        params.flash();
        flash.error("Please correct the error below!");
        validation.keep();
        signup();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to perform some unit testing on the iphone but for some
I'm trying to write a custom Rake task to perform some tests for a
I'm trying to perform some calculations on a non-directed, cyclic, weighted graph, and I'm
In this situation I am trying to perform a data import from an XML
I'm trying to run through some html and insert some custom tags around every
I am trying to catch a file sent with form and perform some operations
I'm trying to perform a join in ActiveRecord using DetachedCriteria. I can't seem to
I am trying to migrate a PHP app from MySQL to SQLite, and some
I am trying to perform some n-gram counting in python and I thought I
I am trying to perform some integration testing to see if the article gets

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.