A facelets function worked great, thanks for reminding me about that!
For anyone else interested in this, java.net.URLEncoder converts " "
into "+" as per the HTML specification for form URL encoding. I wanted
URL encoding (" " to "%20") as per the URL specification. So you do
need a bit of your own code:
public static String encode(String s) throws UnsupportedEncodingException {
return java.net.URLEncoder.encode(s, "UTF-8").replaceAll("\\+", "%20");
}
Mike Kienenberger wrote:
> If it were me, I'd create a facelets function. URLEncoder already
> provides a static method for you to hook into it, so it's just a
> matter of adding a taglib entry -- no code.
>
> http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html
>
> On 9/11/06, Dave Brondsema <[EMAIL PROTECTED]> wrote:
>>
>> The MyFaces implementation of outputLink URL-encodes the parameters, but
>> not the value. This seems correct according to the spec's javadocs for
>> outputlink.
>>
>> So is there an easy way to URL-encode the value of the outputLink? I
>> loop through a List and display the file name as text and also use the
>> file name in the outputLink. But sometimes the file name includes a '#'
>> or special character that needs to be URL-encoded.
>>
>> All I can think of now is writing an extended version of h:outputLink
>> with a encodeValue attribute. Or come up with an EL function to do it,
>> possibly using http://wiki.apache.org/myfaces/Parameters_In_EL_Functions.
>>
>> Are there any better solutions?
>>
>> --
>> Dave Brondsema
>> Software Developer
>> Cornerstone University
>>
>>
>>
>>
>
--
Dave Brondsema
Software Developer
Cornerstone University
signature.asc
Description: OpenPGP digital signature

