Hi,
I have been using Grails for last 3 weeks (learning and working). I have been working on porting a JSP/Servlet application to Grails and it has been absolute "fun" porting the application.
I have facing an issue and have been searching, reading but could not solve it yet.
In the GSP page I have a textfield and search button where user enters ProductID. I have a controller which is called from jQuery Ajax method when a search button is clicked.
// ----- Part of jQuery Ajax call --- $.ajax({ type : "post", url : '/${grailsApplication.metadata['app.name']}/product/checkProductAjax', data : "pid="+proID, // ----- Contoller code----- class ProductController { def scaffold = true def checkProductAjax = { def product= Product.findByProductId(params.pid) if(product) { [product: product] // model to get data in GSP page. render(product.toString() + ":" + product.id) } else { render("none") } } }
Ajax call and everything works fine. The problem I am facing is how to get the model (i.e. the Product data back to the GSP page i.e. [product: product] and display in GSP as for e.g. Product Name: ${product}
How can I get it working? I have read examples where it is mentioned that just setting the model [product: product] will help to get the data in GSP.
Product Name: ${product} always shows blank in the GSP page Product Name:
Please tell me what I am doing wrong.
Cheers! Jay Chandran