java - How to Remove Duplication from Spring 3 MVC Standard and Ajax Request Controllers and Views -


lately i've been running same issue spring mvc applications on , on again, , i'm trying come long term solution.

the problem in standard spring 3 controller, add model objects, specify view name (either inline or injected field) , return. problem i've run if have request returns page person, , pets have (not compilable, psuedo):

@requestmapping( value="personoverview", method="get" ) public string getpersonoverview(model) {     model.add(personrepo.getperson( thename ));     model.add(petrepo.getpetsforperson( theperson ));      return "personoverviewviewname"; } 

now, in view able render of information. however, issue arises when updates "pets" person, , want re-render part of page shows pets.

not need rewrite rendering logic in jsp fragment or in javascript, need duplicate controller code each portion of getpersonoverview method. if break controller methods smaller chunks, not able render full page, have render each chunk separate request.

in normal modelviewcontroller pattern, solution view has access model, in spring mvc model in java , lies behind request layer, need build request handlers each model object.

i know question may seem bit abstract, i'm looking patterns or principles can used allow me build full pages many model objects, able update portions of page ajax without duplication.

not used myself, have considered tiles?


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -