I want to print all my products in a table on a JavaServer page but I have troubles with my jstl code.
My Model product:
public final class Product
{
private int id;
private String description;
private Double price;
private String categoryName;
...
My JavaBean products: (when this bean is created it's filled with products from my model)
@ManagedBean(name = "productsBean")
@RequestScoped
public class Products implements Serializable {
private List<Product> producten;
@ManagedProperty(value = "#{applicationBean}")
private ApplicationBean applicationBean;
public Producten() {
Store store = applicationBean.getStore();
for (String c : store.getCategories()) {
for(model.Product p : store.getProductsOfCategory(c)){
beans.Product product = new Product();
product.setId(p.getId());
product.setDescription(p.getDescription());
product.setCategoryName(p.getCategoryName());
product.setPrice(p.getPrice());
producten.add(product);
}
}
}
My JavaBean Product:
@ManagedBean(name= "productBean")
@RequestScoped
public class Product implements Serializable{
@ManagedProperty(value = "#{applicationBean}")
private ApplicationBean applicationBean;
private int product_id;
private String description;
private Double price;
private String categoryName;
In my JavaServer Page I want something like that but:
<c:forEach var="product" items="${productsBean.products}">
<tr>
<td>${product.description}</td>
</tr>
</c:forEach>