• Welcome to KonaKart Community Forum. Please login or sign up.
 

Adding Quantity Parameter On Product Detail Page

Started by tomtom, January 04, 2008, 11:50:05 am

Previous topic - Next topic

tomtom

Hi,
   I read this forum:
http://www.konakart.com/forum/index.php/topic,40.0.html

where the user wanted to add the quantity to the product detail page.

I wanted to make the same changes as well on the detail page where you be
able  to add # of quantity to the cart on the detail page.

On the konakart/custom/appn/src/com/konakart/forms/AddToCartForm.java, i added this piece of code below:
=======================================================
....
....
private int productQuantity = 0;
......
/**
     * @return Returns the productQuantity.
     * TomChanges
     */
    public int getProductQuantity()
    {
        return productQuantity;
    }

    /**
     * @param productQuantity The productQuantity to set.
     * TomChanges
     */
    public void setProductQuantity(int productQuantity)
    {
        this.productQuantity = productQuantity;
    }
.......
=======================================================

On the konakart/custom/appn/src/com/konakart/actions/AddToCartSubmitAction.java, i added this piece of code:

=======================================================
............
AddToCartForm acf = (AddToCartForm) form;
............ 
BasketIf b = new Basket();
  // This is the default code where item was set to 1 always.
//b.setQuantity(1); 
  b.setQuantity(acf.getProductQuantity());
..........
=======================================================

I build this 2 file and it created a "konakart_custom.jar" where i added it on my tomcat server at this path:
../www/konakart/WEB-INF/lib/konakart_custom.jar

Then i start my server and somehow i got this error in konakart:
Any idea how to resolve this error below ?
Maybe i'm missing some step here. ;D
=============================
HTTP Status 404 - Servlet action is not available

type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.
Apache Tomcat/5.5.15

=============================


My jsp [ProductDetailsBody.jsp] look like this:

<html:hidden name = "AddToCartForm" property="productQuantity" value="2"></html:hidden>

Thanks again for your help on this. Appreciate your expertise  ;D

pete

Hi,

Your modifications make sense. Two questions :

When you copied the new konakart_custom.jar into the lib directory, I assume that it overwrote the existing one ?
Did you change struts-config.xml at all, since a typo in this file can cause that sort of error.

-Pete

tomtom

yes, it did overwrite the existing one.
No, not at all. The only changes was to add the new konakart_custom.jar to the
www/konakart/WEB-INF/lib/...

I'm guessing it something to do with the class files that got compile which cause it.

Looks like even the welcome page in konakart does not work either when i try to load it up

I do get a different error on this on the welcome page:

=============
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:395)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

java.lang.NullPointerException
   org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:428)
   org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:311)
   org.apache.struts.taglib.logic.RedirectTag.generateRedirectURL(RedirectTag.java:294)
   org.apache.struts.taglib.logic.RedirectTag.doEndTag(RedirectTag.java:268)
   org.apache.jsp.index_jsp._jspx_meth_logic_redirect_0(org.apache.jsp.index_jsp:81)
   org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:57)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

note The full stack trace of the root cause is available in the Apache Tomcat/5.5.15 logs.
=============

tomtom

hmm..after taking a look deeper here is what i found out.

Just to give a bit of history, i did not use the wizard to install konakart. I install it manually by downloading the KonaKart-2.2.1.0.zip files. I think i'm able to re-produce this problem which may be due to the KonaKart-2.2.1.0.zip inconsistency file dir created ...i think...please correct me if i'm wrong  ;D

After unzipping this new KonaKart-2.2.1.0.zip file, i move the

konakart/webapps/konakart/.. to my own tomcat webapp dir.
konakart/webapps/konakartadmin/.. to my own tomcat webapp dir.
konakart/webapps/birt-viewer/.. to my own tomcat webapp dir.

and then restart my tomcat server. At this point it work since i was able to see the konakart site.

I took a look at konakart/webapps/konakart/WEB-INF/lib/konakart_custom.jar
and this is the actual file size:  109823 2007-12-06 12:56 konakart_custom.jar

