I have an active object table created where I am able to add data. Now I am trying to retrieve all the data with this piece of code.
@Override public List<ProdConf> getAllProducts() { List<ProdConf> prodConfs = newArrayList(ao.find(ProdConf.class, Query.select())); for (ProdConf prodConf : prodConfs) { System.out.println("Name:" + prodConf.getProdName()); } return prodConfs; } //Action Command public String doManageProd() throws Exception{ prodConfs = prodConfService.getAllProducts(); for (ProdConf prodConf : prodConfs) { System.out.println(prodConf.getProductName()) } return "manageprod"; }
Now when I am using $action.prodConf.getProductName() , it is not showing any value. Please help.
Community moderators have prevented the ability to post new answers.
I guess that in you action you can have a method that returns prodConfService and then iterate objects in the velocity:
// action code: public ProdConfService getProdConfService() { return prodConfService; } in the velocity template: #set ($allProducts = $action.prodConfService.getAllProducts()) #foreach ($product in $allProducts) $product.getProdName() #end
Other approach is to have in your action a method that returns collection of objects and similarly access this method from a template.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.