cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: default value from the modeler ?
Date Wed, 14 Apr 2010 19:00:05 GMT
Since you are using 3, you can create a callback in Cayenne Modeler.
When you select the ObjEntity (the Java portion) in CM, there is a
Callbacks tab.  Click on it and add a "post-add" callback.  You can
call it "initialize" or "initializeProductType" or something similar.
Then in your .java file, create a method like:


protected void initialize()
{
  setFoo(3);
}


You can look at this page for more information on callbacks (including
types of callbacks you can register):

http://cayenne.apache.org/doc30/lifecycle-callbacks.html


mrg


On Wed, Apr 14, 2010 at 1:00 PM, Arnaud Garcia <arnaud@imagemed-87.com> wrote:
> I use cayenne 3..
> Callback ? I need to check the doc, because I don't know how to use it...
>
> thanks for answer !
>
> arnaud
>
> 2010/4/14 Michael Gentry <mgentry@masslight.net>
>
>> Are you using Cayenne 2 or 3?  What you did is fine for Cayenne 2, but
>> in Cayenne 3 you can use a Callback method, too.  Also, there is
>> currently not a way in the modeler to set those initial values.
>>
>> mrg
>>
>>
>> On Wed, Apr 14, 2010 at 8:28 AM, Arnaud Garcia <arnaud@imagemed-87.com>
>> wrote:
>> > Hello,
>> >
>> > Is it possible to add default values using the modeler ?
>> >
>> > if not, the good way is to overide the setPersistenteState ?
>> >
>> > thanks,
>> >
>> > arnaud
>> >
>> > public class SomeObjEntity extends _SomeObjEntity
>> > {
>> >  public void setPersistenceState(int state)
>> >  {
>> >    super.setPersistenceState(state);
>> >
>> >    // if the object was just created, set initial values
>> >    if (state == PersistenceState.NEW)
>> >    {
>> >       // Set all initial values here
>> >    }
>> >  }
>> > }
>> >
>>
>

Mime
View raw message