mardi 4 avril 2017

Grails read from one domain to another domain

I created 2 domain class which is

Duty.groovy:

    class Duty {
               String username
               String duty
    }

User.groovy:

    class User {
               String username
    }

I already assigned some users in Bootstrap.groovy, I want to create a duty list function to assigned duty to users. So in my duty list, it should include a drop-down list which contains list of users from User domain.

But when I import testApp.User at my gsp file and created a taglib to display the userlist, my compiler shows that No such property. I would like to ask for suggestions for best way to display the list of users or any idea for debug my code?

Here is other code: SelectUserTagLib.groovy

    import HR_System.User
    def userInstance = new User()
    def displayType = { attrs,body -> 
    def name = attrs.name 

    out << "<select id=\"${name}\" name=\"${name}\" require=\"\" >"
    out << "<g:each in='${userInstanceList}'' status='i' var='userInstance'>"
    out << "<option value=\"${name}\">${fieldValue(bean: userInstance, field: "username")}</option>"
    out << "</g:each>"
    out << "</select>"
}

_form.gsp:

    <name:displayType name="username" />




Aucun commentaire:

Enregistrer un commentaire