Menu

#3 UTF-8 encoding param not working

v1.1
open
core (4)
5
2004-06-15
2004-06-15
No

in HtmlRenderer.java:
Add 3 lines:
selectURL.append("&paramCharSet=UTF-8");
branchURL.append("&paramCharSet=UTF-8");
branchURL.append("&paramCharSet=UTF-8");
for select, expand & collapse

in TreeMessageServletAdapter.java
package org.webtree.message;

import java.io.*;
import java.net.*;
import javax.servlet.http.*;

import org.webtree.*;

public class TreeMessageServletAdapter {
private static final String defaultCharSetName =
"ISO-8859-1";
private static String decodeParamValue(String pvalue,
String charSetName) throws
UnsupportedEncodingException {
String retValue = pvalue;
if (charSetName != null && retValue != null) {
retValue = URLEncoder.encode(retValue,
defaultCharSetName);
retValue = URLDecoder.decode(retValue,
charSetName);
}

return retValue;
}

public static TreeMessage build(HttpServletRequest
request) throws
UnsupportedEncodingException {
String charSetName = request.
getParameter("paramCharSet");

String collapseParam = decodeParamValue(request.
getParameter("collapse"),
charSetName);
String expandParam = decodeParamValue(request.
getParameter("expand"),
charSetName);
String selectParam = decodeParamValue(request.
getParameter("select"),
charSetName);
TreeMessage event = new TreeMessage();

if (collapseParam != null) {
event.setId(collapseParam);
event.setType(TreeMessage.MSG_COLLAPSE);
}
else if (expandParam != null) {
event.setId(expandParam);
event.setType(TreeMessage.MSG_EXPAND);
}
else if (selectParam != null) {
event.setId(selectParam);
event.setType(TreeMessage.MSG_SELECT);
}
else {
event.setId(null);
event.setType(TreeMessage.MSG_NULL);
}

return event;
}

}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.