SerializeJSON() and ORM watch out!

I'm not sure if this is a bug or the way ColdFusion 9.0.1 works, but today I had an issue with the way ColdFusion was serialising an ORM Entity.

I was making a simply AJAX call and in CF using serialiseJSON() method on an ORM object. My issue was that any object that had a property that was an array of other objects was not being returned.

I posted the issue on stackoverflow but then I remembered having the same issue in a Google Group Post on Taffy. I remember resolving this at the time by splitting up the object and basically recreating it again. I was about to do the same thing then on the Adobe livedocs and spotted "remotingFetch"

Quote: "If remotingFetch is false, then the value of that attribute is not sent over flash remoting. The attribute is true by default for all properties. However, for ORM CFCs where persistent = true, the value of the remotingFetch attribute is set to false, by default, for one-to-one, one-to-many, many-to-one, or many-to-many relationships. After enabling this on my relationship it fixed the issue! However as this was referred to under "flash remoting." I missed it the first time around."

After enabling this on my relationship it fixed the issue! As this was referred to under "flash remoting." I missed it the first time around. Just something to watch out for.

Sep27

API Authentication with Taffy

Recently I have been working with Taffy to create a simply REST API. The API is used by a native mobile application on the iPhone. When it was complete I needed a simply way to authentication the application talking to the API.

This is not something I was familiar with at all. I looked into lots of different methods before I started. I really did not want, nor have the experience to reinvent the wheel, so I look at current methodologies around the web.

My first attempt was BASIC authentication, but this did not feel right. For reasons I won't go into here, the API was not over HTTPS, anyone could sniff out the password. Bad, very bad!

I found a really good post by Greg Moser on AJAX Authentication with Taffy REST API. He talks about using sessions as an API key. This is a good idea, but as my application is mobile, not really applicable for my situation. However his post did get me thinking and was very helpful.

I didn't need the complexity of OAuth. I found that I liked the way Amazon secures their API. So I looked more into this approach.

I needed a simple "half OAuth" approach. Mainly without the user having to approve. This is how I got my head around it all and what I ended up with, code and explanation below.

Continue Reading

Sep22

Check file size before ColdFusion upload

I found a neat little way of checking a file size before full upload in CF by using Java io. In Java the following "file.length();" will get the number of bytes in the file. In CF you can do this...

view plain print about
1createObject("java","java.io.File").init("image.png").length()

So something like this is neat and tidy.

