Jspx-bay

Last updated
jspx
Jspx.png
Stable release
2.1 / December 23, 2015 (2015-12-23)
Written in Java
Operating system Cross-platform
Type Web application framework
License Apache License 2.0 WTFPL
WTFPL badge WTFPL badge.svg
WTFPL badge
Website www.jspx-bay.sourceforge.net
www.jspx.sourceforge.net

jspx-bay, commonly referred to as jspx, is a free open source pure Java web RAD framework. Jspx should not be confused with other technologies using the same name like Oracle Application Framework and XML JSP.

Contents

Jspx extends Java EE servlets to provide an Object-oriented programming model for HTML declarative code. Jspx can be compared to JSF as a web framework. There are many other Java Web frameworks like Apache Wicket that implement such ideas.

History

Jspx icon.gif

Jspx development initially started in February 2008 as a trial to provide an easier way to develop rich interactive web applications in Java. In July 2008, jspx was introduced to the Java community through java.net. Initially jspx had very limited features, including support for web form based development only.

In December 2008, the project moved to SourceForge, [1] where it has been hosted since.

The Name

The name was chosen to indicate the next step of JSP technology, despite the fact that jspx is significantly different from JSP in that it does not directly embed Java code in HTML. The suffix X is analogous to ASP.NET pages, which have the extension aspx. The official jspx framework name on SourceForge is jspx-bay. The suffix bay distinguished the framework from an earlier inactive SourceForge project named jspx. [2]

On 16 November 2009, the jspx project on SourceForge was purged, and it provides the same content as jspx-bay. [3]

Framework Target

Jspx aims at providing easy to use, developer-friendly APIs. Based on the idea that web development is mostly about customizing the HTML that is presented based on user-input, jspx offers an object-oriented view layer interface to HTML. Jspx provides a means of implementing a stateful user interface over a stateless protocol (HTTP). JSF provides similar functionality, but requires that developers learn an entire new set of tags.

Design Goals

Jsxp arch.png

Jspx is relatively new, and combines many features and advantages from existing frameworks while eliminating what might be considered disadvantages. Jspx had the following design goals: [4]

  1. Business case Driven Framework
    Remove boilerplate code and tasks.
  2. Zero configuration
    Unlike JSF, does not require any external configuration.
  3. Declarative and Imperative code
    Attributes declared in HTML are accessible by fully object-oriented APIs.
  4. Optional and Default Implementation
    No need to specify the value of every feature, because they have reasonable default values.
  5. Integration with other frameworks
    Import existing jsp files into jspx HTML pages.
  6. Portable framework
    Run on almost every Application Server without extra effort.

Comparison with Other Frameworks

ASP.NET

Jspx has the following similarities with ASP.NET:

  1. Webform-based framework.
  2. Page life cycle and events.
  3. Page Templates through Master/Content pages.

Jspx is different from ASP.NET in the following ways:

  1. Jspx does not require a particular extension for the html file (i.e. aspx).
  2. Jspx uses standard HTML tags.
  3. Jspx provides many extra features (such as Jspx Beans for View-Controller binding).

JSF

Jspx is similar to JSF in the following ways:

  1. The same goal of providing an object-oriented interface to HTML.
  2. Bean Binding.
  3. Binding to Page properties.

Jspx differs from JSF in the following ways:

  1. Uses standard HTML tags.
  2. Does not rely on any external configuration.
  3. Full control of the page life cycle.

Jspx can be also compared to many other frameworks, such as Apache Wicket, but jspx uses HTML tags and attributes without an additional XML namespace.

Web Development Using Jspx

As Jspx is a webform-based framework, for each business case there is one development unit. A development unit in a jspx application consists of two parts: [5]

  1. Declarative HTML code (myPage.htm)
  2. Imperative Java code (MyPageController.java)

In addition, the web.xml file must direct traffic to jspx main servlet controller (RequestHandler).

Example

A hello world example can be implemented in many different ways. The following example demonstrates one of them.

web.xml
<?xml version="#0" encoding="UTF-8"?><web-appxmlns:xsi="http://www.w#org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee"xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_#xsd"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_#xsd"id="WebApp_ID"version="#5"><display-name>jspx-demo</display-name><servlet><servlet-name>JspxHandler</servlet-name><servlet-class>eg.java.net.web.jspx.engine.RequestHandler</servlet-class></servlet><servlet><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>*.html</url-pattern></servlet-mapping><servlet-mapping><servlet-name>ResourceHandler</servlet-name><url-pattern>/jspxEmbededResources/*</url-pattern></servlet-mapping></web-app>
HelloWorld.html
<pagecontroller="HelloWorld"><html><body><labelid="message"/></body></html></page>
HelloWorld.java
importeg.java.net.web.jspx.ui.controls.html.elements.Label;publicclassHelloWorldextendsPage{Labelmessage;protectedvoidpageLoaded(){if(!isPostBack)message.setValue("Hello Jspx World");}publicvoidsetMessage(Labelmessage){this.message=message;}publicLabelgetMessage(){returnmessage;}}

