KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: Anni on November 23, 2007, 10:50:35 am

Title: problem with getDescription()
Post by: Anni on November 23, 2007, 10:50:35 am
hi again,

I got another problem. on the shop's home page I want to display the latest product with its description. getting the correct image and the product name is no problem. however, when I try to insert the product description via its getDescription()-method, only null is displayed.  ???
any idea, what went wrong? because it works perfectly on the product's details page ...

regards,
anni
Title: Re: problem with getDescription()
Post by: julie on November 23, 2007, 10:56:12 am
Hi Anni,

When we get an array of products the description isn't fetched because it can be very long and so could stifle performance. In order to get it you have to call the getProduct() method of the engine passing it the language id and the product id. It will return one product including its description in the language that you specify.

Regards,

Julie
Title: Re: problem with getDescription()
Post by: Anni on November 23, 2007, 11:10:06 am
hi julie,

thanks for the answer.
how would I do that in the jsp? something like: kkEng.getProduct(prodId, langID).getDescription()?

regards,
anni
Title: Re: problem with getDescription()
Post by: Anni on November 23, 2007, 11:47:50 am
ok, I've tried that, but it seems to be wrong. now, that jsp isn't displayed anymore.

how do I do this correctly?

regards,
anni
Title: Re: problem with getDescription()
Post by: julie on November 23, 2007, 12:06:52 pm
Hi Anni,

This is what you need to do :

if (prod.getDescription() == null ) {

   prod = kkEng.getEng().getProduct(kkEng.getSessionId(), prod.getId(), kkEng.getLangId());

        }

Title: Re: problem with getDescription()
Post by: Anni on November 23, 2007, 12:23:37 pm
thanks :) works perfectly now!

regards,
anni
Title: Re: problem with getDescription()
Post by: Anni on November 23, 2007, 03:17:10 pm
ok, now I've encountered another problem. next to the latest product I plan to display the two next most recent ones. but my inserted code just prevents the page from being displayed (again)  :-\ ???

this is how I did it:


<%int i=0;%>
<td class="olderIssues">
    <logic:iterate id="prod" name="prodArray" length="3" type="com.konakart.appif.ProductIf">
<%if(i==0){%>
    <%i=1;%>
<%}else{%>
    <div>
<html:link page="/SelectProd.do" paramId="prodId" paramName="prod" paramProperty="id">
  <img src="images/<%=prod.getImage()%>" border="0" alt="<%=prod.getName()%>" title=" <%=prod.getName()%> " />
</html:link>
    </div>
<%}%>
    </logic:iterate>
</td>


do you know, why this is not showing up? I'm really confused as to why it doesn't work ...

regards,
anni
Title: Re: problem with getDescription()
Post by: julie on November 23, 2007, 03:25:55 pm
Hi Anni,

The Tomcat log should give you some indication as to what is going wrong.

Regards,

Julie
Title: Re: problem with getDescription()
Post by: Anni on November 23, 2007, 03:34:58 pm
the tomcat log says:

Type mismatch: cannot convert from null to int

and

The operator == is undefined for the argument type(s) int, null

??? ???

I have initialised "i", so there is no null!
getting more and more confused...

regards,
anni
Title: Re: problem with getDescription()
Post by: kingsulaman on April 17, 2009, 01:19:10 pm
Quote from: julie on November 23, 2007, 12:06:52 pm
Hi Anni,

This is what you need to do :

if (prod.getDescription() == null ) {

   prod = kkEng.getEng().getProduct(kkEng.getSessionId(), prod.getId(), kkEng.getLangId());

        }




Thank you so much i had same problem...and i got fixes up.