Before we look at the AJAX functionality, let's set up our Railo Application and create the server-side service that will be used to store our tasks:
1. Create a directory named
todo
in your<Railo Install Directory>/webroot
directory; this is where we are going to hold the application.2. Now let's create the
Application.cfc
for this application, so add a template calledApplication.cfc
and add the following code:component { this.name = "TodoList"; this.sessionmanagement = true; function onSessionStart(){ session.tasks = []; } }
3. Next, we are going to create our
TaskService
. Let's create a template namedTaskService.cfc
in thetodo
folder and add the following code:component{ remote function addTodo(String taskname){ if(Len(arguments.taskname)){ ArrayAppend(SESSION.tasks, {name:arguments.taskname, addedat=Now()}); } return SESSION.tasks;; } remote function removeTodo(Numeric id){ ArrayDeleteAt(SESSION.tasks, id); return...