Railo Tip: Trimming with cfsavecontent
Random tip of the week with <cfsavecontent>:
Random tip of the week with <cfsavecontent>:
As part of the latest Railo update, the format of the task object has changed slightly so, if you have any open tasks in your Administrator (under Services > Tasks), it's probably safer to delete those tasks first, before you update. This applies only to tasks, not scheduled tasks. If you update while such tasks exist, you may encounter a null pointer exception when viewing Services > Tasks in the Administrator. To fix that, simply remove the *.tsk files from the WEB-INF/railo/client-tasks folder tree and restart Railo.
Following up with yesterday's post, there's one more gem in that old Railo documentation. Again, this has been around since Railo 2.0. We're going to make a new, yet similar example.
I was digging around in the old Railo 2.0 documentation and I came across this little gem about magic functions (getters/setters). I thought I'd take a minute to update the documentation a little bit since things have changed as we can no longer rely on this scope since it is publicly accessible.
The team has been attempting to dust off ye ol' wiki. Mark Drew recently added a Tips & Tricks section on the wiki.
In a previous blog post, I mentioned that createObject() has a 3rd / 4th argument negates the need to use Javaloader. Some questions have come up on the Railo mailing list and I thought I'd attach 2 working examples (barcode_samples.zip). One is using the Barbeque library found on Sourceforge, the other is using Google's zxing library. Remember, with a little creativity and expanding these samples, this type of code can be baked into Railo natively (e.g.: <cfbarcode>) today by placing the code in special directories (Functions / Tags).
Special thanks to Leigh's (cfsearching) excellent blog for some example legwork in barcode generation.
So, this is probably confusing to some and I thought I'd try to clear this up. It's possible to setup Railo to run a task every x hour, minute and/or even seconds. You'll want to log into your machine and go to the Scheduled Task page ( e.g.: http://{your server}/railo-context/admin/web.cfm?action=services.schedule )
Andy Jarret recently blogged about the usage of this.datasource in Application.cfc. Just goes to show, it pays off reading the patch notes sometimes because it has been there for awhile ( since version 3.1.0.018 ):
[000059] add support for default datasource to cfapplication/application.cfcGo visit Andy's blog post for more details on how to use this.application. :) Another brief note is that this may be changing slightly in the future, but will always support the ACF Style ( this.datasource = "[some string]" ).
I'm actually hesitant to post this because the Railo team is actually trying to make progress on documentation and we have some new documentation policies in place. However, I know if I don't post this and people eventually find out about it, they'll wonder why they didn't know sooner. This tip pertains to Railo's createObject('java') implementation. I'm told that it has been there for awhile, but I couldn't tell you what build it came from. I'll share the code and go from there.
<cfset object = createObject('java','path.to.package.classtoinvoke','/path/to/jar/file/on/system')>
Read that line 2 or 3 times and let it sink in a little. Yes, Railo's createObject('java') has a 3rd (and 4th) argument. This is the full documentation on this from Michael is:
createObject('java',String className,String paths, String delimiter )
- 'java' (required)
- className (required) - the full class name (class and package) of the class to invoke.
- path (optional) - a list of jar files and directory that contains class files
- delimiter (optional) - delimiter used for the path list (default is comma ",")
Sean Corfield will be presenting this to the opemcfml.org advisory board, whether it gets voted on or not remains to be seen. Also, please note that I'm making Documentation/Wiki a high priority for the year 2010.
If you've installed or upgraded to Railo 3.1.2+ and you're also using Transfer, you may (or may have already) bumped into this error:
Message: Bean creation exception during init() of transfer.TransferFactory Detail: read acccess is protected:to access the configuration without a password, you need to change the read access to [open] in the Server Administrator
To get around this issue, you'll need to do the following:
Nothing has changed in regards to code, but a decision was made to tighten down security.