ajaxed 1.0 released

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…

ajaxed console
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 header.asp and footer.asp in your ajaxedConfig folder. Those files are automatically loaded within your pages. This change brought some additional features as well

ajaxedPage.defaultStructure property 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.title gives you the possibility to assign a title to your page which may be used in the header

ajaxedPage.plain property 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 XHR

lib.exec lets you call any function only if it exists. This is used within the header to allow page specific head elements. Whenever you want anything to appear in your header just add a header() sub to your page and place the stuff there. e.g. especially javascripts, styles

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.

Environment support
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.env, lib.DEV and lib.LIVE are helpers to check which environment is running.

setting ajaxedPage.onlyDev to true in order to prevent calling it on the LIVE environment. E.g. whole ajaxed console and tests are only available on DEV env yet.

(The default environment is always development)

Unit testsTestFixture 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 test_):

tf.assertInstanceOf"testFixture", tf, "this test should be a TestFixture"

tf.assertInDelta1, 1.1, 0.1, "equality with a delta"

tf.assertHasarray(1, 2, 3), 2, "the array should contain 2"

endsub

%>

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:

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 WHERE clause).
Those are handy for common CRUD operations. If you need more sophisticated stuff you should still use db.getRecordset().

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.

Template class
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

Cache component
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 launchedI have created an own google asp ajaxed discussion group for better support and communication with all ajaxed users.

Minor changes/improvements

init() must not exist necessarily anymore. If it exists it will be called. if not then not Thanks to the new lib.exec() and lib.getFunction(). Check the reference for more details.

str.matching checks 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.contains is a useful function which lets us check if a given value exists in a given data structure. Currently supported data structures are array and 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.txt or 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 header.asp and 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.

I’ve observed that the escape function can be pretty slow when a lot of data is passed to this function (amongst other things I use ajaxed to sort tables with 400+ rows – then the escape function takes up to 5 seconds).

To accelerate this process I have written my own escape function which replaces only the slashes and the double quote by their unicode representation:

rolphes you are right that could be very time consuming if there is a lot of data … i have some idea of optimizing it but i am not sure if it will work.
btw: if you get a lot of data you should rather consider making an own page which will be called with Ajax.Updater from prototype .. this is a much quicker way…

Qwaider , i want to provide more samples .. you can find some in the “ajaxed” category already …
what do you mean by the autocompleter support? you can use it as scriptaculous is included … but there are no specific asp wrappers.

Little suggestion…. try to create Dreamweaver extension, there are many people which use ASP in Dreamweaver, but dont have any AJAX option. Im having real trouble with ASP and Mootols but somehow im managing all to work. There is new Adobe’s Spry, but those are only fancy effects

graeme good to hear u guys like it.. i dont fully understand what u mean allowing the user to specify to return the id.
changes u do are okay but i would fully recommend u not doing it as you wont be compatible with the future versions.. the version 2.0 is coming soon with a lot cool stuff. just fyi

If we use db.insert (some SQL) etc then the code (as far as I understand) expects their to be a column called ID in the table. The code then returns this as the result of the insert function.

If there is no ID column an error is thrown. We don’t want to label all our ID columns in our database ID (they are named for the table e.g. personid, addressid, etc). Therefore we have to change the code or it throws an error as we have no column called ID.