I'd like to ask for your advice with the following problem.
I have an entity representation in JSON that looks like this:
{
id: 1,
prop1: "someValue",
prop2: "someValue",
dynamicProperties: {
name1: "value1",
name2: "value2",
name3: "value3"
}
}
As you see, my entity has properties "prop1" and "prop2" which can take any value, and it also has a property "dynamicProperties" which can have a variable number of properties (e.g. "name1, "name2", "name3", and so on).
I want my users to be able to create/update/delete the property dynamicProperties. That is, it will be possible to add a new property "name4" with value "value4" and change the value of the property "name2" and/or delete the pair "name1"/"value1".
I initially thought about using Ext.grid.PropertyGrid in order to show the dynamicProperties. This allows me to edit the values of my properties, but it doesn't allow me to add new properties. By default, the name column of PropertyGrid is not editable and I haven't been able to change this.
is there a way to achieve what I am looking for?
The only alternative that I have thought of is to change my JSON representation to something like the following JSON and use a regular Ext.grid.Panel to manage it:
{
id: 1,
prop1: "someValue",
prop2: "someValue",
dynamicProperties: [
{
name: "name1",
value: "value1"
},
{
name: "name2",
value: "value2"
},
{
name: "name3",
value: "value3"
}
]
}
I don't like this approach because I would need to validate that the name must be unique, and maybe add an id property.
On the backend I use a Java Entity where the dynamicProperties is a HashMap like this:
@ElementCollection
@MapKeyColumn(name="name")
@Column(name="value")
@CollectionTable(name="entity_dynamic_properties", joinColumns=@JoinColumn(name="entity_id"))
private Map<String, String> dynamicProperties;
Thanks for your advice.