isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Haywood <...@haywood-associates.co.uk>
Subject Re: Boolean properties, setting a default value
Date Fri, 27 May 2016 17:27:11 GMT
If you don't want null Booleans, use boolean primitive instead.

With respect to default values, I don't think that the Isis metamodel looks
at the JDO @Column#defaultValue, no.  But you can specify a default value
in a couple of ways.

Assuming:

private boolean myFlag;
public boolean isMyFlag() { return myFlag; }
public void setMyFlag(boolean myFlag) { this.myFlag = myFlag; }

then you could (a) use a defaultXxx supporting method:


public boolean defaultMyFlag() { return true; }


or using a created() callback:

public void created() { setMyFlag(true); }

or (simplest) just setting the field to true:

private boolean myFlag= true;


Let us know if those work/don't work.

Thx
Dan



On 27 May 2016 at 13:52, Stephen Cameron <steve.cameron.62@gmail.com> wrote:

> Hi
>
> I am wondering if its possible to make Boolean properties non-null and have
> a default value via JDO @Column annotations, e.g.
>
> @Column(allowsNull = "false", defaultValue = "true")
>
> Thus in the UI I have only true or false as options?
>
> At the moment the defaultValue seems to be ignored.
>
> Thanks
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message