GSAN February 2016

The [method] action accepts a parameter of type [org...JSONObject] which has not been marked with @Validateable.

I am having this warning:

Warning |The [addPeople] action accepts a parameter of type [org.codehaus.groovy.grails.web.json.JSONObject] which has not been marked with @Validateable.  Data binding will still be applied to this command object but the instance will not be validateable.

   def addPeople(JSONObject jsonsito) {

If I change JSONObject for def, the warning dissapear. I am sure the reference is a JSONObject. I am doing this to avoid future PermGem error.

Anyone can explain how can I mark with @Validateable this OBJ?

Thanks in advance.

Answers


Jeff Scott Brown February 2016

Anyone can explain how can I mark with @Validateable this OBJ?

You can't. The JSONObject class is not part of your code so you don't get to make it @Validateable.

When a controller action accepts a parameter at compile time Grails generates a bunch of code for you. In summary, the generated code does the following:

  1. Create an instance of the class that the parameter is an instance of
  2. Subject the instance to data binding
  3. Subject the instance to dependency injection
  4. If the instance is @Validateable, then invoke .validate()
  5. Then your code in the method finally gets executed

Step 4 is conditional and will only happen if the object is @Validateable. In your case it won't be, which is fine. The warning is just letting you know that.

As a side note, the process described above is different if the parameter type is a domain class, String, one of the 8 primitive types or one of the 8 type wrappers. What I described above is how the system behaves for all other types.

Post Status

Asked in February 2016
Viewed 3,252 times
Voted 12
Answered 1 times

Search




Leave an answer