multibyte content fixes for forms ui.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5084 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-02-08 23:06:25 +00:00
parent 328f998c6c
commit b3569e440a
5 changed files with 78 additions and 60 deletions

View File

@@ -42,18 +42,17 @@ public class AjaxServlet extends BaseServlet
/** /**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/ */
protected void service(HttpServletRequest request, HttpServletResponse response) protected void service(final HttpServletRequest request,
final HttpServletResponse response)
throws ServletException, IOException throws ServletException, IOException
{ {
request.setCharacterEncoding("utf-8");
long startTime = 0; long startTime = 0;
try
{
String uri = request.getRequestURI(); String uri = request.getRequestURI();
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
String queryString = request.getQueryString(); final String queryString = request.getQueryString();
logger.debug("Processing URL: " + uri + logger.debug("Processing URL: " + uri +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : "")); ((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
} }
@@ -61,14 +60,17 @@ public class AjaxServlet extends BaseServlet
// dump the request headers // dump the request headers
if (headersLogger.isDebugEnabled()) if (headersLogger.isDebugEnabled())
{ {
Enumeration headers = request.getHeaderNames(); final Enumeration headers = request.getHeaderNames();
while (headers.hasMoreElements()) while (headers.hasMoreElements())
{ {
String name = (String)headers.nextElement(); final String name = (String)headers.nextElement();
headersLogger.debug(name + ": " + request.getHeader(name)); headersLogger.debug(name + ": " + request.getHeader(name));
} }
} }
try
{
// Make sure the user is authenticated, if not throw an error to return the // Make sure the user is authenticated, if not throw an error to return the
// 500 Internal Server Error code back to the client // 500 Internal Server Error code back to the client
AuthenticationStatus status = servletAuthenticate(request, response, false); AuthenticationStatus status = servletAuthenticate(request, response, false);
@@ -86,12 +88,12 @@ public class AjaxServlet extends BaseServlet
throw new AlfrescoRuntimeException("Servlet URL did not contain all required args: " + uri); throw new AlfrescoRuntimeException("Servlet URL did not contain all required args: " + uri);
} }
// retrieve the command from the URL // retrieve the command from the URL
String commandName = tokens[1]; final String commandName = tokens[1];
// retrieve the binding expression from the URL // retrieve the binding expression from the URL
String expression = tokens[2]; final String expression = tokens[2];
// setup the faces context // setup the faces context
FacesContext facesContext = FacesHelper.getFacesContext(request, response, getServletContext()); final FacesContext facesContext = FacesHelper.getFacesContext(request, response, getServletContext());
// start a timer // start a timer
if (perfLogger.isDebugEnabled()) if (perfLogger.isDebugEnabled())
@@ -124,8 +126,7 @@ public class AjaxServlet extends BaseServlet
// measure the time taken // measure the time taken
if (perfLogger.isDebugEnabled()) if (perfLogger.isDebugEnabled())
{ {
long endTime = System.currentTimeMillis(); perfLogger.debug("Time to execute command: " + (System.currentTimeMillis() - startTime) + "ms");
perfLogger.debug("Time to execute command: " + (endTime - startTime) + "ms");
} }
} }
} }

View File

@@ -467,7 +467,7 @@ public class CreateWebContentWizard extends BaseContentWizard
// put the content of the file into the AVM store // put the content of the file into the AVM store
avmService.createFile(path, avmService.createFile(path,
fileName, fileName,
new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes())); new ByteArrayInputStream((this.content == null ? "" : this.content).getBytes("UTF-8")));
// remember the created path // remember the created path
this.createdPath = AVMNodeConverter.ExtendAVMPath(path, fileName); this.createdPath = AVMNodeConverter.ExtendAVMPath(path, fileName);

View File

@@ -116,7 +116,7 @@ public class XMLUtil
throws SAXException, throws SAXException,
IOException IOException
{ {
return XMLUtil.parse(new ByteArrayInputStream(source.getBytes())); return XMLUtil.parse(new ByteArrayInputStream(source.getBytes("UTF-8")));
} }
/** utility function for parsing xml */ /** utility function for parsing xml */

View File

