Enter your email address to subscribe to this blog.

Recent Comments

Intro to Spring Security Core for Grails
Eric Pierce said: Thanks for these screencasts, Dan! You made it crazy simple to get up and running w/security core h... [More]

Removing duplicates from an array of objects
Arvind said: Great tip, can't thank you enough for this. [More]

Intro to Spring Security Core for Grails
Santosh said: Thanks much for putting up these screencasts. As the others here I'm a beginner and I've been having... [More]

Grails Spring Security Plugin - Logout postOnly setting
eriihine said: I still had some issues with this one. It seems that the href link is always generating a GET method... [More]

Intro to Spring Security Core for Grails
Dan Vega said: Just a heads up but I decided to write up a quick post on your question just in case it trips up any... [More]

Getting Start with Mura CMS

I have really started to dive into Mura lately and hopefully this will be the first post of many to come. If you have not had a chance to check out Mura CMS there is no time like the present. Mura has some really cool features but what really gets me is how easy it is to use. I have the ColdFusion Jedi himself comment a couple times on how easy Mura is to setup and I really have to agree with him. There is nothing better to me then when a product just works like this, it really makes it easier to work with. I also had the pleasure of having dinner & drinks with the guys from Mura at cfObjective() and they are really a great group. What are you waiting for, head over to the website and download Mura CMS now! If anyone has some installation questions let me know, maybe ill create a quick install video if folks need it.

Flex user defined runtime settings Part 2

In the 1st part of this series we looked at the thought process of using dynamic settings in Flex. In part 2 I want to focus on the implementation of reading in an XML file. While you can find many articles out there about reading XML files this article will focus on the problems of web minded thinking. When I first started this project I that prompted this post  I thought, reading a settings file and using the values, that's easy enough. Before we look at a solution we need to take a quick look at the wrong solution. Coming from a web background my mind is very top down procedure driven so I figured this would work. I would create a creation complete event, read in the settings file and use the values. In this example I want to read my settings file and use the panel title setting in my application.

Continue Reading >>


Flex user defined runtime settings Part 1

If you are looking to start developing Flex applications and you are coming from the web world you will hear the following statement many times. It takes time to get your head around the event model versus a traditional web request. This is so true and it can't be stressed enough, stop thinking to yourself how would I do this in (insert you preference here). So that kind of ties in to what I wanted to talk about. After you get a few smaller applications under your belt you start to realize that you need to a way get preferences / settings that a user can set. These are called runtime variables because you don't have to recompile the Flex application when these values change. There are two ways (that I know of) about going about this. You can read in a file such as an XML file or you could use flash vars.

This article is going to focus on reading in a XML file but I  hope to follow it up with a how to on flash vars because they can be very useful as well. For this tutorial we are going to create a config directory under our src folder. In the config directory we will create a simple XML file that contains some application settings.

The first thing most new developers will do is to read in the XML file using the Flex XML tag. If you were to run the example it would work just fine with 1 small problem. This tag is actually a compile time tag which means that when you compile the application the XML is included. You will not be able to change the file after it has been compiled. This obviously will not work as we need the ability for users to change settings without having to recompile the application. So that leaves us with actually reading in the XML file.

This is actually the solution we are looking for but its a little more than just reading the file. Coming from the web world and writing creation Complete events for all of my small applications I thought this would be easy as Sunday morning. The following is pretty basic code that we have all written at one time or another. The problem with this is we can read in our file but if we go to get the actual values right after that line they may not be ready yet. This all goes back to the idea that you need stop thinking of top down programming. We actually need to read in the settings file and than dispatch an event that the configuration file has been loaded. We can then then listen for that event and get our settings when its ready.

In part 2 of this article we will go  through the actual code that consists of a custom class and a custom event class. Any thoughts or comments please let me know.


CFMU 2 quick updates

I got some good suggestions as far as additions go and thought I would throw in 2 quick ones in today. The first is being able to set a max file size in the settings file. By default the max file size is 0 and if you don't change it then its up to the flash player to set the limit. If the user tries to upload a file that is greater than the max file size (measured in bytes) they will get an alert telling them they have exceeded the limit. So once you set a file limit how do we implement it? First off we need to look at how the browse process works.

1.) User clicks browse button
2.) onBrowse Event handler method is called
3.) Create a file reference list
4.) Add a Select event listener
5.) Call the file reference list browse method

Once the browse method is called the OS opens the open dialog box.  Once a user selects a file or files the onSelectFile method is called. Now we have to loop through a list of files, if the user only selects one file then we will only do 1 loop. For each iteration we check check to see if the max file size is 0 (default) if so we just add the file to the array collection. If its not we check to see if the size exceeds our limit. If it does we display a friendly error message letting the user know what happened.

The second update was to allow for removing of multiple files which I covered in the  last post


Removing items from a Data Grid

You may see many posts like this coming from me and to anyone who does Flex development will probably not get much out of them. With that being said for those of us still learning here is a quick tip for removing data from a data grid. In my latest project CFMU the browse button allows you to select a single file or multiple files to be uploaded. At the time I released the project the data grid did not allow multiple selections so if you wanted to remove an item before uploading you had to do it one at a time. This was pretty because all you had to do was reference the selectedIndex of the data grid. When the user selects a file the remove button is enabled and when the remove button is clicked the onRemove method is called.

This worked great but a user suggested that he should be able to remove multiple items at once. I agree and this actually a pretty easy fix. The first thing we need to do is allow a user to select multiple files once they are added to the data grid. The data grid tag has an attribute allowMultipleSelection that accepts a boolean.

Now that the user can select multiple files we need to update our remove method to delete multiple files. We know that calling selectedIndex will tell us what item is selected but the dg also has a property called selectedIndicies. As you can expect this will return an array of selected indexes. To update our remove method all we need to do is loop over that array remove each item.


More Entries