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,32 +42,34 @@ public class AjaxServlet extends BaseServlet
/**
* @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
{
request.setCharacterEncoding("utf-8");
long startTime = 0;
String uri = request.getRequestURI();
if (logger.isDebugEnabled())
{
final String queryString = request.getQueryString();
logger.debug("Processing URL: " + uri +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
// dump the request headers
if (headersLogger.isDebugEnabled())
{
final Enumeration headers = request.getHeaderNames();
while (headers.hasMoreElements())
{
final String name = (String)headers.nextElement();
headersLogger.debug(name + ": " + request.getHeader(name));
}
}
try
{
String uri = request.getRequestURI();
if (logger.isDebugEnabled())
{
String queryString = request.getQueryString();
logger.debug("Processing URL: " + uri +
((queryString != null && queryString.length() > 0) ? ("?" + queryString) : ""));
}
// dump the request headers
if (headersLogger.isDebugEnabled())
{
Enumeration headers = request.getHeaderNames();
while (headers.hasMoreElements())
{
String name = (String)headers.nextElement();
headersLogger.debug(name + ": " + request.getHeader(name));
}
}
// Make sure the user is authenticated, if not throw an error to return the
// 500 Internal Server Error code back to the client
@@ -86,12 +88,12 @@ public class AjaxServlet extends BaseServlet
throw new AlfrescoRuntimeException("Servlet URL did not contain all required args: " + uri);
}
// retrieve the command from the URL
String commandName = tokens[1];
final String commandName = tokens[1];
// retrieve the binding expression from the URL
String expression = tokens[2];
final String expression = tokens[2];
// setup the faces context
FacesContext facesContext = FacesHelper.getFacesContext(request, response, getServletContext());
final FacesContext facesContext = FacesHelper.getFacesContext(request, response, getServletContext());
// start a timer
if (perfLogger.isDebugEnabled())
@@ -124,8 +126,7 @@ public class AjaxServlet extends BaseServlet
// measure the time taken
if (perfLogger.isDebugEnabled())
{
long endTime = System.currentTimeMillis();
perfLogger.debug("Time to execute command: " + (endTime - startTime) + "ms");
perfLogger.debug("Time to execute command: " + (System.currentTimeMillis() - startTime) + "ms");
}
}
}

View File

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

View File

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

View File

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

View File

@@ -29,6 +29,7 @@
//
// Initiliaze dojo requirements, tinymce, and add a hook to load the xform.
////////////////////////////////////////////////////////////////////////////////
djConfig.bindEncoding = "UTF-8";
dojo.require("dojo.debug.console");
dojo.require("dojo.date.common");
dojo.require("dojo.widget.DebugConsole");
@@ -52,7 +53,7 @@ tinyMCE.init({
width: -1,
auto_resize: false,
force_p_newlines: false,
encoding: null,
encoding: "UTF-8",
add_unload_trigger: false,
add_form_submit_trigger: false,
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)
{
@@ -756,6 +755,7 @@ dojo.declare("alfresco.xforms.PlainTextEditor",
/////////////////////////////////////////////////////////////////
// overridden methods
/////////////////////////////////////////////////////////////////
render: function(attach_point)
{
attach_point.appendChild(this.domNode);
@@ -2972,32 +2972,7 @@ dojo.declare("alfresco.xforms.Submit",
submit_buttons[i].widget = this;
dojo.event.browser.addListener(submit_buttons[i],
"onclick",
function(event)
{
if (!event.target.widget)
{
return true;
}
var xform = event.target.widget.xform;
if (xform.submitWidget && xform.submitWidget.done)
{
dojo.debug("done - doing base click on " + xform.submitWidget.currentButton.id);
xform.submitWidget.currentButton = null;
xform.submitWidget = null;
return true;
}
else
{
dojo.debug("triggering submit from handler " + event.target.id);
dojo.event.browser.stopEvent(event);
_hide_errors();
xform.submitWidget = event.target.widget;
xform.submitWidget.currentButton = event.target;
xform.submitWidget.widget.buttonClick();
return false;
}
},
this._submitButton_clickHandler,
false);
}
},
@@ -3012,6 +2987,34 @@ dojo.declare("alfresco.xforms.Submit",
this.done = false;
_hide_errors();
this.fire();
},
/** */
_submitButton_clickHandler: function(event)
{
if (!event.target.widget)
{
return true;
}
var xform = event.target.widget.xform;
if (xform.submitWidget && xform.submitWidget.done)
{
dojo.debug("done - doing base click on " + xform.submitWidget.currentButton.id);
xform.submitWidget.currentButton = null;
xform.submitWidget = null;
return true;
}
else
{
dojo.debug("triggering submit from handler " + event.target.id);
dojo.event.browser.stopEvent(event);
_hide_errors();
xform.submitWidget = event.target.widget;
xform.submitWidget.currentButton = event.target;
xform.submitWidget.widget.buttonClick();
return false;
}
}
});
@@ -3104,7 +3107,6 @@ dojo.declare("alfresco.xforms.Binding",
(_hasAttribute(this.xformsNode, alfresco_xforms_constants.XFORMS_PREFIX + ":required")
? this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":required") == "true()"
: null);
this._type =
(_hasAttribute(this.xformsNode, 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._sendHandler(req);
req.encoding = "utf-8";
dojo.io.queueBind(req);
}
@@ -4012,10 +4015,12 @@ FilePickerWidget._upload_completeHandler = function(id, path, fileName, fileType
// instance methods and properties
FilePickerWidget.prototype = {
getValue: function()
{
return this.value;
},
setValue: function(v)
{
this.value = (v == null || v.length == 0 ? null : v);
@@ -4026,6 +4031,7 @@ setValue: function(v)
this.change_callback(this);
},
setReadonly: function(r)
{
this.readonly = r;
@@ -4038,10 +4044,12 @@ setReadonly: function(r)
this._showSelectedValue();
}
},
render: function()
{
this._showSelectedValue();
},
_showStatus: function(text, isError)
{
var d = this.node.ownerDocument;
@@ -4069,6 +4077,7 @@ _showStatus: function(text, isError)
setTimeout("var _status = document.getElementById('" + this.uploadId +
"-status'); if (_status && _status) { _status.widget._hideStatus(); }", 5000);
},
_hideStatus: function()
{
if (this.statusDiv)
@@ -4091,6 +4100,7 @@ _hideStatus: function()
anim.play();
}
},
_showSelectedValue: function()
{
var d = this.node.ownerDocument;
@@ -4150,6 +4160,7 @@ _navigateToNode: function(path)
req.content.currentPath = path;
AjaxHelper.sendRequest(req);
},
_showPicker: function(data)
{
while (this.node.hasChildNodes() &&
@@ -4341,6 +4352,7 @@ _showPicker: function(data)
this.contentDiv.appendChild(row);
}
},
_createRow: function(fileName, webappRelativePath, isDirectory, fileTypeImage, rowClass)
{
var d = this.contentDiv.ownerDocument;
@@ -4417,6 +4429,7 @@ _createRow: function(fileName, webappRelativePath, isDirectory, fileTypeImage,
});
return result;
},
_hideAddContent: function()
{
if (this.addContentDiv)
@@ -4426,6 +4439,7 @@ _hideAddContent: function()
this.addContentDiv = null;
}
},
_showAddContent: function(currentPath)
{
if (this.addContentDiv)
@@ -4490,6 +4504,7 @@ _showAddContent: function(currentPath)
w);
});
},
_upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, error)
{
if (error)
@@ -4515,6 +4530,7 @@ _upload_completeHandler: function(fileName, webappRelativePath, fileTypeImage, e
this.addContentDiv = null;
}
},
_closeParentPathMenu: function()
{
if (this.parentPathMenu)
@@ -4525,6 +4541,7 @@ _closeParentPathMenu: function()
}
this.headerMenuTriggerLink.style.borderStyle = "solid";
},
_openParentPathMenu: function(target, path)
{
var d = target.ownerDocument;