Commit 60612ba4 by Juho Juopperi

lippukauppajutukkeita

1 parent cb7734cf
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.insomnia.bortal.facade.ProductFacade;
import fi.insomnia.bortal.model.Product;
/**
* Session Bean implementation class ProductBean
*/
@Stateless
public class ProductBean implements ProductBeanLocal {
@EJB
ProductFacade productFacade;
/**
* Default constructor.
*/
public ProductBean() {
// TODO Auto-generated constructor stub
}
@Override
public List<Product> listUserShoppableProducts() {
// XXX: Only user shoppable products
return productFacade.findAll();
}
}
package fi.insomnia.bortal.beans;
import java.util.List;
import javax.ejb.Local;
import fi.insomnia.bortal.model.Product;
@Local
public interface ProductBeanLocal {
List<Product> listUserShoppableProducts();
}
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form>
<h:dataTable border="1" id="productListTable"
value="#{productView.userShoppableProducts}"
var="product">
<h:column>
<f:facet name="header">
<h:outputText value="#" />
</f:facet>
<h:outputText value="#{product.id}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.name']}" />
</f:facet>
<h:outputText value="#{product.name}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{i18n['product.price']}" />
</f:facet>
<h:outputText value="#{product.price}" />
</h:column>
</h:dataTable>
</h:form>
</composite:implementation>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:shop="http://java.sun.com/jsf/composite/tools/shop"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition template="/layout/default-template.xhtml">
<ui:define name="title">Omnia</ui:define>
<ui:define name="header">Lippukauppa</ui:define>
<ui:define name="content">
</ui:define>
<shop:productlist />
<ui:define name="footer">Osta liput</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.view;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.beans.RoleBeanLocal;
import fi.insomnia.bortal.beans.SecurityBeanLocal;
import fi.insomnia.bortal.exceptions.PermissionDeniedException;
import fi.insomnia.bortal.handler.SessionHandler;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.Role;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author jkj
*/
@ManagedBean(name = "productView")
@SessionScoped
public class ProductView {
@ManagedProperty("#{sessionHandler}")
private SessionHandler sessionhandler;
@EJB
private ProductBeanLocal productBean;
private static final Logger logger = LoggerFactory.getLogger(ProductView.class);
@EJB
private SecurityBeanLocal securitybean;
public DataModel<Product> getUserShoppableProducts() {
ListDataModel<Product> items = new ListDataModel<Product>(productBean.listUserShoppableProducts());
logger.info("Fetching products. Found {}", items.getRowCount());
return items;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!