How do you use a String array as a member field in a Grails domain?

I am trying to create a basic grails domain object, and for one of the fields I want to use an array of strings. However, even after running grails generate-views, I still don't see the ability to edit this array. Am I going to do it wrong?

+3
source share
1 answer

If you run "grails install-templates", you can edit src / templates / scaffolding / renderEditor.template, where HTML generation for editors is defined. Add to the new "else if" for String []:

else if (property.type == String[].class)
    out << renderStringArrayEditor(domainClass, property)

and implement renderStringArrayEditor, but you think the best is:

private renderStringArrayEditor(domainClass, property) {
...
}

, HTML , \n. , , String .

"grails generate-all" "grails generate-views", "grails generate-views" GSP .

+4

Source: https://habr.com/ru/post/1731972/


All Articles