Share on Google+Share on Google+

william maidl granzotto
How to create dynamic buttons for adding products on a cart.
0 Answer(s)      5 years and 2 months ago
Posted in : Java Server Faces Questions

Hi. I have some problems creating a page to add items into a cart. The page loads dynamic products from a database, and i would like to know how to group this products so that when i click a button, my CartBean gets updated by that product clicked.

here, my xhtml page.

<h:body style=" background-color: #eeeeee">
    <div id="content" align="center">
        <!-- Division containing the top content-->
        <div id="top">
            <table width="70%">
                <tr valign="center">
                    <td align="left">
                        <c:if test="${login.login}">
                            Bem vindo <b>${login.name}</b>, boas compras.
                        </c:if>
                    </td>
                </tr>
                <tr>
                    <td>
                        <h:form>
                            <h:commandButton value="LOGO"/>
                            <h:inputText id="searchTxt" size="50" value="#{searchEngine.searchWord}"/>
                            <h:commandLink id="searchBtn" action="buscar" actionListener="#{searchEngine.searchMethod}">
                                <h:graphicImage url="resources/lupa1.jpg" style=" vertical-align: bottom"/>
                            </h:commandLink> 
                            &nbsp;
                            <h:commandLink value="Sobre Nós" action="index"/>
                            &nbsp;|&nbsp;
                            <h:commandLink value="Fale Conosco" action="contato"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <h:commandLink value="Criar Conta" action="cadastro"/>
                            &nbsp;|&nbsp;
                            <h:commandLink value="Login" action="login"/>
                        </h:form>
                    </td>
                </tr>
            </table>
        </div>
        <!-- Division containing the main table -->
        <div id="table">
            <table width="70%">
                <tr>
                    <td bgcolor="#999999" style="width:20%">
                        <h1><font color="#cccccc">Categorias de Produtos do Site</font></h1>
                    </td>
                    <td bgcolor="#333333" style="width:60%; vertical-align: bottom">
                        <font color="#ffffff">
                            Resultados da busca por '${searchEngine.lastSearch}'</font>
                    </td>
                    <td bgcolor="#eeeeee" style="width:20%">
                        The right side
                    </td>
                </tr>
                <tr>
                    <td valign="top" bgcolor="#333333">
                        <div id="demo">
                            <p><a href="#" class="eletronicos">Eletrônicos</a></p>
                            <p><a href="#" class="cameras-filmadoras">Câmeras e Filmadoras</a></p>
                            <p><a href="#" class="celulares">Celulares</a></p>
                            <p><a href="#" class="informatica">Informática</a></p>
                            <p><a href="#" class="perfumaria">Perfumaria</a></p>
                        </div>
                    </td>
                    <td bgcolor="#ffffff" valign="top">
                        <p>A busca pelo termo '${searchEngine.lastSearch}' retornou a seguinte relação de produtos, em ordem alfabética:</p>
                        <c:forEach items="${searchEngine.products}" var="product">
                            <table align="center" width="95%">
                                <tr bgcolor="#eeeeee">
                                    <th colspan="2" align="left"><b>${product.name}</b></th>
                                </tr>
                                <tr>
                                    <td width="35%">
                                        <h:graphicImage url="products/${product.url}"/>
                                    </td>
                                    <td width="65%">
                                        <p><font color="#DD0000" size="3">R$ ${product.inCash} à vista</font></p>
                                        <p><font color="#DD0000" size="5">${product.instalments} X <font size="7">${product.paymentDeadline}</font></font>
                                            <h:form>
                                                <h:commandButton action="#{carrinho.add(product.name)}" value="adicionar"/>
                                            </h:form>
                                        </p>
                                    </td>
                                </tr>
                            </table>
                        </c:forEach>


                    </td>
                    <td bgcolor="#ffffff" valign="top">
                        Caso não encontre os produtos desejádos, mande-nos um e-mail e entraremos em contato.
                    </td>
                </tr>
            </table>
        </div>
        <div id="bottom">
            <table>
                <tr>
                    <td>
                        <p>Logo Inferior</p>
                        <p><font size="2">&copy; 2012 Loja de Importados</font></p>
                    </td>
                    <td>
                        <h:form>
                            <h:commandLink value="Sobre Nós" action="contato"/>
                            &nbsp;|&nbsp;
                            <h:commandLink value="Fale Conosco" action="contato"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <h:commandLink value="Criar Conta" action="cadastro"/>
                            &nbsp;|&nbsp;
                            <h:commandLink value="Login" action="login"/>
                        </h:form>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</h:body>;

Ads

View Answers









