
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
Hi Pam,
Yes you can override any property getter
for a class in the usual groovy/java way.
There are several ways you can create a
default value for a property directly in the grails GORM class:
/** implicit virtual initializer */
class MyDomainObj {
String myProp = “aDefault”
}
/** explicit virtual initializer */
class MyDomainObj {
String myProp
{
myProp = “aDefault”
}
}
For your function that starts with ‘get’,
there is no requirement that you have a corresponding property. The JavaBean
conventions are that if you have a method that follows the pattern:
public <return value> getXXX()
then it will be considered to be the readable
property XXX of type <return value>.
Jay Guidos
From: Callaway, Pamela
[mailto:pcallaway@...]
Sent: Thursday, May 15, 2008 9:26 AM
To: user@...
Subject: [grails-user] Can I
over-ride the getProperty function?
Hi
folks,
Is
it possible to over-ride a property “getter” for a class?
Or
should I use a constructor or something to fill up a particular property, if it
doesn’t come directly from the database?
Also,
I noticed I have one function that starts with get, even though I don’t
have a corresponding property, and it still gets created/shown as a property in
the view. Interesting – is there a reason for that?
Thanks,
Pam