@@ -315,7 +315,7 @@ public class XFormsBean
final ChibaBean chibaBean = this.xformsSession.chibaBean; final ChibaBean chibaBean = this.xformsSession.chibaBean;
if (chibaBean.getContainer().lookup(id) instanceof Upload) if (chibaBean.getContainer().lookup(id) instanceof Upload)
{ {
chibaBean.updateControlValue(id, null, value, value.getBytes()); chibaBean.updateControlValue(id, null, value, value.getBytes("UTF-8"));
} }
else else
{ {

View File

@@ -29,6 +29,7 @@
// //
// Initiliaze dojo requirements, tinymce, and add a hook to load the xform. // Initiliaze dojo requirements, tinymce, and add a hook to load the xform.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
djConfig.bindEncoding = "UTF-8";
dojo.require("dojo.debug.console"); dojo.require("dojo.debug.console");
dojo.require("dojo.date.common"); dojo.require("dojo.date.common");
dojo.require("dojo.widget.DebugConsole"); dojo.require("dojo.widget.DebugConsole");
@@ -52,7 +53,7 @@ tinyMCE.init({
width: -1, width: -1,
auto_resize: false, auto_resize: false,
force_p_newlines: false, force_p_newlines: false,
encoding: null, encoding: "UTF-8",
add_unload_trigger: false, add_unload_trigger: false,
add_form_submit_trigger: false, add_form_submit_trigger: false,
theme_advanced_toolbar_location: "top", theme_advanced_toolbar_location: "top",
@@ -500,8 +501,6 @@ dojo.declare("alfresco.xforms.Widget",
}, },
/** /**
* Returns an array of RepeatIndexDatas corresponding to all enclosing repeats.
* The closest repeat will be at index 0.
*/ */
getParentGroups: function(appearance) getParentGroups: function(appearance)
{ {
@@ -756,6 +755,7 @@ dojo.declare("alfresco.xforms.PlainTextEditor",
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// overridden methods // overridden methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
render: function(attach_point) render: function(attach_point)
{ {
attach_point.appendChild(this.domNode); attach_point.appendChild(this.domNode);
@@ -2972,7 +2972,25 @@ dojo.declare("alfresco.xforms.Submit",
submit_buttons[i].widget = this; submit_buttons[i].widget = this;
dojo.event.browser.addListener(submit_buttons[i], dojo.event.browser.addListener(submit_buttons[i],
"onclick", "onclick",
function(event) this._submitButton_clickHandler,
false);
}
},
{
/////////////////////////////////////////////////////////////////
// DOM event handlers
/////////////////////////////////////////////////////////////////
_clickHandler: function(event)
{
this.done = false;
_hide_errors();
this.fire();
},
/** */
_submitButton_clickHandler: function(event)
{ {
if (!event.target.widget) if (!event.target.widget)
{ {
@@ -2997,21 +3015,6 @@ dojo.declare("alfresco.xforms.Submit",
xform.submitWidget.widget.buttonClick(); xform.submitWidget.widget.buttonClick();
return false; return false;
} }
},
false);
}
},
{
/////////////////////////////////////////////////////////////////
// DOM event handlers
/////////////////////////////////////////////////////////////////
_clickHandler: function(event)
{
this.done = false;
_hide_errors();
this.fire();
} }
}); });
@@ -3104,7 +3107,6 @@ dojo.declare("alfresco.xforms.Binding",
(_hasAttribute(this.xformsNode, alfresco_xforms_constants.XFORMS_PREFIX + ":required") (_hasAttribute(this.xformsNode, alfresco_xforms_constants.XFORMS_PREFIX + ":required")
? this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":required") == "true()" ? this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":required") == "true()"
: null); : null);
this._type = this._type =
(_hasAttribute(this.xformsNode, alfresco_xforms_constants.XFORMS_PREFIX + ":type") (_hasAttribute(this.xformsNode, alfresco_xforms_constants.XFORMS_PREFIX + ":type")
? this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":type") ? this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":type")
@@ -3748,6 +3750,7 @@ AjaxHelper.createRequest = function(target, serverMethod, methodArgs, load, erro
AjaxHelper.sendRequest = function(req) AjaxHelper.sendRequest = function(req)
{ {
AjaxHelper._sendHandler(req); AjaxHelper._sendHandler(req);
req.encoding = "utf-8";
dojo.io.queueBind(req); dojo.io.queueBind(req);
} }
@@ -4012,10 +4015,12 @@ FilePickerWidget._upload_completeHandler = function(id, path, fileName, fileType
// instance methods and properties // instance methods and properties
FilePickerWidget.prototype = { FilePickerWidget.prototype = {
getValue: function() getValue: function()
{ {
return this.value; return this.value;
}, },
setValue: function(v) setValue: function(v)
{ {
this.value = (v == null || v.length == 0 ? null : v); this.value = (v == null || v.length == 0 ? null : v);
@@ -4026,6 +4031,7 @@ setValue: function(v)
this.change_callback(this); this.change_callback(this);
}, },
setReadonly: function(r) setReadonly: function(r)
{ {
this.readonly = r; this.readonly = r;
@@ -4038,10 +4044,12 @@ setReadonly: function(r)
this._showSelectedValue(); this._showSelectedValue();
} }
}, },
render: function() render: function()
{ {
this._showSelectedValue(); this._showSelectedValue();
}, },
_showStatus: function(text, isError) _showStatus: function(text, isError)
{ {
var d = this.node.ownerDocument; var d = this.node.ownerDocument;
@@ -4069,6 +4077,7 @@ _showStatus: function(text, isError)
setTimeout("var _status = document.getElementById('" + this.uploadId + setTimeout("var _status = document.getElementById('" + this.uploadId +
"-status'); if (_status && _status) { _status.widget._hideStatus(); }", 5000); "-status'); if (_status && _status) { _status.widget._hideStatus(); }", 5000);
}, },
_hideStatus: function() _hideStatus: function()
{ {
if (this.statusDiv) if (this.statusDiv)
@@ -4091,6 +4100,7 @@ _hideStatus: function()
anim.play(); anim.play();
} }
}, },
_showSelectedValue: function() _showSelectedValue: function()
{ {
var d = this.node.ownerDocument; var d = this.node.ownerDocument;
@@ -4150,6 +4160,7 @@ _navigateToNode: function(path)
req.content.currentPath = path; req.content.currentPath = path;
AjaxHelper.sendRequest(req); AjaxHelper.sendRequest(req);
}, },
_showPicker: function(data) _showPicker: function(data)
{ {
while (this.node.hasChildNodes() && while (this.node.hasChildNodes() &&
@@ -4341,6 +4352,7 @@ _showPicker: function(data)
this.contentDiv.appendChild(row); this.contentDiv.appendChild(row);
} }
}, },
_createRow: function(fileName, webappRelativePath, isDirectory, fileTypeImage, rowClass) _createRow: function(fileName, webappRelativePath, isDirectory, fileTypeImage, rowClass)
{ {
var d = this.contentDiv.ownerDocument; var d = this.contentDiv.ownerDocument;
@@ -4417,6 +4429,7 @@ _createRow: function(fileName, webappRelativePath, isDirectory, fileTypeImage,
}); });
return result; return result;
}, },
_hideAddContent: function() _hideAddContent: function()
{ {
if (this.addContentDiv) if (this.addContentDiv)
@@ -4426,6 +4439,7 @@ _hideAddContent: function()
this.addContentDiv = null; this.addContentDiv = null;
} }
}, },
_showAddContent: function(currentPath) _showAddContent: function(currentPath)
{ {
if (this.addContentDiv) if (this.addContentDiv)
@@ -4490,6 +4504,7 @@ _showAddContent: function(currentPath)
w); w);
}); });
}, },
_upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, error) _upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, error)
{ {
if (error) if (error)
@@ -4515,6 +4530,7 @@ _upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, e
this.addContentDiv = null; this.addContentDiv = null;
} }
}, },
_closeParentPathMenu: function() _closeParentPathMenu: function()
{ {
if (this.parentPathMenu) if (this.parentPathMenu)
@@ -4525,6 +4541,7 @@ _closeParentPathMenu: function()
} }
this.headerMenuTriggerLink.style.borderStyle = "solid"; this.headerMenuTriggerLink.style.borderStyle = "solid";
}, },
_openParentPathMenu: function(target, path) _openParentPathMenu: function(target, path)
{ {
var d = target.ownerDocument; var d = target.ownerDocument;