Again I think it's remarkable how closely TrimPath Junction models the Ruby on Rails framework, especially in a case like this. Just as with Rails, the code starts by putting in an error display section at the top of the page that displays any validation errors on the model. After that, we start a form tag and add fields for each of the items. Then at the bottom, there is a submit button and a link back to the main index page, as well as the end of the form tag.

It's all very easy-to-understand code, and that makes it very easy to maintain. Now, back to the web browser again, I'm going to add some valid, albeit fake, contact information and click on the OK button.

The Show Page

Adding the contact to the database brings up the show page, where we see the specified contact. This is shown in Figure 3.

Figure 3. The show page showing my fake contact

This is just like the creation page, with the exception that we aren't creating a contact, we are just viewing it. The template code is shown in Listing 7.

Just as with Rails, the content for the page is specified within whatever bounding layout you want. All you have to do is ensure that the base TrimPath Junction library is included, as it is with the script tag in the head section of the page.

Conclusion

This little demonstration of TrimPath Junction just scratches the surface of its power. Just as with a Rails demo, using the scaffolding only shows a portion of its potential. For an in-depth view, you can check out the Next Action demo application, which is a very powerful to-do list maintainer. That application works well both online and offline through use of Google Gears.

Since it requires a specific web server solution, TrimPath Junction might not be appropriate for every web application or developer. But it does certainly show the potential of what can be done with JavaScript, both on the client and server side. And it is a fascinating glimpse into the potential offered by disruptive technologies like Google's Gears and Adobe's AIR platform.

Resources

Jack Herrington
is an engineer, author and presenter who lives and works in the Bay Area. His mission is to expose his fellow engineers to new technologies. That covers a broad spectrum, from demonstrating programs that write other programs in the book Code Generation in Action. Providing techniques for building customer centered web sites in PHP Hacks. All the way writing a how-to on audio blogging called Podcasting Hacks.