KonaKart Community Forum

Installation / Configuration => Programming of KonaKart => Topic started by: Sony George on September 05, 2009, 06:32:50 pm

Title: a bug in review tile ::: method revMgr.truncateDesc does not return utf char
Post by: Sony George on September 05, 2009, 06:32:50 pm
Dear Konakart team,

RandomReviewTile.jsp page is not showing the utf char correctly

The method revMgr.truncateDesc does not return utf char.
<%=revMgr.truncateDesc(rev.getReviewText(),15,60)%>

see the attached images
konakart_review_tile_1.jpg is taken with out using the method revMgr.truncateDesc <%=rev.getReviewText()%>

but the second image which is not correct
konakart_review_tile_2.jpg is taken using the method revMgr.truncateDesc <%=revMgr.truncateDesc(rev.getReviewText(),15,60)%>

regards


Title: Re: a bug in review tile ::: method revMgr.truncateDesc does not return utf char
Post by: Sony George on September 06, 2009, 05:20:53 am
Quote from: sony3002 on September 05, 2009, 06:32:50 pm
Dear Konakart team,

RandomReviewTile.jsp page is not showing the utf char correctly

The method revMgr.truncateDesc does not return utf char.
<%=revMgr.truncateDesc(rev.getReviewText(),15,60)%>

see the attached images
konakart_review_tile_1.jpg is taken with out using the method revMgr.truncateDesc <%=rev.getReviewText()%>

but the second image which is not correct
konakart_review_tile_2.jpg is taken using the method revMgr.truncateDesc <%=revMgr.truncateDesc(rev.getReviewText(),15,60)%>

regards





hello,
this happens because u r inserting -<br> inside the review text. how can i remove it ??? from RandomReviewTile.jsp ?? which method i have to call for not to insert -<br> between review text ??
regards
Title: Re: a bug in review tile ::: method revMgr.truncateDesc does not return utf char
Post by: julie on September 07, 2009, 08:31:58 am
Why don't you just truncate the text in the JSP using a bit of Java code instead of calling our method?
Title: Re: a bug in review tile ::: method revMgr.truncateDesc does not return utf char
Post by: costis on September 08, 2009, 09:22:52 am
Still, i too think that this is a problem. Some code in the review system truncates or modifies the inserted characters.

This is how the Greek letters are displayed in KonakartAdmin-->Products-->Edit-->Reviews-->Edit in the Text Area:

&alpha;&beta;&gamma;&delta;&epsilon;&zeta;&eta;&theta;&iota;&kappa;&lambda;&mu;&nu;&xi;&omicron;&pi;&rho;&sigma;&tau;&upsilon;&phi;&chi;&psi;&omega;
&#940;&#941;&#943;&#972;&#973;&#970;&#912;

Text is inserted as "αβγδεζη...." and internally converted into "&alpha;&beta;&gamma;&delta;&epsilon;&zeta;&eta;...", but not all characters can be converted back.

While the Product Description i.e. shows all the characters normally everywhere. 
Title: Re: a bug in review tile ::: method revMgr.truncateDesc does not return utf char
Post by: julie on September 08, 2009, 12:56:25 pm
The problem is that org.apache.commons.lang.StringEscapeUtils.escapeHTML isn't just escaping the HTML control characters but all of the UTF-8 stuff as well. A workaround is as follows:

In WriteReviewSubmitAction.java comment out the line:

kkAppEng.getReviewMgr().writeReview(wrf.getReviewText(), wrf.getRating(), custId);

And replace it with:

           ReviewIf rev = new Review();
            rev.setRating(wrf.getRating());
            rev.setReviewText(wrf.getReviewText());
            rev.setProductId(kkAppEng.getProductMgr().getSelectedProduct().getId());
            rev.setLanguageId(kkAppEng.getLangId());
            rev.setCustomerId(custId);
            kkAppEng.getEng().writeReview(kkAppEng.getSessionId(), rev);


By calling the server engine directly, you miss out the escaping. However, beware that you should still include some HTML escaping because otherwise review text could damage the formatting of the storefront page.