You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jussi isokangas <ju...@gmail.com> on 2011/01/13 09:39:47 UTC

Fwd: How to invite Shopping cart method in product site

Hi,

How can i  invite Shopping cart method which adds a wanted product to  Cart
in product site? How I refer from product class for this button?

Here is my product site and class.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <wicket:extend>
    <h1>Jaakiekko</h1>

        <p>
            <table id="taulukko" >
              <tr>
                <th>id</th>
                <th>tuoteryhma</th>
                <th>nimi</th>
                <th>hinta</th>
                <th>alv</th>
                <th>kpl</th>
              </tr>
              <tr wicket:id="jääkiekko">
                <td wicket:id="id">id-123</td>   <li><a href="#"
wicket:id="ostoskori">Lis&aauml; koriin</a></li>
                   <td wicket:id="tuoteryhma">jaakiekko</td>
                <td wicket:id="nimi">maila</td>
                <td wicket:id="hinta">4</td>
                <td wicket:id="alv">23</td>
                <td wicket:id="kpl">1</td>
              </tr>  *Here button which add product to cart*
            </table>
        </p>

     </wicket:extend>





public class Jaakiekko extends Sivupohja {

      @SuppressWarnings("unused")
      private static final Log log =
          LogFactory.getLog(Jaakiekko.class);
      private static final long serialVersionUID = 1L;

      @SpringBean(name = "verkkokauppaPalvelu")
      private Verkkokauppapalvelu palvelu;

      /**
       * Konstruktori, jokaa hakee halutun tuoteryhmän palvelun avulla
       * ja muuntaa tulokset Wicketin web-malliksi.
       *
       * @param sivunParametrit
       */
      public Jaakiekko(
          final PageParameters sivunParametrit) {
        super(sivunParametrit);

        // Haetaan palvelulta kaikki tuotteet
         Collection<Tuote> jaakiekko =
            palvelu.haetuoteRyhmanMukaan("jääkiekko");
        //add(new Label("kokonaismaara", String
          //  .valueOf(jaakiekko.size())));

        // Luodaan komponentti, jonka sisältö toistuu useita
        // kertaa web-sivulla.
        RepeatingView tuotteetView = new RepeatingView("jääkiekko");
        // Lisätään komponentti osaksi koko web-sivun rakennetta
         add(tuotteetView);

        // Iteroidaan tulosten läpi ja muunnetaan tiedot sopivaan
        // muotoon.
        Iterator<Tuote> tuoteiter = jaakiekko.iterator();
        while (tuoteiter.hasNext()) {

          // Lisätään kutakin riviä varten html-merkkausta
          // sisältävä komponentti.
          WebMarkupContainer item =
              new WebMarkupContainer(tuotteetView.newChildId());
          tuotteetView.add(item);

          // Haetaan seuraavan tuotteen tiedot iteraattorilta.
          Tuote tuote = tuoteiter.next();

          // Lisätään yksittäisen tuotteen tiedot osaksi sivun
          // mallia Label-komponenttien avulla.
           item.add(new Label("id", String.valueOf(tuote.getId())));

          item.add(new Label("tuoteryhma", tuote.getTuoteryhma()));

          item.add(new Label("nimi", tuote
                  .getNimi()));
          item.add(new Label("hinta", String.valueOf(tuote
              .getHinta())));
          item.add(new Label("alv", String.valueOf(tuote
              .getAlv())));
          item.add(new Label("kpl", String.valueOf(tuote
                  .getKpl())));
        }


      }

}

Re: How to invite Shopping cart method in product site

Posted by jussi isokangas <ju...@gmail.com>.
Hi Martin
I meant *Jaakiekko.* Actually it is productgroup not product, I wrote wrong.
*
Tuote* is product Entity class and *Jaakiekko *is web layer  productgroup
class in which *palvelu*(is service layer interface) invites Entity class *
Tuote*.

Below you can see how *palvelu* uses method which invites group "Jääkiekko"
from table *Tuote* in class *Jaakiekko*.

Collection<Tuote> jaakiekko =
  palvelu.haetuoteRyhmanMukaan(
"jääkiekko");

I have to invite below method  in class Jaakiekko, but how I invite it by
"Cart" button?
 palvelu.lisaaostos(id, pcs);  Here *palvelu* adds new product to cart.


