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: Collection of values, not only of entities?
Date Mon, 09 Mar 2015 11:04:33 GMT
Hi Marianne,

Yes, Isis only supports collections of entities or of view models.

One way to workaround this would be to store the collection of values in
some sort of large string property, and then have a derived collection of
view models that unpack it.

for example, if I wanted to have a collection of strings, eg:

"Apple"
"Pear"
"Orange"

then I could store this in a simple string property as a CSV, eg
"Apple,Pear,Orange"  (or use JSON or XML for something more sophisticated).

@Hidden
public String getFruitCsv() { ... }
public void setFruitCsv(String fruitCsv) { ... }

I can then define a view model:

@ViewModel
public class Fruit {

    private String name;
    @Title
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
}


Then, I could have a derived collection, something like:

@javax.jdo,annotations.NotPersistent
public List<Fruit> getFruits() {
    List<Fruit> fruits = new ArrayList<>();
    for(String fruitName = new Splitter(getFruitCsv()).on(",")) {
        fruit = new Fruit();
        fruit.setName(fruitName);
        fruits.add(fruit);
    }
    return fruits;
}


HTH
Dan



On 9 March 2015 at 10:33, Marianne Hagaseth <
Marianne.Hagaseth@marintek.sintef.no> wrote:

> Dear you!
>
> From
>
> http://isis.apache.org/config/metamodel-finetuning-the-programming-model.html
> ,
>
> it looks like it is not possible to have collection of values. Is this
> still true? Is there a (simple) walk-around for this?
>
> Best regards,
> Marianne Hagaseth.
>
>
>

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