<p>I have a domain class containing a couple of fields. I can access them from my .gsps. I want to add a method to the domain class, which I can call from the .gsps (this method is a kind of virtual field; it's data is not coming directly from the database).</p>

<p>How do I add the method and how can I then call it from the .gsps?</p>

To add a method, just write it out like you would any other regular method. It will be available on the object when you display it in your GSP.
```
```
def someMethod() {
  return "Hello."
}
```
```
Then in your GSP.
```
```
${myObject.someMethod()}
```
```