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)
}
Quick example
def update(){
def albumInstance = Album.get(params.id)
albumInstance.properties = params
albumInstance.save(flush:true)
redirect(action: "show", id: albumInstance.id)
}
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>