Referencing original built-in tag/function from tag that overrides it.

30 views
Skip to first unread message

Bruce Kirkpatrick

unread,
Dec 1, 2011, 1:31:53 PM12/1/11
to Railo
I was made aware that this feature exists.
http://wiki.getrailo.org/wiki/TIPS:BuiltInTag

I read the 4 blog posts and comments and I don't see a way to call the
original built-in tag/function.

I want to do a wrapper on the existing function, not reinvent it.

Can someone provide docs or tell me if the feature doesn't exist?

I used cfc approach and dumped the init function arguments, the super
scope and the this scope and there was no reference to the original
built-in object.

It seems like the init function should get passed a value that
references the original tag/function allow me to to extend my
component from the railo base classes and call super the methods.

Bruce Kirkpatrick

unread,
Dec 1, 2011, 1:36:49 PM12/1/11
to Railo
Michael had attached an example.tld and mentioned fld files. When I
look in the server folders, these folders are empty. How would I be
able to generate these files for the other features. It looks like
you could rename the core functions and retain their features using
this format.

Is this documented somewhere? Are the inside one of the railo jars or
something? I don't know where this information is coming from.

Stuff like this would be hard to recreate:
<name>File</name>
<tag-class>railo.runtime.tag.FileTag</tag-class>
<tte-class>railo.transformer.cfml.evaluator.impl.File</tte-class>

Todd Rafferty

unread,
Dec 1, 2011, 1:37:58 PM12/1/11
to ra...@googlegroups.com
Doesn't exist. I requested this feature awhile ago:
--
~Todd Rafferty
Volunteer
Community Manager
Railo Server - Open Source
----

Bruce Kirkpatrick

unread,
Dec 1, 2011, 1:41:39 PM12/1/11
to Railo
I looked in railo.jar and it seems like I'd have to get the source and
compile railo myself to do this perhaps since those are just compiled
classes?

Any chance of making it a feature?

Bruce Kirkpatrick

unread,
Dec 1, 2011, 1:44:34 PM12/1/11
to Railo
Todd,

I commented and put 3 votes on your feature request.

Peter Boughton

unread,
Dec 1, 2011, 1:45:41 PM12/1/11
to ra...@googlegroups.com
Bruce wrote:
> When I look in the server folders, these folders are empty.
> How would I be able to generate these files for the other features.

Do you have an RC file in your patches directory?

If so, you can open that with a zip application and look in
resource/tld to find the .tld file that (looks like it) contains all
the tags.

Peter Boughton

unread,
Dec 1, 2011, 1:46:57 PM12/1/11
to ra...@googlegroups.com
Forgot to say, if you don't have an RC file in your patches dir, you
can scroll to the bottom of the downloads page and get it from there.

Bruce Kirkpatrick

unread,
Dec 1, 2011, 2:03:33 PM12/1/11
to Railo
Peter, I was able to do this and I put the xml below in this
location: /opt/railo/lib/railo-server/context/library/fld/
fileCopy2.tld and it doesn't seem to do anything after restarting
railo. fileCopy2 function doesn't exist.

Do I need to modify the patch zip with a new version number and
manually apply the patch?

The next question would be how do you do a custom update provider url
so I can apply my custom rc or does it work just having it exist in
the filesystem?

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE func-lib PUBLIC "-//Railo//DTD CFML Function Library 1.0//
EN"
"dtd/web-cfmfunctionlibrary_1_0.dtd">
<func-lib>
<flib-version>1.00</flib-version>
<short-name>fbase2</short-name>
<uri>http://www.railo-technologies.com/cf-fld-3-1</uri>
<display-name>Railo Core Function Library2</display-name>
<description>All build in Functions of Railo2</description>
<!-- fileCopy2 -->
<function>
<name>fileCopy2</name>
<class>railo.runtime.functions.file.FileCopy</class>
<description>Copies the specified on-disk or in-memory source file
to the specified destination file.</description>
<argument>
<name>source</name>
<type>any</type>
<required>Yes</required>
<description>path to copy.</description>
</argument>
<argument>
<name>destination</name>
<type>any</type>
<required>Yes</required>
<description>Pathname of the destination file.</description>
</argument>
<return>
<type>void</type>
</return>
</function>
</func-lib>

Bruce Kirkpatrick

unread,
Dec 1, 2011, 4:12:40 PM12/1/11
to Railo
OK, I tried to do what I said and found, yes, I can modify an existing
patch file and restarting railo will apply the changes.

It appears that this is a feature after all. I guess todd must be
wanting a way to do this without restarting railo perhaps?

I found that I was unable to override fileCopy until I renamed the
original in the fld file in the /opt/railo/lib/railo-server/patches/
3.3.1.000.rc file.

I extracted and edited the xml in web-cfmfunctionlibrary_1_0 from
resource/functions/ and then put the new file back in the zip.

The way to extend built-in functions / tags is to rename them first
using the xml file in the current patch. Then you can call
fileCopy2 inside your custom filecopy.


Here is an example of my custom filecopy function:

<cffunction name="filecopy" output="yes">
<cfargument name="arg1" type="string" required="yes">
<cfargument name="arg2" type="string" required="yes">
test output
<cfscript>
return filecopy2(arg1, arg2);
</cfscript>
</cffunction>

The file did get copied and the output message also occured.

Andrea Campolonghi

unread,
Dec 1, 2011, 4:35:18 PM12/1/11
to ra...@googlegroups.com
Bruce.

This works but will be overwritten the next time you apply a railo update.
A new rc file will replace the ones you are hacking now and you will have to repply your chnages.

Andrea

Andrea Campolonghi
and...@getrailo.org

Bruce Kirkpatrick

unread,
Dec 1, 2011, 5:13:38 PM12/1/11
to Railo
You're right of course. The process of updating the rc can be
automated though with simple string replace and zip i/o functions to
minimize the effort for re-patching the patch.

Peter Boughton

unread,
Dec 1, 2011, 5:42:16 PM12/1/11
to ra...@googlegroups.com
My impression was that it should not be required to change the
existing RC, you should just be able to put your own FLD/TLD file
there, restart Railo, and it should work.

I guess Micha can confirm if that's intended behaviour or not.


What Todd is asking for is to be able to do this without FLD/TLD files at all.

<cffunction name="FileCopy" output="false">
<cfif SomeCondition>
... Do Something Different ...
<cfelse>
<!--- Somehow call standard version. --->
<cfreturn FileCopy(ArgumentCollection=Arguments) />
</cfif>
</cffunction>

Oh, and just to highlight there ArgumentCollection=Arguments -
whenever you're just shifting args around you should do that, because
it makes your code more futureproof against the arrival of new
arguments.

Bruce Kirkpatrick

unread,
Dec 1, 2011, 6:11:56 PM12/1/11
to Railo
I can't reproduce my problem with the FLD/TLD/FUNCTIONS global or web-
inf folders now. The RC change is only for renaming the existing tags/
functions. I don't know why I had the problem before.
Reply all
Reply to author
Forward
0 new messages