template-encoding
"Alexander Povargo" <[email protected]> Thu, 19 Dec 2002 02:19:35 +0500
| Newsgroups | gmane.comp.java.jpublish.devel |
|---|---|
| Organization | ALVO Business Solutions, Corp. |
| Message-ID | <000101c2a6db$2e43a930$bc123bd5@alpo> |
Hello,
After Velocity.evaluate(...) was moved from JPublishServlet.java to
Template.java, template-encoding isn't working.
Here correction of Template.java:
----------
// add this to import section:
import java.io.UnsupportedEncodingException;
import org.jpublish.util.CharacterEncodingMap;
// ...
public void merge(JPublishContext context, Page page, Writer out)
throws TemplateMergeException{
try{
CharacterEncodingMap characterEncodingMap =
(CharacterEncodingMap)context.get("characterEncodingMap");
String templateEncoding =
characterEncodingMap.getTemplateEncoding();
Velocity.evaluate(context, out, page.getPath(),
getReader(templateEncoding));
log.debug("Merge complete.");
} catch(Exception e){
throw new TemplateMergeException(e.getMessage(), e);
}
}
protected Reader getReader(String templateEncoding){
String result = "";
try {
result = new String(templateText.getBytes(),
templateEncoding);
} catch (UnsupportedEncodingException e) {
result = templateText;
}
return new StringReader(result);
}
----------
After this changes template-encoding is working now.
Regards,
Alexander Povargo
[email protected]
-------------------------------------------------------
This SF.NET email is sponsored by: Order your Holiday Geek Presents Now!
Green Lasers, Hip Geek T-Shirts, Remote Control Tanks, Caffeinated Soap,
MP3 Players, XBox Games, Flying Saucers, WebCams, Smart Putty.
T H I N K G E E K . C O M http://www.thinkgeek.com/sf/