You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Peter Klotz <pe...@blue-elephant-systems.com> on 2003/06/01 11:23:39 UTC

Re: R: R: R: encoding url for reader / better ways pass strings to areader?

Hi,

is the EncodeURL transformer not supposed to do exactly this?
But at least in Cooon 2.0.4 it does not seem to work, the URLs are not 
changed at all. But either way, a transformer or such a action should be 
  a integral part of Cocoon.

Peter


Andrea Pierini wrote:
[...]
>>-----Messaggio originale-----
>>Da: Bruno Dumon [mailto:bruno@outerthought.org] 
>>Inviato: venerdì 23 maggio 2003 11.09
>>A: cocoon-users@xml.apache.org
>>Oggetto: Re: R: R: encoding url for reader / better ways pass 
>>strings to areader?
>>
>>
>>On Fri, 2003-05-23 at 09:43, Andrea Pierini wrote:
>>[...]
>>
>>>************************** begin action code
>>>****************************
>>>
>>>package urlencodeaction;
>>>
>>>import org.apache.avalon.framework.parameters.Parameters;
>>>import org.apache.cocoon.acting.AbstractAction;
>>>import java.util.Map;
>>>import java.util.HashMap;
>>>import org.apache.cocoon.environment.ObjectModelHelper;
>>>import org.apache.cocoon.environment.Redirector;
>>>import org.apache.cocoon.environment.Request;
>>>import org.apache.cocoon.environment.SourceResolver;
>>>import org.xml.sax.EntityResolver;
>>>
>>>public class urlencodeaction extends AbstractAction {
>>>
>>>  public Map act (Redirector redirector,
>>>                  SourceResolver resolver,
>>>                  Map objectModel,
>>>                  String source,
>>>                  Parameters params) {
>>>    // getLogger().debug("Starting urlencode action ...");
>>>    Map sitemapParams = new HashMap();
>>>    String plainurl;
>>>    try
>>>    {
>>>        plainurl = params.getParameter("plainurl");
>>>    } catch 
>>
>>(org.apache.avalon.framework.parameters.ParameterException
>>
>>>e)
>>>    {
>>>        plainurl = "";
>>>    }
>>>    String encodedurl = plainurl.replaceAll(" ","%20");
>>>    sitemapParams.put("encodedurl", encodedurl);
>>>    /*
>>>    getLogger().debug("plainurl: "+plainurl);
>>>    getLogger().debug("encodedurl: "+encodedurl);
>>>    sitemapParams.put("test","http://localhost/hello%20world.xml");
>>>    sitemapParams.put("testplainurl", plainurl);
>>>    sitemapParams.put("testencodedurl", encodedurl);
>>>    */
>>>
>>>    return sitemapParams;
>>>  }
>>>
>>>}
>>
>>The method org.apache.cocoon.util.NetUtils.encodePath() does 
>>exactly what you need, so try changing the code as follows:
>>
>>String encodedurl = 
>>org.apache.cocoon.util.NetUtils.encodePath(plainurl);
>>
>>this is more robust, since it will also encode any other 
>>special characters.



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-users-help@xml.apache.org