Note the following about the example above:

  1. The only configurations required are to register two servlets of jspx; one for the normal requests on the pages, and the second for embedded resources (such as JavaScript and images).
  2. The HTML must be contained within a root element <page>, and must be well-formed XHTML.
  3. The Java code must extend the root Page controller from the jspx page.
  4. The page has life cycle phases as with ASP.NET, with similar names like pageLoaded
  5. The HTML page should point to the Java controller class through the controller attribute of the <page> element.
  6. In the Java controller, in case it is needed to interact with an HTML control, a control of the same type should be declared as a java property with getter and setter, and the property name should be the same as the value of the attribute ID in the HTML control.

For the note number 6, the framework is considering using of Dependency Injection to eliminate such limitation and any coupling of HTML and java code.

Dependency Injection

Jspx build 1.0.9 provided new way of linking HTML controls to Java controls in the page controller. The above example showed the need to add getter and setter for each control. This methodology created the following cons:

  1. Developer has to type a lot of code to link HTML control to Java control.
  2. The Page controller is getting very crowded with irrelevant code.
  3. Coupling between the HTML control and Java Control; as the link is created only if the Java control name is the same as the value of the attribute id in the HTML control.
  4. Any change in the HTML requires changing the getter and setter in the page Java controller.

For all these reasons build 1.0.9 is using Java Annotation to link Java objects to HTML. The following example is an alternative to the above one.

importeg.java.net.web.jspx.ui.controls.html.elements.Label;publicclassHelloWorldextendsPage{@JspxWebControl(name="message")Labelmsg;protectedvoidpageLoaded(){if(!isPostBack)msg.setValue("Hello Jspx World");}}

As noted the size of the code is very much reduced. Also it is noted that the annotation @JspxWebControl is using an attribute name which is an optional attribute. The value of this attribute should be the same as the id of the HTML control. This technique removes the coupling between HTML and Java code. [6]

Some consider this new feature an insignificant addition to the framework. They use the JspxBean to link the HTML form to Java Model Object, and do not declare server side controls linked to the HTML controls.

JspxBean in build 1.0.9 also has been improved, there is no need to create getter and setter for every JspxBean. Forgetting to add getter and setter was a very common mistake causing the developer to loose the link with the HTML. Dependency Injection is used to inject the JspxBeans without the need for getters and setters.

Expression Language Support

Jspx does not allow Java code inside HTML page. However, in order to satisfy the need of injecting data from the controller; Jspx fully supports Expression Language.

Some examples on EL as following:

Limitations and Disadvantages

Any framework is evaluated according to different criteria aspects, the following which jspx needs more improvements.

  1. IDE support. Jspx can be developed using any IDE, however there is no direct support for jspx. Developer has to write the event handling manually.
  2. Documentation. Tutorials and examples are found on the official website. There is a section on the website for documentation, however not sufficient.
  3. EL Support. Jspx did not fully support EL language until version 2.0, JEXL is used starting from jspx version 2.0 to fully support EL.

Features

Jspx offers some powerful features like:

  1. Native support for Ajax through AjaxPanel [7] [8] [9]
  2. Data Controls like DataTable and ListTable.
  3. Integration with JAAS and adding more features. [10]
  4. Data Binding through JspxBean.
  5. HTML Template through Master/Content Pages.
  6. Client/Server side validation. [11]
  7. Embedded JQuery, JQuery UI, Bootstrap style and many other open source libraries inside.
  8. Embedded JEXL to support EL expressions.

External Jar Dependency

Jspx tries to minimize external jar dependencies, however there are some essential jars: [12]

  1. commons-fileupload-1.2.1.jar (when using File Upload)
  2. slf4j-api-1.7.2.jar (Mandatory for logging)
  3. poi-3.1-FINAL-20080629.jar (when using Export To Excel)
  4. servlet-api.jar (only during compilation)
  5. commons-io-1.3.2.jar (when using File Upload)
  6. commons-jexl-2.1.1.jar
  7. jcl-over-slf4j-1.7.5.jar slf4j bridge for Commons logging (As JEXL is using it)

JDC 2010

Jspx had made its first public appearance at Java Developer Conference 2010 (JDC). Java Developer Conference is the largest Java event in MENA, organized by EGJUG. [13]

Jspx Demo Projects

Jspx1.1.0.demoapp.png

Jspx distribution package includes several files beside the binary jar and the source code. Since the first release on SourceForge the distribution included a demo project as a binary war file and a zipped source code. That project was a simple discrete pages showing different features of Jspx. There was no common business module wrapping these pages, beside it had a poor GUI design. Jspx build 1.1.0 add new demo project that facilitates the easy use of jspx to develop common business case of interacting with DB. The demo is using MySQL. Sql script file is separately downloadable.

