Generating Code for mojoPortal with Codesmith
If you have the mojoPortal source code, we have a number of Codesmtih templates for code generation that can be used to jump start your development. They are located in the CodesmithTemplates folder. You can still download the older freeware version of Codesmith 2.6, though I highly recommend getting the newer version from http://www.codesmithtools.com/, most of our templates do still work with the older freeware version.
About the mojoPortal Codesmith Templates
We've created a variety of Codesmith templates that we use in mojoPortal development to provide a jump start on development and save a lot of typing. The output of our templates is meant only as a starting point, it is expected that you will modify the generated code to meet your needs, we don't typically re-generate for example if we add a column to a database table, our scripts are generally for initial development, if we add a column to the table then we modify our previously generated code by hand to include the new column.
Most of the templates are designed to point at a database table and generate code based on the table. Typically we develop first against MS SQL tables and we implement the other data layers after we complete the implementation of a feature for MS SQL.
Once you have defined your table (it must have a primary key), we have templates for generating stored procedures, a data access class and a business class that uses the data access class. The templates are designed such that if you just use them as they are the business and data access classes will compile and work providing basic CRUD operations (Create, Retrieve, Update, Delete). However, it is recommended that you review and modify the generated code, it is not meant to be a final best solution. For example, if your table has a DateCreated field and a LastModified field, the templates will generate code that updates all fields, but typically I will remove the CreatedDate from the update methods because I don't want to update that field, I prefer it is only set on insert not on updates and the templates do not account for those nuances.
We also have templates that help us implement support for all the database platforms supported by mojoPortal. For example, we have templates that you can point at an MS SQL table and generate the corresponding table script for MySql, SQL CE, PostgreSql, Firebird Sql, and SQLite. There are also templates for generating data access code for each of these database platforms.
Additionally we have some templates that help generate some starter UI code for edit forms and grids, and there are a few templates that just generate some starter UI code for Modules and Pages. These starter module and page templates don't use any database table, they just generate boiler plate code for stubbing out new modules and pages.
You can also watch this training video to learn more about using Codesmith to get a jump start on your results.
Getting a Jump Start on mojoPortal Development with Codesmith Tools and Code Generation
Videos 12 and 13 in our Developer Series also has coverage of how to use Codesmith
Last Updated 2010-08-30