Grails method update, instance.properties = params

1

What is the properties method for?

Quick example

def update(){
  def albumInstance = Album.get(params.id)
  albumInstance.properties = params
  albumInstance.save(flush:true)

  redirect(action: "show", id: albumInstance.id)
}
    
asked by Luis Zayas 10.02.2017 в 00:02
source

1 answer

0

What are properties ?

A property is the combination of one or more fields or variables of a class in Groovy and their respective methods getters (to obtain said variable) and setters (to assign value to that variable). These getters and setter do not apply if the variables were declared as final .

I'll give you an example:

class Book {
    int id
    String name                                                              
}

In this example, both id and name are properties or properties of class Book .

Now, in the code you are modifying albumInstance , assigning all the properties ( properties ) with the value of params .

You can expand a little more on the topic here .

p>     
answered by 10.02.2017 в 04:14