It says that it was added in VelocityTools 1.3. When I try to type it in Workbench, it doesn’t show up in help menu when you type in a $tools.esc. I don’t see the url method, but do see others such as http, xml, and so on. When I try to use it, it just outputs the code directly and isn’t interpreted during assembly. Does Percussion not support this?
Your correct that our implementation of Velocity tools is a little behind, although Velocity like some of the other technologies we use, is a bit of a moving target.
This simplest path is to write your own JEXL function. This takes only a few minutes to do, and doesn’t even require you to restart the server.
As of Java 5, the java.net.URLEncoder class now works properly across all characters: just make sure you specify UTF-8 as the character encoding.
I’ve been trying to find some example java source in the rx tree, but can’t seem to find anything. I did find some document that stated I would need to extend the interface IPSJexlExpression to write my own function extension. Also, I read where to register the extension in Workbench. Can you provide any example source that could provide me with a skeleton to work with?
First, your class must implement the correct Interface…
public class PSOBase64Codec extends PSJexlUtilBase implements IPSJexlExpression
Then you need a method which returns a value. It has to be annotated with @IPSJexlMethod and @IPSJexlParam annotations.
@IPSJexlMethod(description="Encode a binary property",
params={
@IPSJexlParam(name="source", description="binary property to encode")})
public String encode(Property jcrProperty) throws ValueFormatException, RepositoryException
{
if(jcrProperty == null)
{
log.debug("Property is null, no base64 encoding is possible" );
return null;
}
return encode(jcrProperty.getStream());
}
If you’re not familiar with Java 5 annotations, this can be a little confusing. The @IPSJexlParams are an Array, so they have to be enclosed in curly braces {} and separated with commas.
Would it be possible for Fernando or someone from Rhythmyx to post the code necessary to enable URL Encoding? I’m not a Java programmer :o and need to replace spaces with the %20 character.
If there’s another solution that would be appreciated. We’re running Rx6.1.
Thanks,
Geoffrey
Step 3) In the folder C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\lib, remove the velocity-tools-1.2.jar (keep a backup copy) and replace it with the velocity-tools-1.4.jar that you downloaded. (It would seem that velocity-tools-view-1.4.jar might also work, but I didn’t try it).
Step 4) In the folder C:\Rhythmyx\AppServer\server\rx\deploy\rxapp.ear\rxapp.war\WEB-INF\config\velocity edit the tools.xml file. Add these 4 lines to the bottom of the file, just before </toolbox>
Note that this file will get overwritten when you run the installer, so keep a copy someplace safe for future reference.
Step 5) Restart the server. In the workbench, you should see $tools.esc in the “code completion” window.
It’s also possible that some of the other new tools (e.g. the DateComparison tool) might also work, but I haven’t tried them yet.
The current plan is to replace the Velocity 1.4 and Velocity Tools 1.2 with Velocity 1.5 and Velocity Tools 1.4 in the next release of Rhythmyx (tentatively Rhythmyx 6.6)