Entries for month: May 2010

ColdBox Plugins - A wealth of hidden treasure

Alliance , Plugins , Tips & Tricks 3 Comments »

Today I was getting ready to send a file from my app to the browser for the user to download.  I was all set to use cfcontent to do this, but knowing ColdBox I thought I would do a quick check to see if the framework had any nice convenience methods for me to use to make life easier and sure enough... sendFile() in the core Utilities plugin.

getPlugin("Utilities").sendFile(file="test.txt");

So, this post is just a quick word of advice.  Don't reinvent the wheel.  If you are doing something, anything common, check the docs and see if ColdBox can do it for you.  You will be amazed at whats available in the core plugin set already for you to use.  

Plug it In

Plug IT IN

Here are just a few I use commonly.

ORMService - generic ORM Service helper for Hibernate
QueryHelper - all sorts of goodies in here, sorting queries is one of my favorite. Or the querySim.
Validator - all sorts of standard validation methods here. checkEmail and checkIPAddress are my favorites.
FileUtils - This is a utilities library that are file related. Lots of fun methods here.
Utilities - A good mix of a variety of handy methods, like todays gem sendFile()

 

Read more...

ColdBox Support-Mentoring Program Now Available!

Community , News No Comments »

I am very pleased to announce the new Ortus Solutions website and our new professional support and mentoring program. The Support Subscription Program is an incident assistance service that can provide you with sanity checks, code analysis, architectural reviews, professional support, custom development and much more.  We have a state of the art electronic helpdesk, a private knowledgebase, customer advisory boards and even some cool new products coming down the pipe. So not only do you get professional support with our subscription but you can also get custom development, architecture analysis, and so much more.  Check out some assistance topics:

  • Have a question about ColdBox compatibility?
  • How does a plugin/interceptor work?
  • How do you extend the framework?
  • Sanity checks
  • Coding best practices
  • Project pre-analysis
  • Architecture reviews
  • OO Modeling and Coaching
  • Application Scalability
  • How do I create CodexWiki plugins?
  • I need features for CodexWiki
  • So much more...

What do you get with the ColdBox Professional Support Program?

  • Online incident system
  • Online private knowledgebase
  • Priority patches & updates +
  • Product defect escalations +
  • Custom builds +
  • Up to 15% off training discounts +
  • Up to 20% off book discounts +
  • Influence the development direction of the ColdBox Platform +
  • Access to the ColdBox Platform and CodexWiki Client Advisory Boards +
  • Custom plugin/interceptor development *
  • Enhancement development requests *
  • Phone/Skype support by appointment only**+
  • Assistance can be given in the following languages:
  • English, Spanish or Brazilian Portuguese

* Please see the FAQ about custom development.

** All assistance is done electronically via our ticketing system. Skype/Connect sessions can be scheduled by appointment only, for certain support plans.

*** All incidents are charged on a per hour basis.

+ Depends on annual subscription plan

Unit Testing with Mock Objects via MockBox

MockBox , Tutorials , Walkthroughs 1 Comment »

Once you get an appreciation for the importance of unit testing and integration testing is when we reach a new level in our development careers.  Testing is critical to mission critical applications, and even for our own little projects, where we test that our code should work as expected.  There’s that word again, expected.  Expectations in unit testing is like a nasty hamburger at a soccer match in El Salvador.  They go hand in hand :)

Read more...

ColdBox London, UK Training Next Week Still Open

No Comments »

Next week is Scotch on the Rocks and immediately following the conference we will be holding our 3 day ColdBox Training marathon. If you have not attended one of our seminars, well you should, they are intense,fun and a great way to learn. Doug Boude puts it best here in his blog: http://www.dougboude.com/blog/1/2009/11/Coldbox-101-Training-Review.cfm

If you are doing Coldbox development and you have not attended Luis' Coldbox 101 training class, I guarantee you that what you are writing is not all that it could be. It won't be architected as well as it could be, it won't be leveraging all of the shortcuts and features that it could be, and it won't be top of the line. That isn't to say that you aren't capable of writing a good Coldbox app, but without the in-depth understandings that this class offers, your app will very likely not be a great Coldbox app.

If you are serious about writing solid, load-bearing apps in Coldbox, do this for yourself: attend Coldbox 101 training.

We still got a few seats left and we close registration this FRIDAY!!  So hurry and book your seat today: http://coldbox-uk.eventbrite.com/?discount=vivaUK

ColdBox REST Enabled URLs

Tips & Tricks , Tutorials , Walkthroughs No Comments »

Thanks to our 3.0.0 milestones, the SES capabilities have been really fine tuned and added some great concepts in order to enable it for more RESTful applications.  We have added things like:

  • -alpha : Alpha only placeholders
  • {X} : Digit quantifiers for all placeholders
  • constraints : A separate structure where you can give any placeholder your own regular expression
  • RESTful actions : A way to split actions according to the incoming HTTP method

The last one is what we will concentrate on.  In true RESTful style URLs, we must concentrate on the concept of resources or endpoints we are trying to describe.  Say: http://www.example.com/users  most likely will represent users, but we could also have: http://www.example.com/users/lmajano which describes a user but with a more detailed part which is lmajano.

Requests and responses are built around the transfer of "representations" of "resources"

"Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use."

It is also important to note that REST is a style of URL architecture not a mandate, so it is an open avenue of sorts.  However, you must stay true to its concepts of resources and usage of the HTTP verbs.  Here are a few pointers when using the HTTP verbs:

  • POST : Create a resource
  • GET : Retrieve a resource(s)
  • PUT : Update a resource
  • DELETE : delete a resource

So examples for true RESTful URLs:

  • GET /users
    return a list of users
  • GET /users/lmajano
    return the representation of user lmajano
  • POST /users
    create a new user with post data
  • PUT /users/lmajano
    Update the lmajano user
  • DELETE /users/lmajano
    Delete the lmajano user

So how can we do this in ColdBox? Very easily! The new 3.0.0 SES interceptor allows for a pattern to be bounded to a handler and a structure of actions that match the incoming HTTP verbs:

// User representation

addRoute(pattern="users/:user",    
handler="rest.Users",    
action={    
GET = "show",    
POST = "create",    
DELETE = "remove",    
HEAD = "info"    
});

 

As you can see, the action argument can be a structure or a JSON structure of mappings between HTTP verbs and the action method you wish to fire whenever the resource is accessed with that method.  So if I go to /users/lmajano with a DELETE, then we will execute: rest.Users.remove().  So the approach of binding HTTP verbs to the correct actions, can give us TRUE RESTful URLs instead of us trying to create tons of URL representations and always using POST and GET. 

In conclusion, ColdBox 3.0.0 adheres to the standard RESTful principles and gives you a way to do HTTP verb to action mappings very easily when creating your resource URLs.  Stay tuned for more information on other useful RESTful features we have on 3.0 like:

  • HTTP method security right from within your handlers
  • onError() conventions when RESTful handlers throw exceptions
  • Request context updates to retrieve headers and content
  • Much more