Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
dhanaraja rajendran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 !!!





 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!