view plain print about
1if (createObject("java","java.io.File").init("image.png").length() gt xx)
2 return false;
3 else
4 fileUpload("D:\","#arguments.image#","","makeUnique");

There are of course many other ways of doing this, but simple things like this impress me.

Sep19

Augmented reality App: Unlocks discounts in Manchester

Gencia Media has created an augmented reality app that allows people to access discounts at Manchester retailers and leisure venues.

Users who have downloaded the free app are encouraged to find 'hearts' - with graphics inspired by the Park Inn's mosaic branding - around the city at various points of interest.

Using the GPS systems within their smartphone they can wander the city and, upon finding the pictured hearts, download and unlock offers at Tiger Tiger and Papa Gs at the Printworks, retailers such as Nicky Clarke and Calvin Klein and attractions including the Manchester Big Wheel, Manchester Ghost Walks and Manchester Museum.

More Info: http://www.how-do.co.uk/north-west-media-news/north-west-digital-media/augmented-reality-app-unlocks-discounts-in-manchester-with-park-inn-2011080410095

Aug08

Park Inn Win Offers for Manchester UK

Here's a sample itinerary involving a few of our partners. If you are planning a weekend out in Manchester over the next few weeks you really should check out the parkinnwin.co.uk website. Saving galore!

Friday
2pm Check into Park Inn by Radisson Manchester Victoria receiving your 10% discount. Offer Link
3pm Enjoy a Spa Treatment in your hotel with 25% off, plus a refreshing swim and sauna. Offer Link
6.30pm Enjoy 10% off your Dinner at the hotel Offer Link
8.30pm Watch a film at AMC Cinema for less than £5 Offer Link
11:30pm 20% off quite drinks at multi award winning Rain Bar. Offer Link

 

Saturday
10:30am Breakfast served in the hotel where you can claim your 10% discount. Offer Link
12pm Take a ride on the Manchester Big wheel and get 10% off Offer Link
1:15pm Shopping at Spinningfields Fields where you can receive discount in shops such as Calvin Klein and Cotswold Outdoor. Offer Link
4pm 25% off an ultimate hair experience at Nicky Clarke Offer Link
7pm 20% off your food and drink bill when you are dining at Papa G's in The Printworks Offer Link
8.30pm Free Entry to Tiger Tiger! . Offer Link
8.35pm Get very drunk with 50% off drink and sign song with Buy 1 get an hour feree Lucky Voice at Tiger Tiger Offer Link

Lots more offers are still being added! O, and I forgot, the biggest, a chance to win a whole years stay at the ParkInn Manchester!

Jun09

Mura: New ORM Tag Attribute

I have just been informed on the Google Group for Slatwall Ecommerce that the hardworking Mura team have push out a minor update recently. The change in version 5.4.4456 + allows you better integration for ORM within your Mura plugins. True to the style of BR, it's super easy to configure too.

Within your plugin config XML file just add the following attribute...

view plain print about
1<ormcfclocation>your path here</ormcfclocation>

You can also configure custom tags paths with the new tag attribute, which is cool! Greg and the ten24 team that created the Slatwall Ecommerce Plugin have been making real good use of this new feature. See for yourself by download at GitHub.

Apr20

CFMAP: address not valid error message solved

After some minor frustration today with CFMAP and the way it sends addresses to a geocoding service, I am now back on track. I just wanted to write a quick post for anyone else that may run into the same issue. CFMAP was leading me down the wrong path, telling me a bunch of addresses were invalid - "not found". When I directly used the geocoding functionality from Google to test the addresses i.e.

view plain print about
1"http://maps.google.com/maps/geo?q=#address#&output=csv&sensor=false&ke y#yourgooglekey#
2200,5,52.6006027,-1.1840779

Google returned "ok" status code, including the longitude and latitude details I needed. The addresses was indeed valid as far as Google was concerned. So something else was afoot.

Next, I tried the longitude and latitude values in CFMAP and excluded address attribute. This time however all my 50 markers were loaded correctly with no errors.

I looked at the Google Maps API in more detail. I found they had implemented a geolocation service that takes the address you've supplied, and then converts it to longitude etc. As it turns out this geolocation service restricts the total number of requests, per second you can make. It seems CFMAP uses this same geolocation service when you don't have longitude or latitude in your map item tag.

Looking at my own source, ColdFusion makes all the requests to this service in just one call. After the confusing error message, I was beginning to think this was my issue and not that the addresses were invalid.

Anyhow, a quick Google, and Jedi Master to the rescue! Easy when you know what to search for, right?

Ray resolved this issue by calling a CFC to get the lat and lon points, then sleeping for 500ms before continuing in the loop, he saves the results into the application scope and then keep looping, checking if it exists until he has them all in this app scope.

I decided to use this solution, but in a different way. I did not want to use the application scope because my data changes to often.

So I change my approach. I created two new fields in my database for both longitude and latitude. When my users creates a new "address" via my backend, I create the Google Geocoder V3 CFC. And then save the results to a database. As my users add events one at a time, I would not run into the restriction here... Well, I could, but it's very unlikely, right?

view plain print about
1// Geo Get Funtions
2local.geo = createObject("component", "eventManagerApp.com.utility.googlegeocoder3");
3local.geoResults = geo.googlegeocoder3(address="#rc.venueDetails.getvenueAddressLine1()# & #rc.venueDetails.getvenuePostCode()#");
4// Save Geo Function
5rc.venueDetails.setvenueLon(local.geoResults.longitude);
6rc.venueDetails.setvenueLat(local.geoResults.latitude);
7rc.venueDetails.setvenueAddressType(local.geoResults.result_type);
8// Save
9rc.venueDetails = geteventVenueService().save(entity=rc.venueDetails);

I could now use the raw longitude and latitude data without calling the geo service by using the address attribute and incurring the per second restrictions.

I loaded over 50 markers without any issues! Thank You... O, and what a run around!

Apr14

Mura CMS - Shadowbox issues

I had a few issue this morning getting shadowbox to work within my plug-in view. Maybe below will helps other with similar issues.

  • 1) Shadowbox scripts only got added by Mura to header when logged in as an administrator.
  • 2) Shadowbox will not load pages that don't have file extensions.

