gsp - Grails save method, doesn't recall method correctly if has error -


i have 2 method create new domain:

first 1 modified create() method, instead of respond subdomain created parameters in form (inside newsubdomain view), pass userdomainlist gsp can create select it.

def newsubdomain() {         def currentuser = springsecurityservice.getcurrentuser()          def domainlist = currentuser.domains //an hasmany domain user         def subdomain = new subdomain(params)         [subdomain: subdomain, domainlist: domainlist ]      } 

second 1 save() method

def savesubdomain(subdomain subdomain) {      if (subdomain== null) {         notfound()         return     }      if (subdomain.haserrors()) {         respond subdomain.errors, view:'newsubdomain'         return     }      subdomain.save flush: true          redirect(controller: "controller", action: "action")                } 

subdomain must have unique name, if create subdomain same name, want show error message on top of newsubdomain view, happens, when recall method passing error, doenst reload and/or pass "domainlist" cannot load select inside view.

this part of code of newsubdomain.gsp view

<g:haserrors bean="${this.subdomain}">         <ul class="errors" role="alert">             <g:eacherror bean="${this.subdomain}" var="error">                 <li <g:if test="${error in org.springframework.validation.fielderror}">data-field-id="${error.field}"</g:if>><g:message error="${error}"/></li>             </g:eacherror>         </ul>     </g:haserrors>       <g:form controller="subdomain " action="savesubdomain">          <f:field bean="subdomain " property="name"/>         <br>         <f:field bean="subdomain" property="domain">         <g:select name="domain"                   from="${domainlist}"                   optionkey="id"                   optionvalue="name"         />     </f:field>          <g:actionsubmit value="save sub domain" action="savesubdomain"/>     </g:form> 

what i'm doing wrong? dont know grails (or web applications in general) there's better way pass parameters view controllers? why when call newsubdomain view again when encounter error doesn't pass domainlist?

in newsubdomain, marshal data domainlist, , provide new subdomain newsubdomain view use.

in savesubdomain, method receives subdomain object. when errors found, savesubdomain controller method uses data has send user newsubdomain view -- savesubdomain method not have populated domainlist variable. view has no domainlist data show.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -