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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:50:27+00:00 2026-05-30T07:50:27+00:00

I am implementing a project with play 1.2.4, based on documentation the right way

  • 0

I am implementing a project with play 1.2.4, based on documentation the right way to handle validation is:

public static void signUp() {
    render();
}

public static void doSignUp(@Required @Valid User user) {
    if (validation.hasErrors()) {
        params.flash();
        validation.keep();
        signUp();
    }
    user.create();
    Application.index();
}

But based on samples provided with play, it seems that different approach is used:

public static void signUp() {
    render();
}

public static void doSignUp(@Required @Valid User user) {
    if (validation.hasErrors()) {
        render("@signUp"); 
    }
    user.create();
    Application.index();
}

For this small example the code difference is small, but in more complex examples it’s not so simple.

Pros and cons I see are:
First approach:

  • Gives nice URLs to user

  • Always redirects after POST, so no confirm problem if user refreshes page

  • Only one method is responsible for filling renderArgs before calling
    template

  • Compile time verification that signUp method exits if it gets renamed

Second approach:

  • Faster, no redirect/round-trip in browser

So what is the best practice? Which approach to use use along the application?

  • 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-30T07:50:28+00:00Added an answer on May 30, 2026 at 7:50 am

    Let me go over your arguments:

    First:

    Gives nice URLs to user

    The URL can always be fine in Play 1.x. You can use the following:

    get  /signUp  myController.signUp
    post /signUp  myController.doSignUp
    

    So the first argument doesn’t matter.

    Second:

    Always redirects after POST, so no confirm problem if user refreshes page.

    I think if a user makes a mistake and press F5 or refresh with other technique it’s good if he get the same errors again. If the user should get the possibility to get a clean form, I prefer to have a cancel-button.

    Third:

    Only one method is responsible for filling renderArgs before calling template

    Can’t see the problem with render("@signUp");

    Fourth:

    Compile time verification that signUp method exits if it gets renamed.

    Ok, this is an argument but I think it’s weak. Will be false with play 2.0.

    So I think both approaches can be good, depending on the situation. Specially if you have a large form, the redirect won’t work. As default I would recommend the second solution.
    However, I don’t know how the situation with play 2.0 will be.

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

Sidebar

Related Questions

I'm implementing a interpreter-like project for which I need a strange little scheduling queue.
I am implementing some networking stuff in our project. It has been decided that
I'm implementing the TTThumbsViewController from the Three20 project and things are finally starting to
I am implementing a small database(university Project) and i am facing the following problem.
I am working on implementing Zend Framework within an existing project that has a
We have just completed implementing a successful but problematic project. We want to get
I'm implementing a simple Graph library for my uni project and since this is
I am implementing a bluepay payment gateway in my PHP project. I couldn't find
For part of a project I'm working on I am implementing a RTPpacket where
I'm currently working on a Google Maps project and am implementing a search function.

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.