After than, i ran an ant build at this dir: konakart/custom/... and a bunch of konakart jars got created in the jar dir  in this dir konakart/custom/...

I took a look at the konakart_custom.jar     
ls -la konakart_custom.jar                                                                   [.../konakart/custom/jar]
117816 2008-01-04 19:00 konakart_custom.jar

It looks like the konakart_custom.jar in ../konakart/custom/jar/... is different than the one in
.../konakart/webapps/konakart/WEB-INF/lib/konakart_custom.jar

When i move this .../konakart/webapps/konakart/WEB-INF/lib/konakart_custom.jar to my own tomcat server and start my server, it works.

When i move this ../konakart/custom/jar/konakart_custom.jar to my own tomcat server and start my server, it did not work.

Bare in mind, i have not change any code in KonaKart-2.2.1.0.zip yet.
I just unzip it and build the custom directory.
Looks like the custom dir have some run time problem.
Can someone please investigate this ...hopefully reproduce step i took ?

Any idea how can i fix this ? I really do appreciate your expertise on this.

I did not get the chance to say this ....so .....
Thanks again for this really cool software and Happy New Year to the konakart family  ;D

kate

Hi Tomtom,

I don't get that problem when I compile... on Windows or Linux,   I've just done it as follows:

[root@konakart ~]# ls -ltr ~konakart/konakart/webapps/konakart/WEB-INF/lib/konakart_custom.jar
-rwxr-xr-x  1 konakart webadmin 109823 Dec  6 07:56 /home/konakart/konakart/webapps/konakart/WEB-INF/lib/konakart_custom.jar

[root@konakart ~]# cd ~konakart/konakart/custom/

[root@konakart custom]# java -version
java version "1.5.0_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode)

[root@konakart custom]# ./bin/ant
Buildfile: build.xml

clean_wars:
     [echo] Cleanup WARs...

clean:
     [echo] Cleanup...

compile:
     [echo] Compile the customisable application code
    [mkdir] Created dir: /home/konakart/konakart/custom/appn/classes
    [javac] Compiling 104 source files to /home/konakart/konakart/custom/appn/classes
    [javac] Note: /home/konakart/konakart/custom/appn/src/com/konakart/actions/SelectCategoryAction.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.

compile_modules:
     [echo] Compile the customisable module code
    [mkdir] Created dir: /home/konakart/konakart/custom/modules/classes
    [javac] Compiling 50 source files to /home/konakart/konakart/custom/modules/classes

make_payment_module_jar:
     [echo] Create the module jar
    [mkdir] Created dir: /home/konakart/konakart/custom/jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_authorizenet.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_chronopay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_cod.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_epaybg.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_payjunction.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_paypal.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_usaepay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_worldpay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_payment_yourpay.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_productdiscount.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_shipping.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_subtotal.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_tax.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_total.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_ordertotal_totaldiscount.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_digitaldownload.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_flat.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_free.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_item.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_table.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_shipping_zones.jar

make_jars:
     [echo] Create the konakart_custom.jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakart_custom.jar
     [echo] Create the konakartadmin_custom.jar
      [jar] Building jar: /home/konakart/konakart/custom/jar/konakartadmin_custom.jar

build:

BUILD SUCCESSFUL
Total time: 21 seconds

[root@konakart custom]# ls -ltr jar/konakart_custom.jar
-rw-r--r--  1 root root 109823 Jan  5 02:51 jar/konakart_custom.jar


This is the same size as the original file in the kit.


So it seems there could be something wrong/different with your build?

Have you compared the jar you created with the original?

Are all the jars produced different sixes to the originals?

Which verison of java are you using?

How did you execute the build?

Kate

tomtom

Kate, thanks for the quick response  ;D

Here is what i did:

a) Download this zip file at this site: http://www.konakart.com/downloads.php
    # Zip for manual installation on all platforms:   KonaKart-2.2.1.0.zip