Related Tutorials/Questions & Answers:
How to create dynamic buttons for adding products on a cart.
How to create dynamic buttons for adding products on a cart.  Hi. I have some problems creating a page to add items into a cart. The page loads dynamic products from a database, and i would like to know how to group this products
How to prevent adding duplicate items to the shopping cart
How to prevent adding duplicate items to the shopping cart  ...;?php session_start(); if (!isset($_SESSION['SHOPPING_CART'])){ $_SESSION['SHOPPING_CART'] = array(); } if (isset($_GET['itemID']) && isset($_GET
Advertisements
Shopping Cart Products
Know To Sell The Right Products On E-Commerce Shopping Cart E-commerce... to be wary of your competitors who are selling the same products too. How... as this is the fastest way of shopping and shipping products to customers. Many online
How to create dynamic array in C?
How to create dynamic array in C?  How to create dynamic array in c programming language?   Dynamic Array in C Tutorial
How to Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
adding buttons - Swing AWT
adding buttons  can u plzz explain how to add button to a dialog box and make them perform some event on the image loaded on the panel
adding buttons - Swing AWT
adding buttons  can u plzz explain how to add button to a dialog box and make them perform some event on the image loaded on the panel
creating dynamic buttons in iphone
creating dynamic buttons in iphone  i Have a UIView and i wanted to create a multiple buttons to that should come on view load. It will be great if that can be removed after sometime or required time.   -(void
To create a shopping cart
To create a shopping cart  I want to create a online shopping cart..., how to retrieve the data from the database by creating a single table for different products as mentioned above. Hope someone will help me out. thnx
how to create directed line between two buttons when i clicked there
how to create directed line between two buttons when i clicked there  Hi I have to create a topology between 6 nodes. 6 nodes are created as 6 buttons and when i clicked in first button and then on second button a directed
how to create a dynamic website - Servlet Interview Questions
how to create a dynamic website  create a dynamic website of a topic of your choice. Web technologies to be used should include: HTML, JavaScript, Applets, Serverlets, and Database.  Hi friend, employee form
create dynamic array in javascript
create dynamic array in javascript  How to create dynamic array in javascript
Create Multiple Buttons
Create Multiple Buttons using Java Swing       In this section, you will learn how to create multiple buttons labeled with the letters from A to Z respectively. To display them, we
create dynamic image gallery jquery
create dynamic image gallery jquery  How to create a dynamic image gallery in Jquery
Create dynamic page through JSP
how to create dynamic page. This code shows one by one record of student from... Create dynamic page through JSP..., application fetch next record from database. Create a database :  Before
How to Create Animated Main Menu Application with Java Swnig Buttons - Java Beginners
How to Create Animated Main Menu Application with Java Swnig Buttons  Hello sir I want to display Main Menu after Log in i have created Log in Form but I want More attractive Animated Main Menu which includes Following
Create Dynamic Table using Hubernate
Create Dynamic Table using Hubernate  Thank's for reading my Post. I...: How to create seperate table for all users they sign up for my web app. i need... files but i done create and update for a single table. i dono how to automate
how to add dynamic data
how to add dynamic data  how to add dynamic data to an existing web application
Shopping cart
Shopping cart Overview A web based shopping cart is something like the original grocery shop shopping cart that is used by the customer in selecting certain products. Finally after selection the customer confirms orders
Shopping Cart
Shopping Cart In this section we will discuss about shopping cart and how you... of the easiest way to sale products, you have to setup shopping cart application, add your... the shopping cart, we will also see how to setup a shopping cart website for selling
What is shopping cart?
and much more. How a shopping cart works? A shopping cart software is dynamic web... shopping cart software for selling their products online. What is shopping...? AAdmin panel provides the UI for managing the shopping cart products, price
How can combine threads and buttons?
How can combine threads and buttons?  I would like to start an application, stop it and restart it again and stop etc. I tried the following code... TestActionEvent(); frame.setTitle("Two buttons
how to upload and download images using buttons in jsp?
how to upload and download images using buttons in jsp?  how to upload and download images using buttons in jsp
i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation
i want to create dynamic calendar in java
i want to create dynamic calendar in java  i want code and explanation
Choosing the Best Ecommerce Shopping Cart
Choosing the Best Ecommerce Shopping Cart In this articles explains you how to choose the best ecommerce shopping cart for your next online shopping portal...-friendly shopping cart software for selling the products online.  
Buttons
Buttons  I have created a web page with radio button group with two radio buttons for accepting the home appliances categories,Kitchen appliances and other appliances.I want to check for the appliance chosen when the required
how to write a query for adding records in database
how to write a query for adding records in database  How write fire query in JSP for adding records in database
how to display a table and buttons in swings - Java Beginners
how to display a table and buttons in swings  Hi frends, Actually... different buttons below this displayed table using swings.....please can any... the table and iam not getting buttons below the table......... Thanking you
how to insert value in dynamic table
how to insert value in dynamic table  i am creating a project in Training and Placement.i have a created a company register part where i create a dynamic table for every company.but whenever i'm inserting values to the company
Cart Quantity
Cart Quantity  How to increase and decrease quantity from a cart using session in jsp and sevlet
Tutorials   
Java Spring Hibernate Struts Training i have an ques. of advanced java commandlink tag in primefaces needs onclick effect how can i run ASP.Net Server from netbeans IDE? java code for cursor java vertual machine launcher error; cannot access jarfiles JSF Tutorial render in input typetext java.lang.ClassNotFoundException: com.sun.faces.config.ConfigureListener After authentication and connection establishment, Upload a zipfile by chunks in java JSF CONNECTION WITH MICROSOFT ACCESS Download Current Web Page As PDF java servlet dropdown list in jsf panelGrid header do the following how to make drop down list in JSF & fetch data Item from database help me please doubt regarding JSF Creating Dynamic Tree How to upload zip file from android to server programmatically????? jsf application war file not running in my jboss 6.0 on linux 5.5 Business analysis servlet servlet exception in thread main while running servlet How to get browser time zone? JAVA Socket Programming excel report fro jsp mysql Redirect to same jsp page on successful login jsf f:parm value dynamical settings jsf f:parm value dynamical settings RMI Program in netbeans pagination in jsf pagination jsf pagination How create csv format in jsf ? need JSP Code. Arrays, loops and string handling unique value renderer JSF 1.2 online tutorial JSF code JSP jps Multicast under UDP(client server application) How to rectify "Bad version number in .class file" exception in Eclipse about avl tree and hashing project on avl tree and hashing How to navigate from one jsf to another in eclipse how to focus on the new window opened from JSF ? Editing UI components using managed bean

Ads

 
Advertisement null

Ads