Some of jspx features are used like Master/Content pages, Ajax, DataTable, Validators and web forms.

With Jspx 1.2 there were two new demo projects added. One offline Demo was jspx-demo3, that is demonstrating the use of jspx to create simple asset tracking application. The other demo was an online jspx live demo.

See also

Related Research Articles

Jakarta Server Faces

Jakarta Server Faces is a Java specification for building component-based user interfaces for web applications and was formalized as a standard through the Java Community Process being part of the Java Platform, Enterprise Edition. It is also a MVC web framework that simplifies construction of user interfaces (UI) for server-based applications by using reusable UI components in a page.

Apache Struts 1

Apache Struts 1 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top-level Apache project in 2005.

In computing, Oracle Application Development Framework, usually called Oracle ADF, provides a Java framework for building enterprise applications. It provides visual and declarative approaches to Java EE development. It supports rapid application development based on ready-to-use design patterns, metadata-driven and visual tools.

Apache Wicket, commonly referred to as Wicket, is a component-based web application framework for the Java programming language conceptually similar to JavaServer Faces and Tapestry. It was originally written by Jonathan Locke in April 2004. Version 1.0 was released in June 2005. It graduated into an Apache top-level project in June 2007.

Apache Tapestry

Apache Tapestry is an open-source component-oriented Java web application framework conceptually similar to JavaServer Faces and Apache Wicket. Tapestry was created by Howard Lewis Ship, and was adopted by the Apache Software Foundation as a top-level project in 2006.

In software engineering, a plain old Java object (POJO) is an ordinary Java object, not bound by any special restriction. The term was coined by Martin Fowler, Rebecca Parsons and Josh MacKenzie in September 2000:

"We wondered why people were so against using regular objects in their systems and concluded that it was because simple objects lacked a fancy name. So we gave them one, and it's caught on very nicely."

XML Interface for Network Services (XINS) is an open-source technology for definition and implementation of internet applications, which enforces a specification-oriented approach.

In software engineering, a WAR file is a file used to distribute a collection of JAR-files, JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages and other resources that together constitute a web application.

The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Although the framework does not impose any specific programming model, it has become popular in the Java community as an addition to the Enterprise JavaBeans (EJB) model. The Spring Framework is open source.

Stripes is an open source web application framework based on the model–view–controller (MVC) pattern. It aims to be a lighter weight framework than Struts by using Java technologies such as annotations and generics that were introduced in Java 1.5, to achieve "convention over configuration". This emphasizes the idea that a set of simple conventions used throughout the framework reduce configuration overhead. In practice, this means that Stripe applications barely need any configuration files, thus reducing development and maintenance work. It has been dormant since 2016.

ItsNat Natural AJAX, is an open-source Java component-based Ajax framework.

The front controller software design pattern is listed in several pattern catalogs and related to the design of web applications. It is "a controller that handles all requests for a website", which is a useful structure for web application developers to achieve flexibility and reuse without code redundancy.

RichFaces

RichFaces is an open source Ajax-enabled component library for JavaServer Faces, hosted by JBoss. It allows easy integration of Ajax capabilities into enterprise application development. It reached its end-of-life in June 2016.

In computing, Facelets is an open-source Web template system under the Apache license and the default view handler technology for Jakarta Server Faces. The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on building the JSF component tree, reflecting the view for a JSF application.

Apache Click is a page and component oriented web application framework for the Java language and is built on top of the Java Servlet API.

Java view technologies and frameworks are web-based software libraries that provide the user interface, or "view-layer", of Java web applications. Such application frameworks are used for defining web pages and handling the HTTP requests (clicks) generated by those web pages. As a sub-category of web frameworks, view-layer frameworks often overlap to varying degrees with web frameworks that provide other functionality for Java web applications.

ZK is an open-source Ajax Web application framework, written in Java, that enables creation of graphical user interfaces for Web applications with little required programming knowledge.

JWt is an open-source widget-centric web application framework for the Java programming language developed by Emweb. It has an API that uses established GUI application development patterns. The programming model is component-based and event-driven, similar to Swing.

The Brutos Application Framework is MVC controller written in Java. Designed to reduce the complexity of web development, with configurable mapping, view resolution as well as support for uploading and downloading files. Can be configured using XML, annotations and CoC.

References

  1. http://jspx-bay.sourceforge.net
  2. "Jspx Bay Name".
  3. "Jspx Name on SourceForge".
  4. "Jspx Design Aspects".
  5. "Jspx Hello Web".
  6. "jspx dependency injection".
  7. "Jspx Ajax".
  8. "Ajax in Jspx".
  9. "Jspx AjaxPanel Limitation".
  10. "JAAS on the webcontrol level"..
  11. "jspx features".
  12. "jspx jar dependency".
  13. "jspx in JDC 2010". Archived from the original on 2010-02-10.