Francesco Galgani
Francesco Galgani

Reputation: 6249

Store arbitrary object in a PropertyBusinessObject

This question is specific for Codename One.

Is it possible to store any arbitrary object in a PropertyBusinessObject? In the examples in the developers guide and in the Codename One blog I found only Strings, Numerics and Dates. What do I have to do to store inside a User PropertyBusinessObject a new class created by me?

For example, suppose that I need to associate a User with a Sport object (that is a POJO with several attributes) and the Sport object contains a Team object (that is another POJO).

Upvotes: 1

Views: 45

Answers (1)

Shai Almog
Shai Almog

Reputation: 52770

Right now the builtin support is for PropertyBusinessObject to reference other PropertyBusinessObject instances so Team or Sport shouldn't be POJO's but rather PropertyBusinessObject instances.

Having said that it's still useful to be able to work with other objects. E.g. I might want to store the Location object or an Image (we do use EncodedImage in some cases). The theoretical syntax is identical:

public final Property<MyObject, ParentClass> prop = new Property<>(MyObject.class);

The problem with this is the word "store".

We need an API that will map such objects to JSON/Map/Database etc. and that API just wasn't defined yet. It should be a relatively simple interface we just didn't define it yet. There are a few RFE's in the queue for 5.0 related to properties, I'm not sure if one of them covers this.

Upvotes: 1

Related Questions