the new major release of asp ajaxed is here. I have jumped with counting to version 1.0 because it has been such a big update and the library reached its maturity level. Curious whats new in the box? A lot of improvements and new stuff – i got a lot of inspiration from ruby on rails as well and the biggest goodie is an own developer console with unit tests, documentation creator…
For all who cannot wait go directly to the download and update to the new version.
Ok, so whats new in 1.0? I have aggregated all the comments and tried to implement all your requests. As I am developing with Ruby on Rails, I have added some rubyism to the whole library as well. Do I have to change my running system completely now? No! no need to panick. There are only two small things you need to prepare before upgrading to 1.0 (mentioned at the end of the article). Ok, let’s move to the updates…
Probably the most fancy update is the new ajaxed console which supports you while you develop your applications. its immediately available through
/ajaxed/console/ on your server. You’ll find there a lot of useful stuff like a test runner, current configuration, documentation creator, regular expression evaluator, etc. Check a demo of the console here
New ajaxed config
The ajaxed config (
config.asp) has been moved to an own folder which is located in the webroot
/ajaxedConfig/config.asp. Seperating the configuration from the library makes the update process easier now. You can overwrite the ajaxed library without any thoughts…
html, head and body tags integration (header & footer)
People used to have problems of integrating the html, head and body tags into their pages. This has been solved now and you can find a
footer.asp in your ajaxedConfig folder. Those files are automatically loaded within your pages. This change brought some additional features as well
ajaxedPage.defaultStructureproperty lets you load your page with a default header and footer (provided by the library itself). This is useful if you quickly need a standard structure and don’t really care about the details
ajaxedPage.titlegives you the possibility to assign a title to your page which may be used in the
ajaxedPage.plainproperty allows to render a page completely plain which means it renders only those things which are defined in the page itself. (no header and footer). You will need this for your
lib.execlets you call any function only if it exists. This is used within the
headerto allow page specific head elements. Whenever you want anything to appear in your header just add a
- <% sub header() %>
- /* some styles */
- <% page.loadJSFile "someJSFile.js" %>
- <% end sub %>
Best thing is you take a look into the predefined
header.asp in your config to see whats going on there. And don’t forget it’s up to you what you bung in there. You can add as many
lib.exec calls as you want.
ajaxed supports two environments now:
LIVE (production) and
DEV (development). The config variable
AJAXED_ENVIRONMENT sets the current environment. This enhancement allows us …
- creating conditions dependent on the environment.
lib.LIVEare helpers to check which environment is running.
truein order to prevent calling it on the
LIVEenvironment. E.g. whole ajaxed console and tests are only available on DEV env yet.
(The default environment is always development)
TestFixture class lets you create unit tests for your own applications. It comes with a lot of different asserts (as commonly known in other unit testing frameworks) and is very quickly to set up. After you have written your tests you can run them directly from the ajaxed console. Tests for the library itself are located there as well. Here is an example of how you write a simple test (test file must start with
- <!--#include virtual="/ajaxed/class_testFixture/testFixture.asp"-->
- set tf = new TestFixture
- 'create test methods starting with test_
- 'followed by an increasing number
- sub test_1()
- tf.assertEqual "x", "x", "x should be x"
- tf.assert 1 = 1, "one should be definitely one"
- tf.assertInstanceOf "testFixture", tf, "this test should be a TestFixture"
- tf.assertInDelta 1, 1.1, 0.1, "equality with a delta"
- tf.assertHas array(1, 2, 3), 2, "the array should contain 2"
- end sub
Documentation generator (Documentor)
Some of you have long waited for the day to come Finally its here! Automatically create a documentation of your ASP code. The tool is called
Documentor and can be found within your ajaxed console. It is also used for the generation of the actual ajaxed documentation which got a small face lift as well. Read How to document to know more about documenting your code (This manual can be found in your ajaxed console). Example of a method documentation:
- '' @DESCRIPTION: gets all users for a given country
- '' @PARAM: country [string]: specified country. e.g. AT
- '' @RETURN: [recordset]
- function getUsersBy(country)
- end function
Automatic version check
The ajaxed console checks automatically for a new version of ajaxed and reminds you if there is a new version available. Never miss an update.
MD5 hash class
We have a hash on board of the library now. Hash your passwords, etc. easily with:
- hash = (new MD5).hash("mypassword")
There are some new useful database methods which makes your code more readable and easier to debug.
- 'get the number of records of a table
- numberOfRecords = db.count("tablename", empty)
- 'get number of records with condition
- numberOfRecords = db.count("tablename", "active = 1")
- 'insert a record into a table (returns the ID)
- ID = db.insert("tablename", array("firstname", "jack", "lastname", "johnson"))
- 'updating a record
- db.update "tablename", array("firstname", "Johnny"), ID
- 'works as well with condition
- db.update "tablename", array("firstname", "Johnny"), "firstname = 'Jack'"
- 'delete a record with a condition
- db.delete "tablename", "active = 0"
- 'delete with an ID
- db.delete "tablename", 10
- 'toggle the value of bit fields.
- db.toggle "tablename", "active", "country = 'AT'"
- 'or with ID
- db.toggle "tablename", "active", 10
Most of them support a condition parameter which can be either a number (its used automatically as ID) or a string (which is a condition for the
Those are handy for common CRUD operations. If you need more sophisticated stuff you should still use
RSS reader and writer
If you ever want to generate an RSS feed in your application or read another one – it’s no problem anymore. ajaxed has the right component inside. There is a full detailed article about this component here.
- 'example of reading some feed
- set r = new RSS
- r.url = "http://domain.com/feed"
ajaxed 1.0 includes a template class called
TextTemplate. Very useful if you send emails within your applications. Create an template for the content of your email and parse it using
TextTemplate. The ajaxed console provides a simple management of templates. For more details about
TextTemplate read the article Template component for classic ASP or check the ajaxed documentation. Simple example
- set t = new TextTemplate
- t.filename = "mytemplate.template"
- t.add "name", "jack johnson"
- 'your email object
- 'i use the first line of the template as the subject of my emails
- mail.subject = t.getFirstLine()
- mail.body = t.getAllButFirstLine()
Caching data, rss feeds, etc. globally for all visitors can be achieved now with the
Cache class. This class has been around for while as well and a details article is available here
Discussion group launched
I have created an own google asp ajaxed discussion group for better support and communication with all ajaxed users.
init()must not exist necessarily anymore. If it exists it will be called. if not then not Thanks to the new
lib.getFunction(). Check the reference for more details.
str.matchingchecks a string against a given regular expression pattern. Is much more readable then creating the regex object over and over again.
- An error will be raised if there is no
main()in your page. Makes it easier to know whats going on…
lib.containsis a useful function which lets us check if a given value exists in a given data structure. Currently supported data structures are
dictionary. Usage is easy:
lib.contains(array("yes", "no"), "maybe")
- script.aculo.us is now part of the library as well. I decided to do this as it plays very nicely with prototype and both are being used in ruby on rails successfully for a long time.
- some more minor improvements and bug fixed which you bette look up in the
changes.txtor directly in the SVN
That was it. Hope you enjoy working with the new version and I am looking forward for your feedback .. which already made the library what it is! Here are some things i am working on already…
- generic email class
- automatically notify admin about ANY errors
- plugin infrastructure
- asserts for request and response
- logging possibilities
- validator for business objects
- dropdown control and calendar control
If you UPGRADE from 0.3 then the only thing you need to do is to move your
config.asp into the new
/ajaxedConfig/ folder. Last but not least create a
footer.asp in that folder. Put all your html, head and body tags there. You can use the existing ones and adopt them to your needs. Last but not least change
AJAXED_ENVIRONMENT to your needed environment.
If you want to live on the edge then grab the latest version from SVN.