b) Unzip the file KonaKart-2.2.1.0.zip

c) Check konakart_custom.jar at .../konakart/webapps/konakart/WEB-INF/lib/

ls -la konakart_custom.jar                                                                                                      [.../konakart/WEB-INF/lib]
-rw-r--r-- 1 tomtom users 109823 2007-12-06 12:56 konakart_custom.jar

d) ran ant build at .../konakart/custom/..

========================
tomtom [00:56] :->ant                                                                                                                       [.../tomTesting/konakart/custom]
Buildfile: build.xml

clean_wars:
     [echo] Cleanup WARs...

clean:
     [echo] Cleanup...

compile:
     [echo] Compile the customisable application code
    [mkdir] Created dir: /home/devdownload/cartSoftware/tomTesting/konakart/custom/appn/classes
    [javac] Compiling 104 source files to /home/devdownload/cartSoftware/tomTesting/konakart/custom/appn/classes

compile_modules:
     [echo] Compile the customisable module code
    [mkdir] Created dir: /home/devdownload/cartSoftware/tomTesting/konakart/custom/modules/classes
    [javac] Compiling 50 source files to /home/devdownload/cartSoftware/tomTesting/konakart/custom/modules/classes

make_payment_module_jar:
     [echo] Create the module jar
    [mkdir] Created dir: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_authorizenet.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_chronopay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_cod.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_epaybg.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_payjunction.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_paypal.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_usaepay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_worldpay.jar

make_payment_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_payment_yourpay.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_productdiscount.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_shipping.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_subtotal.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_tax.jar


make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_total.jar

make_ordertotal_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_ordertotal_totaldiscount.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_digitaldownload.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_flat.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_free.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_item.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_table.jar

make_shipping_module_jar:
     [echo] Create the module jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_shipping_zones.jar

make_jars:
     [echo] Create the konakart_custom.jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakart_custom.jar
     [echo] Create the konakartadmin_custom.jar
      [jar] Building jar: /home/devdownload/cartSoftware/tomTesting/konakart/custom/jar/konakartadmin_custom.jar

build:

BUILD SUCCESSFUL
Total time: 28 seconds

========================

e) Check newly created konakart_custom.jar at .../konakart/custom/jar/

117816 2008-01-05 00:57 konakart_custom.jar   [different size compare to the current one at the webapp level - Step c]

The rest of the other jars are at this size:
=========================
tomtom [01:05] :->ls -lart                                                                                                                         [.../konakart/custom/jar]
total 348
-rw-r--r-- 1 tomtom users  12654 2008-01-05 00:57 konakart_payment_authorizenet.jar
drwxr-xr-x 7 tomtom users   4096 2008-01-05 00:57 ../
-rw-r--r-- 1 tomtom users  12248 2008-01-05 00:57 konakart_payment_payjunction.jar
-rw-r--r-- 1 tomtom users  12714 2008-01-05 00:57 konakart_payment_epaybg.jar
-rw-r--r-- 1 tomtom users   5554 2008-01-05 00:57 konakart_payment_cod.jar
-rw-r--r-- 1 tomtom users  10993 2008-01-05 00:57 konakart_payment_chronopay.jar
-rw-r--r-- 1 tomtom users  12568 2008-01-05 00:57 konakart_payment_yourpay.jar
-rw-r--r-- 1 tomtom users  10777 2008-01-05 00:57 konakart_payment_worldpay.jar
-rw-r--r-- 1 tomtom users  11456 2008-01-05 00:57 konakart_payment_usaepay.jar
-rw-r--r-- 1 tomtom users  10818 2008-01-05 00:57 konakart_payment_paypal.jar
-rw-r--r-- 1 tomtom users   7354 2008-01-05 00:57 konakart_ordertotal_productdiscount.jar
-rw-r--r-- 1 tomtom users   5436 2008-01-05 00:57 konakart_ordertotal_total.jar
-rw-r--r-- 1 tomtom users   5641 2008-01-05 00:57 konakart_ordertotal_tax.jar
-rw-r--r-- 1 tomtom users   5630 2008-01-05 00:57 konakart_ordertotal_subtotal.jar
-rw-r--r-- 1 tomtom users   6035 2008-01-05 00:57 konakart_ordertotal_shipping.jar
-rw-r--r-- 1 tomtom users   7410 2008-01-05 00:57 konakart_shipping_table.jar
-rw-r--r-- 1 tomtom users   6484 2008-01-05 00:57 konakart_shipping_item.jar
-rw-r--r-- 1 tomtom users   5673 2008-01-05 00:57 konakart_shipping_free.jar
-rw-r--r-- 1 tomtom users   6299 2008-01-05 00:57 konakart_shipping_flat.jar
-rw-r--r-- 1 tomtom users   6069 2008-01-05 00:57 konakart_shipping_digitaldownload.jar
-rw-r--r-- 1 tomtom users   7325 2008-01-05 00:57 konakart_ordertotal_totaldiscount.jar
-rw-r--r-- 1 tomtom users   8413 2008-01-05 00:57 konakart_shipping_zones.jar
-rw-r--r-- 1 tomtom users 117816 2008-01-05 00:57 konakart_custom.jar
-rw-r--r-- 1 tomtom users   1764 2008-01-05 00:57 konakartadmin_custom.jar
drwxr-xr-x 2 tomtom users   4096 2008-01-05 00:57 ./

