Commit 8df2b0e6 by Juho Salli

Tuotteiden varastoarvon lisays

1 parent cfb14754
package fi.insomnia.bortal.facade;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import fi.insomnia.bortal.model.InventoryEvent;
@Stateless
@LocalBean
public class InventoryEventFacade extends IntegerPkGenericFacade<InventoryEvent> {
public InventoryEventFacade() {
super(InventoryEvent.class);
// TODO Auto-generated constructor stub
}
}
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:f="http://java.sun.com/jsf/core"
>
<h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata>
<f:event type="preRenderView" listener="#{addInventoryView.initCreateInventory}" />
</f:metadata>
<ui:define name="content">
<products:addInventory />
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
<?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" xmlns:p="http://primefaces.org/ui">
<composite:interface>
</composite:interface>
<composite:implementation>
<h1>${i18n['inventory.product.title']}</h1>
<h:form id="inventoryform">
<h:panelGrid columns="2">
<h:outputText value="${i18n['inventory.product.name']}" />
<p:selectOneMenu required="true" id="product" value="#{addInventoryView.inventoryEvent.product}" converter="#{productConverter}">
<f:selectItem itemLabel="----" />
<f:selectItems value="#{addInventoryView.products}" var="product" itemLabel="#{product.name}" />
</p:selectOneMenu>
<h:outputText value="${i18n['inventory.product.quantity']}" />
<p:inputText value="#{addInventoryView.inventoryEvent.quantity}" required="true">
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</p:inputText>
<h:outputText value="${i18n['inventory.product.info']}" />
<p:inputTextarea value="#{addInventoryView.inventoryEvent.info}" />
</h:panelGrid>
<p:commandButton ajax="false" value="${i18n['inventory.product.submitButton']}" action="#{addInventoryView.save}" />
</h:form>
</composite:implementation>
</html>
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.beans.PermissionBeanLocal;
import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.InventoryEvent;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class AddInventoryView extends GenericCDIView {
private static final long serialVersionUID = 1L;
@EJB
private ProductBeanLocal pblocal;
@EJB
private PermissionBeanLocal permBeanLocal;
private InventoryEvent inventoryEvent;
private List<Product> products;
private static final Logger logger = LoggerFactory.getLogger(AddInventoryView.class);
public void initCreateInventory()
{
if (super.requirePermissions(ShopPermission.MANAGE_PRODUCTS) && inventoryEvent == null)
{
inventoryEvent = new InventoryEvent();
super.beginConversation();
setProducts(pblocal.findProductsForEvent());
logger.debug("Initialized {} products for inventoryview", products.size());
}
}
public String save() {
pblocal.saveInventoryEvent(inventoryEvent);
return null;
}
public List<Product> getProducts() {
return products;
}
public void setProducts(List<Product> products) {
this.products = products;
}
public InventoryEvent getInventoryEvent() {
return inventoryEvent;
}
public void setInventoryEvent(InventoryEvent inventoryEvent) {
this.inventoryEvent = inventoryEvent;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!