• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Velocity Template text showing as a ?? mark if the text is Arabic

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Actually In my application I have mail sending functionality.. but the text which i am sending is in Arabic..

problem that I am facing here is it is giving me question mark (???)instead of arabic text..

Here I pasted all my codes for your reference



Step 1: Loading velocity properties:

VelocityContext context = new VelocityContext();
for (Map.Entry<String, Object> content : messageContent.entrySet())
{
context.put(content.getKey(), content.getValue());
}
Note: here my content.getValue() is in arabic as I mentioned earlier

Step 2:Loading velocity Properties

InputStream velocityStream =
MessageContent.class
.getResourceAsStream(MessageConstants.PROPERTY_FILE_VELOCITY);
Properties velocityProperties = new Properties();
velocityProperties.load(velocityStream);



MessageConstants.PROPERTY_FILE_VELOCITY loading from below three lines

runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem
input.encode="UTF-8"
output.encode="UTF-8" .

Step 3:Getting vm template content

String contentTemplate = getContent(contentTypeName);

contentTypeName is the file name of my vm template like abc.vm

Step 4:
Initializing velocity properties
Velocity.init(velocityProperties);

Step 5 :
evaluating velocity
ie, loading my content value to the vm template in this case abc.vm file

Velocity.evaluate(velocityContext, contentWriter, "LOG", contentTemplate);


I have pasted complete method here for your reference:

public static String getContentData(String contentTypeName, VelocityContext velocityContext)
{
// Load the velocity.properties.
// Load the template.
StringWriter contentWriter = new StringWriter();
InputStream velocityStream =
MessageContent.class
.getResourceAsStream("/velocity.properties");
Properties velocityProperties = new Properties();
velocityProperties.load(velocityStream);
String contentTemplate = getContent(contentTypeName);
if (StringUtils.isEmpty(contentTemplate))
{
log.error("Template content not retrieved.");

}
Velocity.init(velocityProperties);
Velocity.evaluate(velocityContext, contentWriter, "LOG", contentTemplate);
return contentWriter.getBuffer().toString();

GUIDE ME HOW TO RESOLVE THIS ISSUE AND DISPLAY PROPER ARABIC TEXT IN MY EMAIL..

NOTE:- IF POSSIBLE I NEED TO CONVERT THIS ARABIC TO ENGLISH AND DISPLAY IT IN EMAIL

AND ONE MORE THING THIS TEXT WILL BE DYNAMIC EVERY TIME.......

THANKS IN ADVANCE !!!





 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JSF forum is not the best place to get help with Velocity. Velocity and JSF are 2 very different products.

I'm not actually sure how much Velocity supports right-to-left text. However, if you get "?" characters, boxes, or other characters that do not resemble the text you expected, you probably have not set up the code page for the HTML output properly.

More than that I cannot say. I would suggest you check in our "Other open source frameworks" forum.
 
reply
    Bookmark Topic Watch Topic
  • New Topic