grails - Reusing json/model object to avoid making extra calls to controller -


i've got groovy usercontroller , _listmyusers.gsp. _listmyusers.gsp using

 <g:dojoremoteform             formname="usersearchform"             id="usersearchform"             url="[controller:'user',action:'search']"             update="[success:'content']">  

the method in usercontroller (search) simple criteria builder returns following gsp, can use controls in gsp customize search criteria parameters (passed controller param.field_name):

    render (template:"listusers",             model:[                     users:users,                     usertypes:usertypelookup.list(),                     sortby:params.sortby,                     direction:nextdirection,                     currentdirection:sortdirection,                     pager:pager,                     organizations:orgs,                     usertype:usersearchtypes             ]) 

now works great , model used build out userslist table. problem comes in when click on 1 of users in results edit said users data, save. save completes , returns main listusers table. re-runs search method searchcriteria wild carded 'all' in selections (so users in db returned).
question is, how can preserve initial "custom" search returned when done editing user, original "search" still there ui users don't have go , re-do usersearch criteria again? thanks,

the grails cache plugin might here. cache output form search action, using user's query parameters method arguments (so can used keys cache).

@cacheable('searchresults') def search(string sortby, string sortdirection /* other parameters */)   {   // render output } 

then in save action, can use cacheevict annotation clear searchresults cache, search action return latest data:

@cacheevict(value='searchresults', allentries=true) def saveuser() {   //save user , return response code } 

see plugin documentation details on specifying items in cache evict, etc.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -