5,662,937 members and growing! (91 online)
Email Password   helpLost your password?
Third Party Products » Product Showcase » Applications     Intermediate

Easily Create AJAX Enabled Applications with Swan

By ObjectWave Corp

Swan makes building rich web applications easy.
XML, HTML, Java (Java, J2EE), Apache, PHP, Ajax, Dev

Posted: 17 Jun 2008
Updated: 17 Jun 2008
Views: 6,765
Bookmarked: 11 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
4 votes for this Article.
Popularity: 2.53 Rating: 4.20 out of 5
0 votes, 0.0%
1
1 vote, 25.0%
2
0 votes, 0.0%
3
1 vote, 25.0%
4
2 votes, 50.0%
5
This article is in the Product Showcase section for our sponsors at The Code Project. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

This paper demonstrates how easy it is to create AJAX-based rich web interfaces using Swan. With Swan, there is no need to learn complex JavaScript libraries in order to integrate AJAX into your web pages. You simply select the components you want to have AJAX enabled and provide the controller class to handle the data and events for your enriched web page. In this tutorial, we’ll present one of the wizards available within Swan to quickly build an AJAX-enabled application.

About Swan

Swan combines an AJAX framework and best practices in software development with easy-to-use development tools that accelerate web application development and enforce consistency. Swan's architecture enables a more natural integration between web pages and server side components.

swan-arch.png

Above: Swan Application Architecture

JavaScript Swan Engine

The JavaScript Swan Engine takes care of all AJAX functionality, transparently integrating it with your web form components and all other Swan-based widgets. Swan is also responsible for the distribution of events handled by either the server or the browser. Swan uses JSON as the means to transport data across.

Server Side SDK

The Server Side SDK provides the framework to build your custom application components that will serve as the model/controller of your web pages. It also provides access to a representation of the UI widgets on the server side, which enable you to easily push data back to the front end, as well as fulfill other requests such as opening a dialog or displaying a message.

Swan Control Bindings

Swan uses an XML descriptor file in order to glue the UI with the Page Model. Here is where the magic happens. You do not need to worry about creating this file. Swan provides the necessary tools to make the creation of this file transparent to you.

Swan Wizards

Swan’s toolkit includes a set of wizards for creating sample applications based on commonly used templates. These wizards are useful, especially if you are new to Swan. In this tutorial, we’ll show the creation of a listing web application with typical CRUD functionality. Now you’ll learn how Swan-based applications are composed. You will see how easy it is to build rich web applications with Swan, even if you don’t know AJAX.

Prerequisite

For this tutorial, you must have Eclipse for J2EE Development and Tomcat 5.5 set up.

Install Swan Plug-in

Download Swan (a ZIP file) and unzip the contents within the plug-in folder of your Eclipse installation. Start or re-start your Eclipse environment in order to activate Swan's plug-in.

Creating Your First Swan Project

The steps for creating a Swan project are as simple as 1-2-3.

  1. Create a Dynamic Web Project
  2. Add Swan's Nature to the new project
  3. Create the Swan application

1 - Create a Dynamic Web Project

The current version of Swan’s toolkit is based on the Eclipse Web Tools Platform. In order to create a Swan Project, you must first create a Dynamic Web Project.

Select New > Dynamic Web Project.

new-project.png

Figure 1 - New Dynamic Web Project

For this tutorial, create a project named ListingApp.

listing-app.png

Figure 2 - New ListingApp Project

2 - Add Swan's Nature

When creating a Swan-based application, we need to prepare the new project with all the required libraries used by Swan. To do this, we just need to add Swan's Nature to the project. This will automatically add the necessary JavaScript libraries and Java libraries to enable the Swan SDK within your project.

Select the ListingApp project and right mouse click to bring the pop-up menu. Now select Add Swan Nature.

swan-add-nature.png

Figure 3 - Add Swan Nature

Adding all required libraries may take a few seconds. Once completed, you should see the updated directory structure as illustrated here.

swan-nature.png

Figure 4 - ListingApp with Swan Nature Folders

This task should have done the following:

  • Added the Swan-engine folder, including Swan's JavaScript libraries
  • Added the required Java libraries to the lib folder under the WEB-INF folder
  • Added the ui_specs folder under the WEB-INF folder to store Swan's binding files
  • Registered Swan's Servlets within the web.xml file

3 - Create the Swan Application

To create the Listing application, we'll use one of the Swan wizards. To open the wizard, select the ListingApp project and then select HTML Page Wizard as illustrated in figure 5.

new-html.png

Figure 5 – Open New HTML Page Wizard

Swan's HTML Page Wizard

swan-wizard.png

Figure 6 - Listing App Wizard Settings

Click Next to add the fields for the Listing application.

Adding Fields to Page

swan-wizard-3.png

Figure 7 - Adding Fields to Listing App

To add fields, click on the Add button -- as illustrated in Figure 7 -- to open the Component Definition Dialog. Select the type of component needed for each field, its label and ID. For this tutorial, add the following fields:

Component Label ID
TextField First Name firstName
TextField Last Name lastName
DateField Date of Hire dateOfHire

Once done, just click Finish. The wizard will generate the necessary HTML page, bindings and Java Controller class, as illustrated in Figure 8.

swan-wizard-4_small.PNG

Figure 8 - Listing App Generated Code

The generated Listing application has the functionality to add, edit and remove records in memory.

Is it really that easy? TEST IT.

To test the application, first create an index.html file as illustrated in Figure 9.

index_page.png

Figure 9 - New index.html File

Once the file index.html is created, add the following code within the body:

<H1>Swan Demo Application</H1>
<a href=&quot;SwanApplication?_open=listingPage&quot;>Listing Application</a>

The HTML page should look something like this:

new-html-3.png

You must have Tomcat installed to proceed.

Select index.html. Right click and select Run As > Run on Server.

run-on-server.png

Select the Tomcat server and click Finish.

run-on-server-2.png

Once the index.html page is displayed, click on the Listing App tab. The browser should display the Listing application, as illustrated here.

application.png

To make this a fully functional application, you’ll need to customize it. Once finished with this tutorial, go ahead and explore the code generated, so that you become familiar with Swan’s API.

Summary

Swan makes building rich web applications easy. During this tutorial, you learned about the Swan framework and how quickly you can create a template application. By exploring the code, you will also learn how easy it is to integrate the web interface with the server side controller.

Resources

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ObjectWave Corp


ObjectWave, Corp., is a leading software engineering company headquartered in Chicago, IL.

ObjectWave has more then 17 years of experience building enterprise-level object systems and customized developer frameworks using OO technology, emerging technologies and advanced methodologies.

Company: ObjectWave Corp.
Location: United States United States

Other popular Product Showcase articles:

  • Inside xamSalesManager: a NetAdvantage for WPF Showcase Sample
    Infragistics dives deep into the technical architecture of their xamSalesManager showcase sample for WPF. Read how you can apply the Model - View - ViewModel pattern to your own application designs to create compelling user experiences like in this sophisticated sales dashboard.
  • Native XML Databases: Why Should You Care?
    In this paper, learn how you can store XML documents in an integrated, scalable, high-performance, object-oriented native XML database and take advantage of fast access to every element of an XML document regardless of the number of concurrent users, the number of documents, or the database size.
  • Building Graphical Displays for the Desktop and Web
    Software developers know that user interfaces often take much longer to build than initially planned. This white paper presents approaches for quickly creating and delivering graphically rich user interfaces that work on both the desktop and the Ajax-enhanced browser.
  • Static Analysis on Steroids: Parasoft BugDetective
    Data flow analysis enables early and effortless detection of critical runtime errors like exceptions, resource leaks, and security vulnerabilities. It can also check if exceptions reported from automated unit testing are “real bugs.”
  • Solving Today’s Setup Authoring Challenges with the New InstallAware 8: Windows Installer without Rocket Science
    InstallAware has been built from the ground up to offer developers maximum flexibility with the Windows Installer platform. InstallAware brings runtime decision making, better-than-CAB compression, partial web deployment, Flash/HTML interactive billboards, and many more time saving benefits.
Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
Generali don't think this is "EASILY"membermouhannad6:56 26 Aug '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 17 Jun 2008
Editor: Genevieve Sovereign
Copyright 2008 by ObjectWave Corp
Everything else Copyright © CodeProject, 1999-2008
Java | Advertise on the Code Project