Geertjan is a DZone Zone Leader and has posted 468 posts at DZone. You can read more from them at their website. View Full User Profile

Interview: Amr ElAdawy, JSPX Java Web Framework Developer

01.04.2009
| 13724 views |
  • submit to reddit

Amr ElAdawy is a software engineer at Etisalat Egypt in Cairo. Etisalat is an Egyptian Mobile operator, where Amr develops Java enterprise applications for telecommunications & sales.

He is a member of a small community that is developing and supporting a web framework called "JSPX" . (Its homepage is here.)

Yet another web framework? 

Looking into the existing frameworks for developing Java web applications, we found that each requires a lot of knowledge and time before one can become productive with it. We wanted something that is easy to learn, productive, and (most of all) developer friendly. Hence we developed JSPX.

JSPX's main target is to be a "developer friendly" framework. Since JSPX is based on standard HTML tags and simple Java POJOs:

  1. JSPX is easy to learn. We already involved some fresh developers with basic knowledge of HTML and Java and no knowledge whatsoever of the framework... and they managed to start being productive in a remarkably short time.

  2. The out-of-the-box components that implement common tasks, such as DataTable, ListTable, Validators, and Capatcha are very powerful.

  3. Utilization of declarative code with full controllability, which is the ability to interact with the declared HTML controls through Java APIs is a fundamental concept in this framework.      

How does declarative code make JSPX different?

JSPX is smart enough to know what you need it to do without your needing to tell it how to do so. You only need to declare some attributes in your HTML pages to change the behavior of the results. For example, by setting the value of the "AutoBind" to "True", in a DataTable component, will a data table automatically connect to a database, without the need for any Java code at all.

Here are some of the DataTable tags:

To give us a visceral idea about what JSPX entails, can you give us a "Hello World" scenario?

Hello World with JSPX is very simple. Only three steps will get you on the road:

  1. Configure web.xml file. Just register two servlets and choose your URL pattern:
    <servlet>
    <display-name>JspxHandler</display-name>
    <servlet-name>JspxHandler</servlet-name>
    <servlet-class>eg.java.net.web.jspx.engine.RequestHandler</servlet-class>
    </servlet>

    <servlet>
    <display-name>ResourceHandler</display-name>
    <servlet-name>ResourceHandler</servlet-name>
    <servlet-class>eg.java.net.web.jspx.engine.ResourceHandler</servlet-class>
    </servlet>

    <servlet-mapping>
    <servlet-name>JspxHandler</servlet-name>
    <url-pattern>*.jspx</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>ResourceHandler</servlet-name>
    <url-pattern>/jspxEmbededResources/*</url-pattern>
    </servlet-mapping>
  2. Create HTML file with the extension you chose in the URL pattern. For example FirstPage.jspx in the Webroot folder:
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:noNamespaceSchemaLocation="http://jspx-bay.sourceforge.net/jspx.xsd"
    controller="FirstPage" >
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>jspx demo</title>
    </head>
    <body>
    <form method="post" enctype="multipart/form-data" >
    <label id="resultLabel"></label>
    </form>
    </body>
    </html>
    </page>
  3. Create a Java class. It must have the same name as defined in the controller attribute in the HTML page's tag "jspx.demo.web.controller.FirstPage":
    public class FirstPage extends Page {

    protected void pageLoaded() {
    resultLabel.setValue("Hello Web in JSPX");

    }

    public Label resultLabel = new Label();

    public Label getResultLabel() {
    return resultLabel;
    }

    public void setResultLabel(Label result) {
    this.resultLabel = result;
    }

    }

Now you can start and try to access this url http://localhost//jspx-demo/pages/FirstPage.jspx.

Now please tell us exactly how an HTML file in JSPX is different to normal HTML files.      

Looking at the above example, we can see that the page contains standard HTML tags, except for the root element which is <page>. That is one of the most important features of JSPX: the ability to port an already-designed HTML page into JSPX pages. Just wrap the HTML within <page> tags! JSPX is built on top of all HTML standard tags. However, when going into some advanced business cases, such as database searches, one would require some non-standard tags that are specific to JSPX (as shown in the screenshot earlier in this interview).

What exactly is defined in the POJOs and how are they hooked into the HTML files? 

The controller code, which is a simple POJO class, is a representation of the HTML declarative code on the JSPX page. In the page, you see the attribute "Controller" in the Page node. This defines the name of the controller class. In this controller, you can define web controls that have the same name as the value of the ID attribute in the HTML page.  So, you will be able to interact with them. Also, through this controller you are exposed to a set of inherited methods to control all the phases of  JSPX. In addition to that, there are advanced binding techniques, via the JspxBean control, which are almost the same as JSF backing beans.

What about configuration files, like struts-config.xml? 

The approach taken in configuration is one of the most important advantages of JSPX. Our main goal from the start has been to eliminate the headache of configuration files. Unlike JSF and Struts, JSPX does not require any configuration files, other than the standard web.xml file. Hence, JSPX can be considered a "Zero Configurations Framework".

Are there any disadvantages to using this framework? 

Using relatively new frameworks is considered a risk for some people. In JSPX, we looked into the other frameworks and we covered almost everything that is needed and missing. Also, we provided the ability to use JSPX with already developed projects that were made in different technologies like JSF and JSP. Also, we support including already-made JSPs into JSPX pages.

Are you using the framework in production code and what are the results of doing so? 

Over the past 5 months, since the first announcement of JSPX, it has been used in at least five of our enterprise projects. Some of them have been totally migrated to JSPX. Others were already created in different technologies and JSPX was used to implement new requirements. In all of these cases, JSPX provided outstanding productivity. Top management has been very pleased about our time-to-market. In fact, we were able to deliver requirements that were planned to take days in just an hour!

What are the future plans of this framework?

The first JSPX release was announced on the 1st of January 2009... and the framework will not stop there! There is a plan for monthly releases, aiming to include bug fixes and new features. We are planning to provide support for AJAX, which is scheduled in the next build. Also, a plugin for NetBeans IDE will improve the productivity of users of this framework.

Mainly we are counting on user feedback to drive this framework, as it is strongly characterized as a highly dynamic and business-case driven framework.

How to start using it?

Visiting the project website at  http://jspx-bay.sourceforge.net will give you a comprehensive starting point for JSPX. A demo project is also provided, demonstrating some use cases of the framework. And, of course, we are more than pleased to support any request at the JSPX support email: support DOT jspx AT gmail DOT com.

 

AttachmentSize
amr.JPG12.17 KB
fig.png109.14 KB
Published at DZone with permission of its author, Geertjan Wielenga.
Tags:

Comments

Amr Lafi replied on Mon, 2009/01/05 - 8:15am

well done ! looks like it's easy to get start with if you're from ASP.NET background 

amr adawy replied on Mon, 2009/01/05 - 9:20am in response to: Amr Lafi

This a good point that we did not thought about when we started this framework. but if this framework is that easy to be comapred to ASP.NET, sure that is a good advantage. We are tragetting Java Developers manily with HTML background. hence we made this framework to be more close the concept itself not to a certian Technology. it is easy to get started with regardless your background.

Passion Lab replied on Tue, 2012/08/14 - 2:14pm

JSPX is easy to learn. We already involved some fresh developers with basic knowledge of HTML and Java and no knowledge whatsoever of the framework... and they managed to start being productive in a remarkably short time. Forex Programming

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.