tomtom [01:05] :->                                                                                                                           
[.../konakart/custom/jar]
=========================


To answer your questions:

So it seems there could be something wrong/different with your build?
tomtom: Yes and i don't know what...maybe the step above will enlighten you on what i'm doing wrong here  ;D
           
This is the ant version i'm using:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
tomtom [01:14] :->which ant                                                                                                                        [.../konakart/custom/jar]
/usr/bin/ant
tomtom [01:14] :->ls -la /usr/bin/ant                                                                                                              [.../konakart/custom/jar]
-rwxr-xr-x 1 root root 9725 2006-12-13 04:16 /usr/bin/ant*
tomtom [01:14] :->ant -version                                                                                                                     [.../konakart/custom/jar]
Apache Ant version 1.7.0 compiled on December 13 2006                       
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

and my OS is Linux: Open Suse-10.3

Have you compared the jar you created with the original?
tomtom: Yes and you can see from the steps above i was able to reproduce it again

Are all the jars produced different sixes to the originals?
tomtom: Not sure but currently only konakart_custom.jar is the only one different

Which version of java are you using?

tomtom:
+++++++++++++++++++++++++++++
tomtom [01:12] :->java -version                                                                                                                    [.../konakart/custom/jar]
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Client VM (build 1.5.0_13-b05, mixed mode)
+++++++++++++++++++++++++++++

How did you execute the build?

tomtom: Look at step d)


Hopefully this info will help.
Thanks again for investigating this. Appreciate your help on this  :P


kate

Hi,

I'm pretty sure that the reason you are seeing a different size konakart_custom.jar is that you're using a different java compiler to produce it (to the one used to build the original one).

If you modify the custom/build.xml and add a "target="1.5"" (right after the source="1.5" on the javac tasks - then rebuild, you will produce a jar of the same size as the original (built on 1.5 java).

However, this should not matter if you are actually running with a JVM that is at least as recent as the one you used to build.

I have verified this myself...  On a system where I run KonaKart with java 1.6 I built the konakart_custom.jar and produced one with a size of 117817 bytes.    The konakart_custom.jar that I was using previously, running under a 1.6 JVM, was sized 109823 bytes.

I copied over my new, larger, konakart_custom.jar. restarted my tomcat, and all worked fine.


Therefore...  all I can suggest is that you try again ensuring that you run KonaKart with a JVM that can support all the classes you've created.

Alternatively you could modify the build.xml as explained above and see how that works for you...

Kate

tomtom

Kate thanks! It work  ;D

The different java compiler is the culprit  :P