Jussi

**



13. tammikuuta 2011 11.33 Martin Makundi <martin.makundi@koodaripalvelut.com
> kirjoitti:

> Hi!
>
> Product class you mean Tuote? Can you call tuote.add(kiekko); ?
>
> **
> Martin
>
> 13. tammikuuta 2011 10.39 jussi isokangas <ju...@gmail.com>
> kirjoitti:
> > Hi,
> >
> > How can i  invite Shopping cart method which adds a wanted product to
>  Cart
> > in product site? How I refer from product class for this button?
> >
> > Here is my product site and class.
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> > http://www.w3.org/TR/html4/loose.dtd">
> > <html>
> > <head>
> > <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> > <title>Insert title here</title>
> > </head>
> > <body>
> >    <wicket:extend>
> >    <h1>Jaakiekko</h1>
> >
> >        <p>
> >            <table id="taulukko" >
> >              <tr>
> >                <th>id</th>
> >                <th>tuoteryhma</th>
> >                <th>nimi</th>
> >                <th>hinta</th>
> >                <th>alv</th>
> >                <th>kpl</th>
> >              </tr>
> >              <tr wicket:id="jääkiekko">
> >                <td wicket:id="id">id-123</td>   <li><a href="#"
> > wicket:id="ostoskori">Lis&aauml; koriin</a></li>
> >                   <td wicket:id="tuoteryhma">jaakiekko</td>
> >                <td wicket:id="nimi">maila</td>
> >                <td wicket:id="hinta">4</td>
> >                <td wicket:id="alv">23</td>
> >                <td wicket:id="kpl">1</td>
> >              </tr>  *Here button which add product to cart*
> >            </table>
> >        </p>
> >
> >     </wicket:extend>
> >
> >
> >
> >
> >
> > public class Jaakiekko extends Sivupohja {
> >
> >      @SuppressWarnings("unused")
> >      private static final Log log =
> >          LogFactory.getLog(Jaakiekko.class);
> >      private static final long serialVersionUID = 1L;
> >
> >      @SpringBean(name = "verkkokauppaPalvelu")
> >      private Verkkokauppapalvelu palvelu;
> >
> >      /**
> >       * Konstruktori, jokaa hakee halutun tuoteryhmän palvelun avulla
> >       * ja muuntaa tulokset Wicketin web-malliksi.
> >       *
> >       * @param sivunParametrit
> >       */
> >      public Jaakiekko(
> >          final PageParameters sivunParametrit) {
> >        super(sivunParametrit);
> >
> >        // Haetaan palvelulta kaikki tuotteet
> >         Collection<Tuote> jaakiekko =
> >            palvelu.haetuoteRyhmanMukaan("jääkiekko");
> >        //add(new Label("kokonaismaara", String
> >          //  .valueOf(jaakiekko.size())));
> >
> >        // Luodaan komponentti, jonka sisältö toistuu useita
> >        // kertaa web-sivulla.
> >        RepeatingView tuotteetView = new RepeatingView("jääkiekko");
> >        // Lisätään komponentti osaksi koko web-sivun rakennetta
> >         add(tuotteetView);
> >
> >        // Iteroidaan tulosten läpi ja muunnetaan tiedot sopivaan
> >        // muotoon.
> >        Iterator<Tuote> tuoteiter = jaakiekko.iterator();
> >        while (tuoteiter.hasNext()) {
> >
> >          // Lisätään kutakin riviä varten html-merkkausta
> >          // sisältävä komponentti.
> >          WebMarkupContainer item =
> >              new WebMarkupContainer(tuotteetView.newChildId());
> >          tuotteetView.add(item);
> >
> >          // Haetaan seuraavan tuotteen tiedot iteraattorilta.
> >          Tuote tuote = tuoteiter.next();
> >
> >          // Lisätään yksittäisen tuotteen tiedot osaksi sivun
> >          // mallia Label-komponenttien avulla.
> >           item.add(new Label("id", String.valueOf(tuote.getId())));
> >
> >          item.add(new Label("tuoteryhma", tuote.getTuoteryhma()));
> >
> >          item.add(new Label("nimi", tuote
> >                  .getNimi()));
> >          item.add(new Label("hinta", String.valueOf(tuote
> >              .getHinta())));
> >          item.add(new Label("alv", String.valueOf(tuote
> >              .getAlv())));
> >          item.add(new Label("kpl", String.valueOf(tuote
> >                  .getKpl())));
> >        }
> >
> >
> >      }
> >
> > }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to invite Shopping cart method in product site

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

