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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:39:53+00:00 2026-05-31T00:39:53+00:00

I have some issue with validation of parameters passed to a controller method. Following

  • 0

I have some issue with validation of parameters passed to a controller method.

Following the suggestion from the tutorial, I am using the same controller method for “save” and “create new” of an entity. See example in
http://www.playframework.org/documentation/1.2.4/guide9

So, my controller method looks like:

public static void saveEntity(long l, Long itemId,  
  @Required(message="error.shouldspecifyname") String name, 
  @Required(message="error.shouldspecifycategory")  String category)

If ‘itemId’ is not part of the data sent via an HTTP request – it is supposed to be set to ‘null’.

Unfortunately, it seems like “Play” is automatically adding a validation error on the “missing” parameter.

When looking into the validation errors’ list, every time ‘itemId’ is ‘null’ – I am getting an error Incorrect value for field itemId

Is it a documented behavior? Any way to override it, or “get rid” of the error.

I am handling the errors simply using redirection, like:

if(validation.hasErrors() ) 
{

            validation.keep();
            showSomePage();         
}

So the errors are displayed “out of the context” they get generated. This is the reason the “automatic” error bothers me.

Thanks for any hint.

  • 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-31T00:39:54+00:00Added an answer on May 31, 2026 at 12:39 am

    Most likely it fails to validate itemId because it’s declared as Long, are you sure you have “Long” there ant not just “long”? We are using validation with controllers every where and it works with @Required and passed “null” to “Long” values.

    Worst case you can remove error from validation object based on “itemId” key, also if you’re using controller to save model object, you might want to use:

    public static void saveEntity(@Required @Valid MyEntity entity) {
    if(validation.hasErrors() ) {
      validation.keep();
      showSomePage();         
    }
    entity.save();
    }
    

    It will automaticly hook your changes inside existing entity if you pass ID from page with:

    <input type="hidden" name="myEntity.id" value="${myEntity.id}">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some strange issue using jQuery Validation plugin. Firs of all here is
I have an issue with System.Threading.Timer. I am scheduling some actions using a time
I'm using XPreformatted to print some preformated text and I have an issue with
I have some issue with a Perl script. It modifies the content of a
I have some unsolved issue with threads. It's my first time doing it. I
i have an issue i could use some help with, i have python list
I have a design issue that I would appreciate some input on. I would
I'm working on some screen scraping software and have run into an issue with
We're having a small issue and could use some help - we have the
I have a few input fields in a form which are submitted using Save

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.