cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sternath Elmar <elmar.stern...@siemens.com>
Subject AW: Umlauts in cocoon 2.0.2
Date Mon, 11 Nov 2002 07:36:21 GMT
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:jakarta@kbr-immobilien.de]
Gesendet: Sonntag, 10. November 2002 02:32
An: cocoon-users@xml.apache.org
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>

---------------------------------------------------------------------
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message