This article gives you a short overview on how to read the ajaxed API.
ajaxed is structured into classes. Therefore this document contains all classes and its corresponding documentation.
Whenever we talk about "loading a class" we refer to the process of including the asp file (which contains the class) into your source file. Its recommended to do it by an absolute path notation:
All classes are placed within the ajaxed
folder. Each class has its own folder named after the class and prefixed with class_
. This folder then contains the actual class source file which is named exactly like the class and has the extension .asp
Let's say we have the class Datatable
then the path would be /ajaxed/class_datatable/datatable.asp
Each class may contain a class description, its methods, its properties, some meta information and initializations:
- Description: The class description briefly summarizes the functionality and its usage.
- Properties:A Property is marked with a icon and can be a set/get property or both (mentioned in the property description). Beside the property name you can find the possible data types. Properties can only be invoked on instances of the class. Example:
<%
'creating an instance of the AjaxedPage class
set page = new AjaxedPage
'setting the title property
page.title = "my page"
'reading the title property
a = page.title
%>
When a property is a class' default property it is marked with a icon. In this case you can (don't have to) use it implicitly. Example: The Validator
class' valid
property is a default property and can be used as follows:
<%
'creating an instance of Validator
set v = new Validator
'checking if validator is valid (explicitly)
isValid = v.valid
'checking if validator is valid (implicitly)
isValid = v = true
%>
Often you will read about the default value of a property (default = "something"
). This means that the value is the initial property value when the instance is created.
- Meta: Meta contains all kinds of meta information about the class:
- Author: The class author(s)
- Singleton name: When the class contains a singleton name then you don't need to load the class and you don't need to instantiate it. It's automatically available within your code using its singleton name - which holds an instance of the class. Best example is the
StringOperations
class which is available
with str
as its singleton name. As we need string operations all the time we want it to be available as quick as possible:
<%
'using string operations
matches = str.matching("^[A-Z]+$", "some text", true)
str.write(str.shorten("We shorten that text", 10, "..."))
'also the database is available through
'a singleton name. Example to get a recordset
set RS = db.getRS("SELECT * FROM tab", empty)
%>
Another important class which is available as a singleton is the Library
class. This class contains all kind of useful functionality which is used almost everywhere within the ajaxed library. Therefore its available immediately with the name lib
.
Note: You might think that the class is instantiated as a real singleton but its not really that case. Whenever you create a new instance of the class you will get a new unique instance! The name Singleton was used for this scenario because those classes are instantiated only once internally.
- Requires: Classes which are required for the class to work
It mean that you have to load them (include) when you are using the class. - Friend Of: Name of the class to which this class belongs to. This means that the class is automatically loaded when its main class is loaded and that it is only used in combination with the main class.
- Compatible: States the compatibility of the class. E.g. Check the
Database
class. You will see the list of compatible DBMS systems.
- Methods: Methods are marked with a icon and contain a brief summary in addition to a detailed description (after clicking the method name). If a method is marked with a icon it means that the method is a static method (You can only invoke it on the class directly - not on an instance). Yes, VBScript does not support static methods but ajaxed uses them. In order to use a static method just create a dummy instance of the class and invoke the method on it. You can also invoke it on an existing instance (just keep in mind that static methods will never use instance variables by definition).
For example the Email
class contains two static methods which allow you
to quickly build an Email instance. One of them is called newWith()
:
<%
'normal creation of an Email instance
set m = new Email
'creating with a static method
'in this case the method is newWith()
'which lets you create an email with an existing
'Text template.
set m = (new Email).newWith(new TextTemplate)
%>
Like the properties also methods can be marked as default (only one per class) with . This means that you can call them without explicitly writing its name. The other static method of our Email
class is called quickSend()
and is also marked as default. This allows us to call the method in different ways:
<%
'quickSEnd() is static and default!
result = (new Email)(new TextTemplate, "some@email.com")
'explicit call
result = ((new Email).quickSend(new TextTemplate, "some@email.com"))
'BTW: The quicksend method allows you to send an email with
'only 1 line of code!
%>
Sometimes you will see an alias for a method (right next to the methods name). This means you can call the method also using its alias. In most cases the alias is shorter. Note that this is a valid alias for the Library.arrayize()
method:
<%
'calling lib.arrayize()
arr = lib.arrayize("some val")
'calling the alias of lib.arrayize()
arr = []("some val")
'BTW: the arrayize() method ensures a given value to be an array
'(if not already an array)
%>
- Initializations:Initializations lets you override the default values (most of them) of class properties. In other words it means that you can define which value will be set for a given property when the class is instantiated. Initializations need to be placed within the
/ajaxedConfig/config.asp
file. Check the initializations of the AjaxedPage
class for more details. The default value of an initialization shows you which value the property gets when you do not override it. Example of config.asp
file:
<%
'the DBConnection is false by default.
'this allows us that the database connection
'is automatically established on each page
AJAXED_DBCONNECTION = true
set p = new AjaxedPage
'but we still can turn it off later
p.DBConnection = false
%>
Whenever a clas member has a line through its name it means that the member is obsolete and should not be used anymore. Refer to the member description for further details then.