Grails controls the scaffold of the query scope

Source: Internet
Author: User
Tags min grails
Generated by scaffold in Customercontroller
Java code   static allowedproperties = [' name ',  ' address ',  ' telephone ',  ' Postcode ']      def list = {       params.max  = math.min (Params.max ? params.int (' Max ')  : 10, 100)         def customerInstanceList, customerInstanceTotal        if (params?). Searchvalue && allowedproperties.contains (params?). Searchkey))  {           def c =  Customer.createcriteria ()            customerinstancelist  = c.list (max: params.max, offset: params.offset?:0)  {               ilike ( params.searchkey,  "%"  + params.searchValue +  "%")      &nbsP;         eq ("deleted",  false)             }            customerinstancetotal = customerinstancelist.totalcount       }  else {           customerInstanceList =  Customer.findallbydeleted (false, params)             Customerinstancetotal = customer.countbydeleted (false)        }        [customerinstancelist: customerinstancelist, customerinstancetotal:  customerInstanceTotal]  }  

The corresponding controller-scaffold sections are:
Java code   <%       excludedprops = event.allevents.tolist ()   <<  ' id '  <<  ' version '  <<  ' dateCreated '  <<  ' LastUpdated '  <<  ' deleted '  <<  ' Itemorder '  <<  ' Memo '        allowedNames = domainClass.persistentProperties*.name        props = domainclass.properties.findall { allowednames.contains (It.name)  && !excludedprops.contains (It.name)  && ! Collection.isassignablefrom (It.type)  }       collections.sort (props,  Comparator.constructors[0].newinstance ([domainclass] as object[])         def propNames = []       props.name.each {propnames.add   "'" +it+ "'"}  %>   STATIC&Nbsp;allowedproperties = <%=propnames %>      def list =  {       params.max = math.min (params.max ? params.int (' Max ')  : 10, 100)        def ${propertyname}list, ${ propertyname}total       if (params?). Searchvalue && allowedproperties.contains (params?). Searchkey))  {           def c = ${ Classname}.createcriteria ()            ${propertyname}list  = c.list (max: params.max, offset: params.offset?:0)  {               ilike ( params.searchkey,  "%"  + params.searchValue +  "%")                  EQ ("deleted",  false)            }            ${propertyname}total = ${propertyname}list.totalcount        } else {            ${propertyname}list = ${classname}.findallbydeleted (false, params)             ${propertyname}total = ${classname}.countbydeleted (False)        }       [${propertyname}list: ${ propertyname}list, ${propertyname}total: ${propertyname}total]  }  

The list page is generated by scaffold
Java code <g:form action= "list" method= "POST" usetoken= "true" > <g:select name= "Searchkey" from= "${customerco Ntroller.allowedProperties.toList ()} "value=" ${searchkey} "optionvalue=" ${{message (code: ' Customer. ') +it+ '. Label ', Default:message (code: ' DomainProperty. ') +it+ '. Label ', Default:it)}} "/> <input type=" text "name=" Searchvalue "value=" ${params?. Searchvalue} "/> </g:form>

The corresponding scaffold-list sections are:
Java code <g:select name= "Searchkey" from= "\${${domainclass.fullname}controller.allowedproperties.tolist ()}" value = "\${searchkey}" optionvalue= "\${{message (Code: ' ${domainclass.propertyname}. ') +it+ '. Label ', Default:message (code: ' DomainProperty. ') +it+ '. Label ', Default:it)}} "/>

i18n Append
Java code domainproperty.name.label= name ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.