Build a multi-lingual app with Quick ORM (Tamarind v1)
What you'll learn
- Use the Coldbox MVC framework to build a multi-lingual foundation application with modern object oriented ColdFusion
- Use Quick ORM, a high performance Object Relational Mapper to build a new or migrate an existing database schema
- Leverage Quick ORM and qb (query builder) to retrieve entity objects
- Add methods in our entities to enforce relationships defined in the database schema
- Write and test handler components that call methods encapsulated in our entities
- Write pre-validation rules in our handlers that check input in our views, broadcasting a message in case of error
- Create a menu navigation component
- Create a custom module called Globalization
- Implement re-usable events with the Viewlets component
- Build a dynamic menu navigation using layouts and the Viewlets component
- Build Views that let us create, read, update and delete records
- Create an interceptor component that catches invalid events and re-directs to a 404 page
- Tune qb query performance on large tables with the help of cbdebugger
- Configure the project for internationalization (i18n)
- Create a Translation builder service component that leverages Coldbox i18n module to retrieve resource bundles
- Implement an Application helper to make a single getTranslation() function available to all layouts, handlers and views
- Retrieve menu and core application translations with session loaded resource bundles for the user locale
Requirements
- It is a good idea, although not necessary, to watch the two hours foundation tutorial prior to taking this course
- The project baseline code will be provided to you for download in the Getting started section of this course
- Must have a MySQL client import utility that lets you run SQL scripts to insert up to 6000 records in a table at one go
- This course will be run on a Mac and all instructions will apply to a Mac environment
Description
This course expands on the foundation tutorial titled "Build a user login and registration foundation (Tamarind)" that was released a few months ago. We are going to build a modular application that features a component driven dynamic menu. The menu content will be stored in a navigation structure component that will be injected as a dependency in our handlers. At the end of the course, this menu and the core application will be presented in different languages by simply toggling the user locale preference in the MyAccount view where the user can edit his/her account.
We are first going to enhance our MySQL database schema with additional tables (14 altogether) and create foreign key constraints with the help of the cfmigrations module. The cfmigrations module was already briefly covered in the foundation tutorial but will be re-visited again in section 2, at the beginning of this course.
Next, we are going to build entities and map them to the database schema using Quick ORM.
From the Home page, we'll have a main menu of what we call "processes" (or features within Tamarind) such as Admin or Globalization that link to an array of sub-menu options that would remain in context or disappear dynamically from the view, as we navigate through the main menu. One of the features (Globalization) will be implemented as a Coldbox custom module. Each sub-menu option will then link to views mapped to actions defined in their corresponding handler (index, new, create, edit, update, delete), while keeping track of the current menu navigation cursor as we click around between views. We are also going to trap invalid events in our application with a Coldbox event interceptor and with methods added to the Main.cfc handler that are registered in the Coldbox configuration file to prevent users from manipulating the URL and therefore trigger exceptions.
We are then, going to customise the application layout and build a dynamic menu using the concept of re-usable events with the Viewlets handler. Working with the Viewlets component will help us explore Model-View-Controller in action, and in particular, understand the benefits of the request collection structures (RC,PRC) to exchange data between the views and the handler in conjunction with each event. Request collections constitute one of the key principles of the Coldbox MVC framework that are essential to understand.
Next, we are going to build the application Views (or forms) in conjunction with Coldbox cbValidation and cbMessagebox modules, and associate them to their respective handlers and entities.
Next, we are going to demonstrate how to use the debugger to tune the performance of our queries. Although you may query database tables directly with the qb module, the performance advantage of using qb and Quick ORM stems from performing queries on entities in memory, not on database tables to retrieve records. With the help of the debugger we will show you how to use a technique known as eager loading to improve query performance.
Finally, in the last section, we will configure our project for internationalisation (i18n). We are going to load resource bundles for the following nine locales: Arabic(UAE), English(US), English(Singapore), French(France), French(Canada), Japanese, Korean, Thai and Chinese(Singapore). Note that in Tamarind v1, our application will not generate resource bundles as the result of the maintenance of dictionary keys and their translations in the various locales, which means that the resource bundles will remain as they are, with no feature to update them.
Our menu component as well as the core of our application will then be enabled for translation in any of the nine locales above listed. We will achieve that with the creation of a Translation builder service component and by using a technique called an Application helper that will fetch a getTranslation() function from a single location in the code and make it available to our layout, our handlers and all our views.
At the end of the course, you should have acquired a solid and practical understanding of the Coldbox framework using Layouts, Modules, Entities, Handlers and Internationalisation (i18n), with proper testing using TestBox at every stage of our development. As a result, we would have delivered Tamarind, in its version 1, a real world foundation application, using basic Bootstrap for its user interface.
Who this course is for:
- Software developers, consultants and corporate power users curious about modern ColdFusion
- Developers and maintainers of legacy ColdFusion code
- Developers recognising the value of open source technology adoption
- Other language developers that are ready to learn a mature yet modern technology stack
Instructor
Philippe Sambor is a freelance instructor based in Singapore. He graduated from business school in France and started his own business in 2000. Information technology has always been an essential part of his career, albeit more in direct relation to the business than pure engineering. To him, knowing how to code has always been an essential asset as an entrepreneur.
Here is what he had to say about what motivated him to teach:
“I dedicated the recent few years acquiring the knowledge of the CFML language (also known as ColdFusion), leveraging the ColdBox CFML framework as a core server technology. CFML is a language that I came to consider for its simplicity, portability and reliability. After 25 years on the market, as long as Java (in which it is rooted), PHP or Ruby, ColdFusion evolved into the robust and modern CFML language it is today, powered by a vibrant and dynamic worldwide community. Although CFML is an easy language to pick up, writing secure, high performance and quality tested code as well as understanding all the moving parts throughout the entire stack is not. This is where I thought that my contribution to the community at large could make a difference.”