Page 1 of 1
How to get review object in prodcut list item template?
Posted: Fri Jun 06, 2014 10:15 am
by gowthamgutha
I would like to get the review object in the productListItem template. I would like to know how could I do it.
Also, how could I the objects I want to the template page i want? I haven't found (or may be haven't understood) how to do this in the Broadleaf docs.
Thanks in advance.
Re: How to get review object in prodcut list item template?
Posted: Fri Jun 06, 2014 10:31 am
by phillipuniverse
The short answer is that you add attributes to the model (Model parameter in a Spring MVC controller) and then those objects are available to you within your Thymeleaf templates. There are other facilities that you can use to deal with variables in Thymeleaf and there are also more ways to load and deal with dynamic data straight from the template. For instance, ContentProcessor (Broadleaf class) adds a piece of StructuredContent on to the model. You invoke that processor from the view layer and then do things with the result. There is also a concept of Variable Expressions that also do dynamic things from your templates.
In general, this is really more of a Thymeleaf question. Their docs are very extensive and very good:
http://www.thymeleaf.org/doc/html/Using-Thymeleaf.htmlYou might specifically want to read up on
http://www.thymeleaf.org/doc/html/Thyme ... ring3.html which goes over things like model objects and forms.
Re: How to get review object in prodcut list item template?
Posted: Sun Jun 08, 2014 2:17 am
by gowthamgutha
In which controller should I add the model attributes?
Thanks in advance.
Re: How to get review object in prodcut list item template?
Posted: Mon Jun 09, 2014 1:40 pm
by phillipuniverse
Since you need this in productListItem.html, you want this attribute to follow everywhere that you are displaying the product in a list. Since this will likely be multiple places, you probably don't want to put it in the controller and instead use a Thymeleaf Process within productListItem.html itself. Look at ContentProcessor and you can see how we are doing that with Structured Content.
Re: How to get review object in prodcut list item template?
Posted: Sat Oct 11, 2014 1:34 am
by angel10
very good post..........