character encoding problem with processTemplate?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2007 11:38 AM
So i've been writing all my html forms in dreamweaver doctype xhtml, and
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
The html forms have this type and charset specified also:<form action="${url.serviceContext}/apply/postdoc08/edit?guest=true" method="post" enctype="multipart/form-data" charset="utf-8">
I have a freemarker template applicant.xml.ftl that starts off <?xml version="1.0" encoding="UTF-8"?>
So everything should be utf8 right? Indeed if i edit my source xml document with extended characters, and save as UTF8 in TextEdit or Oxygen.app, then all my html pages render the text just fine. Those freemarker templates are xhtml, utf-8, and are loading the xml file thusly:<#assign dom=document.xmlNodeModel>
So that all works, but the problems arises when submitting the html form. The POST is received by a .js file, which applies the template and saves the result out to the repository. Here is where i think the character encoding is getting lost:var tScriptSpace = companyhome.childByNamePath( gPathToScriptSpace );var tXMLTemplateNode = tScriptSpace.childByNamePath( gXMLTemplate );var tArgs = formFieldsToArgsArray();var tNewApplicantXMLStr = tApplicantXMLNode.processTemplate( tXMLTemplateNode, tArgs);tApplicantXMLNode.content = tNewApplicantXMLStr;
My best guess is the call to processTemplate() is returning the wrong character encoding somehow? Not sure. Where have I gone wrong or is it a problem with processTemplate or something i have overlooked?
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2007 12:09 PM
I haven't tried this myself (i will do) but I think you may need to override the FreeMarkerProcessor bean definition in the Spring config thus:
<bean id="freeMarkerProcessor" parent="baseTemplateProcessor" class="org.alfresco.repo.template.FreeMarkerProcessor"> <property name="name"> <value>freemarker</value> </property> <property name="extension"> <value>ftl</value> </property> <property name="defaultEncoding"> <value>UTF-8</value> </property> </bean>
As the JavaScript API is going direct to the template processor, it does not know the encoding of the source webscript page that is executing within. I'll take a look as it should be possible to fix this for a future version.
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2007 04:02 PM
I get the same result when I enter UTF8 characters into my form and save it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2007 04:57 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2007 03:24 AM
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2007 12:50 PM
but the same problem still.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-24-2007 12:51 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2007 05:04 PM
Kevin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2007 07:04 AM
For your testing purposes, I have provided the modified .class file here. You can patch it into your alfresco-web-client.jar inside the alfresco.war file and check it works for you. I think the config change I posted above should fix any issues with processTemplate() - but that doesn't look like it was the issue anyway.
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2007 01:01 PM
I am not that familiar with how tomcat expands these files.