Both of these issues were a simple fix. Let's look at the first problem.

Shadow Box scripts were only loaded when logged in as an administrator. This is because Mura uses these scripts for the edit page function across the top when logged in. However this meant when I was logged in as a user this edit page option is not available thus Mura does not load unnecessary scripts i.e. shadowbox.js

This is good, but in my case I needed the scripts to be included in my layout. Thankfully Mura has made loading all the necessary scripts into the page very easy.

view plain print about
1cfset $.getContentRenderer().loadShadowBoxJS()/>

See I told you it was easy! - Honest that's it! Thanks Mura :)

Second issue I then had was with Shadowbox itself, not Mura.

Because I don't use file extensions (IIS rewrite) and if I did then I think index.cfm handles the loading requests anyway at /path/. This means none of my paths actually have filenames or extension, meaning they don't get loaded in to shadow box

view plain print about
1<a href="#buildURL( 'public:widget.external' )#" rel="shadowbox" >My Link</a>

Looking at the Shadowbox.js file Mura includes I could see the following lines...

view plain print about
1ext: {
2 img: ['png', 'jpg', 'jpeg', 'gif', 'bmp'],
3 qt: ['dv', 'mov', 'moov', 'movie', 'mp4'],
4 wmp: ['asf', 'wm', 'wmv'],
5 qtwmp: ['avi', 'mpg', 'mpeg'],
6 iframe: ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php',
7 'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml',
8 'txt', 'vbs']
9 }
10
11 };

The only way I could quickly solve this problem was to include a blank setting in the iframe list.

view plain print about
1ext: {
2 img: ['png', 'jpg', 'jpeg', 'gif', 'bmp'],
3 qt: ['dv', 'mov', 'moov', 'movie', 'mp4'],
4 wmp: ['asf', 'wm', 'wmv'],
5 qtwmp: ['avi', 'mpg', 'mpeg'],
6 iframe: ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php',
7 'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml',
8 'txt', 'vbs', '']
9 }

Now I know this may not be the best way going forward, and it's possible that this issues has already been address in a more recent releases of shadowbox.js. For an immediate solution it works for me.

Mar16

Mura FW/1 and ValidateThis Plugin

I had a few hours today which I set aside to learn more about FW/1 and ValidateThis. I wanted to use both of these frameworks within a Mura Plug-in I had created. I have never used ValidateThis, so I wondered how hard it would be to add it into the fw/1 Plug-in. I am not saying below is the best way, it's my first attempt and I welcome ideas :)

Continue Reading

Jan31

Mura CMS URL rewriting for Windows IIS7

It has been sometime since my post on friendly URL's in Mura CMS. A lot has changed, it's now even easier to have friendly URL's. Best of all it only takes a few seconds.

Getting rid of the siteID & index.cfm

First open the config/settings.ini.cfm file. We are interested in two settings, siteidinurls and indexfileinurls. Change both of these to 0.

view plain print about
1siteidinurls=0
2indexfileinurls=0

Note: If you get rid of siteid and plan to run more than one site on the same instance of Mura, then all you have to do is change your bindings in IIS 7 to match what you have setup for each site in Mura. Doing this means you can have each site on their own domain running from one instance of Mura, cool or what?

Now, logon to your Windows Server 2008 and install the rewriting extension found here. Install either the 32bit or 64bit depending on your OS.

Once installed, open up your Mura site in the IIS 7 Manager. Then double click on the new URL "rewrite" icon. You will now see on the right hand side under actions, an option called "Select Import Rules". Click this and enter the following in the rewrite rules box and click apply...

view plain print about
1RewriteEngine On
2RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
3RewriteRule ^([a-zA-Z0-9/-]+)$ /index.cfm%{REQUEST_URI} [PT]

Lastly restart the website and then Mura. Thats it.

Jan23

More Entries