Product class you mean Tuote? Can you call tuote.add(kiekko); ?

**
Martin

13. tammikuuta 2011 10.39 jussi isokangas <ju...@gmail.com> kirjoitti:
> Hi,
>
> How can i  invite Shopping cart method which adds a wanted product to  Cart
> in product site? How I refer from product class for this button?
>
> Here is my product site and class.
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
> http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <title>Insert title here</title>
> </head>
> <body>
>    <wicket:extend>
>    <h1>Jaakiekko</h1>
>
>        <p>
>            <table id="taulukko" >
>              <tr>
>                <th>id</th>
>                <th>tuoteryhma</th>
>                <th>nimi</th>
>                <th>hinta</th>
>                <th>alv</th>
>                <th>kpl</th>
>              </tr>
>              <tr wicket:id="jääkiekko">
>                <td wicket:id="id">id-123</td>   <li><a href="#"
> wicket:id="ostoskori">Lis&aauml; koriin</a></li>
>                   <td wicket:id="tuoteryhma">jaakiekko</td>
>                <td wicket:id="nimi">maila</td>
>                <td wicket:id="hinta">4</td>
>                <td wicket:id="alv">23</td>
>                <td wicket:id="kpl">1</td>
>              </tr>  *Here button which add product to cart*
>            </table>
>        </p>
>
>     </wicket:extend>
>
>
>
>
>
> public class Jaakiekko extends Sivupohja {
>
>      @SuppressWarnings("unused")
>      private static final Log log =
>          LogFactory.getLog(Jaakiekko.class);
>      private static final long serialVersionUID = 1L;
>
>      @SpringBean(name = "verkkokauppaPalvelu")
>      private Verkkokauppapalvelu palvelu;
>
>      /**
>       * Konstruktori, jokaa hakee halutun tuoteryhmän palvelun avulla
>       * ja muuntaa tulokset Wicketin web-malliksi.
>       *
>       * @param sivunParametrit
>       */
>      public Jaakiekko(
>          final PageParameters sivunParametrit) {
>        super(sivunParametrit);
>
>        // Haetaan palvelulta kaikki tuotteet
>         Collection<Tuote> jaakiekko =
>            palvelu.haetuoteRyhmanMukaan("jääkiekko");
>        //add(new Label("kokonaismaara", String
>          //  .valueOf(jaakiekko.size())));
>
>        // Luodaan komponentti, jonka sisältö toistuu useita
>        // kertaa web-sivulla.
>        RepeatingView tuotteetView = new RepeatingView("jääkiekko");
>        // Lisätään komponentti osaksi koko web-sivun rakennetta
>         add(tuotteetView);
>
>        // Iteroidaan tulosten läpi ja muunnetaan tiedot sopivaan
>        // muotoon.
>        Iterator<Tuote> tuoteiter = jaakiekko.iterator();
>        while (tuoteiter.hasNext()) {
>
>          // Lisätään kutakin riviä varten html-merkkausta
>          // sisältävä komponentti.
>          WebMarkupContainer item =
>              new WebMarkupContainer(tuotteetView.newChildId());
>          tuotteetView.add(item);
>
>          // Haetaan seuraavan tuotteen tiedot iteraattorilta.
>          Tuote tuote = tuoteiter.next();
>
>          // Lisätään yksittäisen tuotteen tiedot osaksi sivun
>          // mallia Label-komponenttien avulla.
>           item.add(new Label("id", String.valueOf(tuote.getId())));
>
>          item.add(new Label("tuoteryhma", tuote.getTuoteryhma()));
>
>          item.add(new Label("nimi", tuote
>                  .getNimi()));
>          item.add(new Label("hinta", String.valueOf(tuote
>              .getHinta())));
>          item.add(new Label("alv", String.valueOf(tuote
>              .getAlv())));
>          item.add(new Label("kpl", String.valueOf(tuote
>                  .getKpl())));
>        }
>
>
>      }
>
> }
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org