grails: how to properly edit/update a collection? -
I was wasting just half a day, trying to understand it, reading about some action, and thinking "It can not be so wrong - there should be a direct task to edit a collection in Grails, using scaffolded scenes or using your own."
Assume that I have This domain object is:
class treegroup {list of string names & lt; Tree & gt; Static hamney of the tree = ['tree': MyTree]} Just to explain the choice of data structure - I have a unique need for my record, but in order, I set this The reason that I chose the list, AFAIK can not rely on order in a set. So there are two pieces of this question - 1) How to remove from any collection, for example a set, 2) is the list of the best replacement for the set in this context (order protection).
I want to be able to create a group record and update 4 with a tree in it:
- Edit / Save < / Li>
- Edit group
- Add another tree
- remove b and c
And of course, After wanting the desired state. At present though, I can only add records, and if I save / edit the list then list elements are added to it.
I am using multiple selection tags for this. It looks like:
& lt; G: = "$ {allTrees}" option name = "tree" optionk = "id" multi = "true" class = "many-to-many" value = "$ {tree tree * .id: treeGroupInstance .. TTS * .IID} "/> And it's okay, it generates an HTTP header with these variables on the update:
_method: PUT Version: 19 Name: d5 Tree: 1 _action_update: Update But the data binder only adds new elements, it does not allow you to edit the list
The safest way to do this What is it? Is it a design defect of me, is not something obvious, or is it a Grails data binding (and hence, when / how it will be fixed)?
Is there a way to clear the list of hidden HTTP parameter elements (again)
thanks
Personal reconsideration (def domain object, string property name, class domainclose) {if (params [ PropertyName]! = Null {domainObject [propertyName] .clear () domainObject [propertyName] .addAll (params [propertyName] .collect {domainKlaz.get (it)}}}} And I'm calling the update controller method before saving it, copy For each collection, how OGM is unattractive.
Comments
Post a Comment