URL-encode the result of <bdm:display>

X-Application Version: 3.1.1
Tamino Version : 3.1.1
Platform : Win2k
WebContainer : Tomcat 3.3
JDK Version : 1.4

I would like to URL-encode the result of the bdm:display tag, because i need it for a link …

How can I reach this, e.g. for this output:
<bdm:display select=“/meta-info/autor”/> ?

Any suggestions ?


Ralf

Hello,

my propose is a plugin to overload the display method ?getValue? for the element you want to encode. In your case, write your class with a static display method for the author element, e.g.

<BR>Package ... <BR><BR>import java.net.URLEncoder;<BR><BR>public class MyClass {<BR><BR>    public String displayAuthor(Element author) {<BR>        return URLEncoder.encode(author.getText());<BR>    }<BR><BR>}<BR></pre><BR><BR><BR>Register the Plugin within the xapplication.xml file of your application, e.g.<BR><BR><pre class="ip-ubbcode-code-pre"><BR><plugin><BR>   ...<BR>   <element name=?author?><BR>       <action name=?getValue?<BR>               method=?...MyClass.displayAuthor? /><BR>   </element><BR>   ...<BR></plugin><BR>



For more information about plugins have a look at the documentation of X-Application.

Bye,
Christian.

Hello !

I would like to realize the URL-encoding with the URLEncoder-Class:

<a href=“http://www.server.de/filename.jsp?
<%= java.net.URLEncoder.encode(“firstname lastname”) %>”>Link

results, as assumed, to

http://www.server.de/filename.jsp?firstname+lastname

But the problem is, that

<a href=“http://www.server.de/filename.jsp?<%= java.net.URLEncoder.encode(”<bdm:display select=‘/meta-info/autor’/>“) %>”>Link

results to:

http://www.server.de/filename.jsp?<bdm%3Adisplay+select%3D’%2Fmeta-info%2Fautor’%2F>

because “<bdm:display …” is interpreted as a normal string.

And without the " an error messsage occurs:
Missing term.out.print( java.net.URLEncoder.encode() );

Link


Ralf

Hi Ralf,

I think Christian was proposing that the encoding is done via a plugin, so you would automatically get the URL encoded value of Author, when you do the bdm:display.

So, you would be able to say

<a href="http://www.server.de/filename.jsp?<bdm:display select=‘/meta-info/autor’/>Link

and the value of ‘/meta-info/autor’ would already be URL encoded, courtesy of the plugin.

This is nice since it keeps the business logic (Java code) separate from the presentation.

However, there is also an alternative approach.
You could assign the value of the bdm:display tag to a JSP variable, and then URL encode it.

To do this, you need to install the “SetVariable”
tag. See the following link.

Set Variable

You could then say:

<t:SetVariable name=“autor” create=“true”>
<bdm:display select=‘/meta-info/autor’/>
</t:SetVariable>

Link

Hope this helps!

Good luck and best regards,
Puny Sen

Hello !

> To do this, you need to install the
> “SetVariable” tag. See the following link.

All works very fine after the installation of the TagLib. Thanks for the tip, Puny Sen !

If I have more time, I will try the propose of Christian …

One questin in advance:
Is it possible with the overload of the display method to select, which result is URL-encoded ?

<a href=“
http://www.server.de/filename.jsp?
<bdm:display select=‘/meta-info/autor’/>
”>
<bdm:display select=‘/meta-info/autor’/>


In the href=" … " I need the bdm:display result URL-encoded , and as the text of the link not encoded.

It would be very nice to have something like:

<a href=“
http://www.server.de/filename.jsp?
<bdm:display-URL select=‘/meta-info/autor’/>
”>
<bdm:display select=‘/meta-info/autor’/>



Ralf