json - Spring mvc 3 Jqgrid :How to load data to a select Type from a list of objects -


i have 2 classes, user.java , bank.java . each user has reference bank. when add new user must select bank list of banks. question how load list of objects(from db) select form in jqgrid, , knowing selected data registered in db integer (the foreign key refer bank table), can tell me how goes.

@entity public class utilisateur {  @id @generatedvalue(strategy = generationtype.auto) private long iduser; .     . @autowired @manytoone private agence agence;  @manytoone private banque banque; 

and controller

@requestmapping(value = "/getall", method = requestmethod.get) public @responsebody customuserresponse getall() {      system.out.println("affichage");      list<utilisateur> users = utilisateurdao.getallusers();  list<banque> banks=utilisateurdao.getallbanks();       customuserresponse response = new customuserresponse();     response.setrows(users);      response.setrecords(string.valueof(users.size()));      response.setpage("1");      response.settotal("10");      return response; }       @requestmapping(value = "/add", method = requestmethod.post) public @responsebody customgenericresponse add(  @requestparam("nom") string nom, @requestparam("prenom") string prenom,         @requestparam("nomacces") string nomacces,         @requestparam("typeacces") typeacces typeacces,         @requestparam("motpasse") string motpasse,         @requestparam("banque") banque banque  ) {      logger.debug("received request add new user");      // construct our new user object. take note id not required.     // assign values parameters     utilisateur user = new utilisateur();      user.setnom(nom);     user.setprenom(prenom);     user.setnomacces(nomacces);     user.settypeacces(typeacces);     user.setmotpasse(motpasse);     user.setbanque(banque);     // custom validation here or in service      // call service add     boolean success = utilisateurdao.save(user); 

thanks.

if @ documentation on

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:predefined_formatter

they describe how can generate select event used in edit form.

ex: (as part of setup inside colmodel of bank column

formatter:'select', editoptions:{value:"1:one;2:two"}  

where id , names of banks values pass down. can have grid query controller build list well.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -