Friday, June 27, 2008

PureMVC Argument

So me and the other people in my team got in a small argument over the proper use of PureMVC's mediators. We've read in various blogs that it is not a good practice to call a Proxy directly from a mediator. If you're going to call a proxy, it needs to be done from a command. In this particular case, we're asking for the proxy to refresh some data. That's it... one call. someProxy.refresh(). The refresh will send it's notification and our mediator will update. So one of my coworkers wanted to register a command that called someProxy.refresh() and then send a notification from the mediator. If there was some business logic that needed to happen, I'd be all for it! But there isn't, we're just refreshing an array collection. So someone please tell me why should I register a command to call a proxy in this case? And to further my point, the employee admin demo on PureMVC's official website does exactly what I'm describing in RolePanelMediator.as private function onAddRole( event:Event ):void { roleProxy.addRoleToUser( rolePanel.user, rolePanel.selectedRole ); } private function onRemoveRole( event:Event ):void { roleProxy.removeRoleFromUser( rolePanel.user, rolePanel.selectedRole ); } I am not a very stubborn person. if someone can make a good point for why I shouldn't do it this way, then I'll change my ways. I promise.

Labels: , , , , , ,

Wednesday, June 25, 2008

Are your scrollbars not working in Flex?

In the Flex 3 SDK flex framework I found a minor little bug. When you set the "maxScrollPosition" on a scrollbar object, it doesn't actually change the scrollbar! Why? Well let's look at the code. Found this in Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\projects\framework\src\mx\controls\scrollClasses /** * @private */ public function set maxScrollPosition(value:Number):void { _maxScrollPosition = value; } What's missing here? Just one line of code, invalidateDisplayList(). This function tells the UI component that something has changed and it needs to be redrawn. There are a few ways to fix this. One, you can change the Flex SDK to fix the problem (but I don't recommend this). Two, you can extend the VScrollBar or HScrollBar components and override public function set maxScrollPosition to include it. And finally, just put myScrollBar.invalidateDisplayList() anytime you update the scrollbar in your application.

PureMVC explained in a simple manor

Whatever you do, don't look at the diagram on PureMVC's website. It will just confuse the hell out of you. I'm about to explain PureMVC as I understand it in the simplest manor. If my explanation is incorrect, let me know so I can correct it. [insert marketing about how great PureMVC is here]. So you have the "model" the "view" and the "controller". Controller's do stuff, the model is stuff, and the view shows the stuff. PureMVC is just a way to orchestrate all that... well... stuff! The bases of how that happens is by sending "notifications." A notification in PureMVC is pretty much like an event. You send these events from two places, the "mode" through something called a "proxy" and the "view" with something called a "mediator." When these notifications get sent out, the "Controller" catches them and executes a "command." So the "controller" is the go-between the two. The "Facade" is just something that kinda sits above it all. Now the "mediator" is allowed to control things relating to how the view is displayed, which view is displayed etc. But any business logic happens in the "command" which is the controller. You can still use regular events too... but only between the view and the mediator. Then you'll want to send a notification. Here's a quick example. Let's say you want to "add a user" from a view. You would create the user object, add it to the body of a notification, send that notification. The application facade knows which controller these notifications go to (because you tell it). The command calls the proxy (remember that the proxy is how you interact with the model) and tells it to add the user. The proxy sends a notification when this is complete. The command might do an alert that says "user added". Make sense? Or did I totally confuse you? To be honest, I'm really writing this to help me understand pureMVC better. On my next post, I think I'm going to do ASFusion's MATE. Hopefully this paragraph will make things a little simpler when you go to look at some PureMVC examples.

Monday, June 16, 2008

ColdFusion and Blogger

A lot of ColdFusion bloggers use BlogCFC. I think BlogCFC is great, but I've always used Blogger and it works great with ColdFusion. Blogger's got some key features built in that I like just a little bit more than BlogCFC, and it also seems to get indexed in search engines faster. So how do you use Blogger with ColdFusion? It's simple! Just set your blogger account to publish to your ColdFusion server via FTP. Then edit your template to include a header and footer file built in ColdFusion. I used cfimport and a single customtag which renders my layout. The last step is to change your publishing file name to "index.cfm" or "blog.cfm." Now all of your files get published with the CFM extension, so any CF code in your template will be rendered like ColdFusion.

Labels: ,

Feed (RSS/Atom)

Contact Me

Don't put anything here: