shopToUser.xhtml 2.85 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:panelGrid columns="2">

						<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:panelGrid>
					<h:panelGroup>
						<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:panelGroup>


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

				<products:shop
					commitaction="#{productShopView.commitShoppingCart()}"
					items="#{productShopView.shoppingcart}"
					commitValue="#{i18n['productshop.commit']}" />
			</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>