shopToUser.xhtml 3.6 KB
<!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:f="http://java.sun.com/jsf/core"
	xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:p="http://primefaces.org/ui" xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body>
	<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml">
		<f:metadata>
			<f:viewParam name="userid" value="#{userView.userid}" />
			<f:event type="preRenderView" listener="#{userView.initView}" />
			<f:event type="preRenderView" listener="#{productShopView.initShopView}" />
		</f:metadata>

		<ui:define name="title">
			<h1>#{i18n['user.shop.title']}</h1>
			<users:usertabs tabId="shop" />
		</ui:define>
		<ui:define name="content">

			<h:form id="shoppingcartform">
				<h:panelGrid columns="2">

					<h:panelGroup>
						<div id="shopItems">
							<ui:repeat value="#{productShopView.shoppingcart}" var="cart">
								<div class="shopItem">
									<h:commandLink action="#{productShopView.addOne}" value="#{cart.product.name}">
										<f:ajax render="@form" />
									</h:commandLink>
								</div>
							</ui:repeat>
						</div>

					</h:panelGroup>

					<h:panelGroup>
					
					<h:dataGrid >
					
					
					</h:dataGrid>
						<h:outputLabel value="#{i18n['shop.readBarcode']}" />
						<h:inputText id="barcode" value="#{productShopView.barcode}" />
						<h:commandButton action="#{productShopView.readBarcode}" onclick="blip(); return true;" value="#{i18n['productShopView.readBarcode']}">
							<f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" />
						</h:commandButton>

						<h:outputLabel value="#{i18n['shop.accountBalance']}" />
						<h:outputText value="#{productShopView.accountBalance}">
							<f:convertNumber />
						</h:outputText>

						<h:outputLabel value="#{i18n['shop.totalPrice']}" />
						<h:outputText value="#{productShopView.totalPrice}">
							<f:convertNumber />
						</h:outputText>

						<h:outputLabel value="#{i18n['shop.cash']}" />
						<h:inputText value="#{productShopView.cash}">
							<f:ajax render="@form" event="valueChange" />
							<f:convertNumber />
						</h:inputText>
					</h:panelGroup>




				</h:panelGrid>
				
				
				<h:outputText value="#{i18n['product.shopInstant']}" />
				<h:selectBooleanCheckbox value="#{productShopView.payInstant}">
					<f:ajax render="@form" execute="@form" />
				</h:selectBooleanCheckbox>

				<h:outputScript library="primefaces" name="jquery/jquery.js" />
				<div style="margin-top: 5px;">
					<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-top" value="#{cc.attrs.commitValue}" />
				</div>



				<div>
					<h:outputText value="#{i18n['productshop.total']} " />
					<h:outputText value="#{productShopView.totalPrice}">
						<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
					</h:outputText>
				</div>

				<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-botton" value="#{cc.attrs.commitValue}" />


			</h:form>
			<script>
				var blipSnd = new Audio(
						"#{request.contextPath}/resources/media/blip.mp3")

				$(function() {
					$("#shoppingcartform\\:barcode").focus();

				});

				function blip() {
					blipSnd.play();
				}

				function barcodeReadEvent(data) {
					if (data.status == "success") {
						$("#shoppingcartform\\:barcode").focus();
					}
				}
			</script>
		</ui:define>


	</ui:composition>

</h:body>
</html>