SUMMARY from 28. October
----- Original Message -----
Sent: Monday, October 28, 2002 1:48
PM
Subject: [SUMMARY] Encoding form
data
Cocoon does not support non-US characters when posting data to
the server. Characters like č (e accent grave) are translated to two
strange characters when checking the posted data. iso-8859-1 is
the default encoding for Cocoon and it does support all necessary West
European characters (thanks to Bruno for pointing this out). You can
find out more on iso-8859-1 on http://www.bbsinc.com/iso8859.html If
you need support for other characters you will need to replace iso-8859-1
with UTF-8 which has Unicode support. More on UTF can be found at http://www.columbia.edu/kermit/utf8.html
When
you create a webform and post to a pipeline that has a request generator
and an XML serializer you will see that posted data is not correctly
presented. To correct this you need to add the
request.setCharacterEncoding method to set the encoding for the request
data. This method is captured in the setCharacterEncodignAction
action.
To use it simply add
<map:action name="set-encoding"
src="org.apache.cocoon.acting.SetCharacterEncodingAction"/>
to
the action component block
Then add this at the beginning of every
pipeline that catches requested non-ASCII
data
<map:act
type="set-encoding">
<map:parameter name="form-encoding"
value="iso-8859-1"/>
</map:act>
Of course you need to replace "iso-8859-1" with
"UTF-8" if you need to use that encoding.
Another important thing
is that you must make sure the data is sent out to the browser with the
correct encoding in the first place. To achieve this add the
encoding to the XML and the (x)html serializers.
<map:serializer
mime-type="text/html" name="html"
src="org.apache.cocoon.serialization.HTMLSerializer" pool-grow="4"
pool-max="32" pool-min="4"
logger="sitemap.serializer.html">
<buffer-size>1024</buffer-size>
<encoding>iso-8859-1</encoding> </map:serializer>
This
should do it!
Have fun. Bert
This mail is written in
100% recycled
electrons.
--------------------------------------------------------------------- Please
check that your question has not already been answered in the FAQ
before posting. <http://xml.apache.org/cocoon/faq/index.html>
To
unsubscribe, e-mail: <[EMAIL PROTECTED]> For
additional commands, e-mail: <[EMAIL PROTECTED]>
----- Original Message -----
Sent: Monday, November 11, 2002 8:36
AM
Subject: AW: Umlauts in cocoon
2.0.2
Hi Braun,
I wrote an action to encode the request params
before accessing them in the sitemap:
public class
RequestEncodedParamAction extends ComposerAction implements ThreadSafe
{
public final static String
MAP_URI =
"requestURI"; public final static String
MAP_QUERY =
"requestQuery"; public final static String
MAP_CONTEXTPATH = "context";
public final static
String PARAM_PARAMETERS = "parameters"; public final
static String PARAM_DEFAULT_PREFIX = "default.";
public Map act( Redirector redirector, SourceResolver resolver, Map
objectModel, String source, Parameters param
) throws
Exception
{
Request request =
(Request)
objectModel.get(Constants.REQUEST_OBJECT);
if (request == null)
{
getLogger().error("RequestInfoAction: no request
object!");
return(null);
}
Map map = new
HashMap();
map.put(MAP_URI,
request.getRequestURI());
String query =
request.getQueryString(); if
(query != null && query.length() >
0){
map.put(MAP_QUERY, "?" + query);
}
else{
map.put(MAP_QUERY, "");
}
map.put(MAP_CONTEXTPATH,
request.getContextPath());
if ("true".equalsIgnoreCase(param.getParameter(PARAM_PARAMETERS,
null))){ Enumeration
e =
request.getParameterNames();
while(e.hasMoreElements()){
String name = (String)
e.nextElement();
String value = request.getParameter(name);
getLogger().debug("Encode
Parameter: " + name + " with value: " +
value);
if (value != null &&
!map.containsKey(name)){
map.put(name, URLEncoder.encode( value
));
} }
String[] paramNames =
param.getNames();
for (int i=0; i< paramNames.length; i++)
{ if
(paramNames[i].startsWith(PARAM_DEFAULT_PREFIX) &&
(request.getParameter(paramNames[i].substring(PARAM_DEFAULT_PREFIX.length()))
== null)) { getLogger().debug("Encode Parameter: " + paramNames[i] + " with
value: " + param.getParameter(paramNames[i]));
map.put(paramNames[i].substring(PARAM_DEFAULT_PREFIX.length()),
URLEncoder.encode(
param.getParameter(paramNames[i])));
} }
}
return(map); } }
-----Ursprüngliche
Nachricht----- Von: Braun [mailto:[EMAIL PROTECTED]] Gesendet:
Sonntag, 10. November 2002 02:32 An: [EMAIL PROTECTED] Betreff:
Umlauts in cocoon 2.0.2
I have the problem with german Umlauts in
request parameters. When I transfer german Umlauts by request paramaters
cocoon doesn't decode the Umlauts encoding when I use these Umlauts in my
xml-documents or stylesheets. I set already all my encodings to
ISO-8859-1.
--------------------------------------------------------------------- Please
check that your question has not already been answered in the FAQ
before posting. <http://xml.apache.org/cocoon/faq/index.html>
To
unsubscribe, e-mail: <[EMAIL PROTECTED]> For
additional commands, e-mail: <[EMAIL PROTECTED]>
--------------------------------------------------------------------- Please
check that your question has not already been answered in the FAQ
before posting. <http://xml.apache.org/cocoon/faq/index.html>
To
unsubscribe, e-mail: <[EMAIL PROTECTED]> For
additional commands, e-mail: <[EMAIL PROTECTED]>
|