Tuesday, April 29, 2014

Ze Framework - A powerful but lightweight java framework for web applications


I have developed a java web application framework. Name of the framework is "Ze Framework".
The framework is developed by considering two basic request from browser.

[1] Requesting to view a web page. (e.g. Clicking on a page link).
[2] Submitting form data to server to be processed. (e.g. Hitting submit button).

When a user requesting to view a web page, we called it here as "View" event. And when user submitting some data, we called it as "Action" event.

We know that "View" event can be occurred independently, but "Action" event always followed by "View" event.

Here, I have separated the "View" event and "Action" event.

"View" event:

What do we need to implement "View" event? We need a loader class which loads that data what are going to be displayed later. The loader class loads the data and sets it into models classes. Now, JSP fetches the models' data to display on browser.
So, we need three component to fulfill the event: (1) A loader class (2) Some model classes (3) A JSP page.

So, now we need a configuration xml file in which we can map all this to a "View" event. The config file is based on an xsd. The framework parses the config file using JAXB, so we need that xsd along with the config xml.

"Action" event:

What do we need to implement "Action" event?. We need a handler class which processes the submitted data. But, how would we get that submitted data into handler? The framework populates that submitted data into model classes. The handler gets data from the models and processes it. After processing, user need to view some page, so it is actually a "View" event. The handler needs to return a "View" event name, by which the framework kick starts that "View" event and the whole above described stuff for "View" event would going on and user would see a web page. So, we need two components to fulfill the event: (1) Some model classes (2) A handler class.

We can configure with the framework that a "View" event succeeded by an "Action" event are to be dispatched or to be sent redirect.

What if an exception occurs while executing an application developed using the framework? To solve this, the framework has a mechanism. There is an exception handler class and a JSP page we can configure with an exception. When the configured exception or its base exception would be thrown the handler class would be called by the framework and after finishing execution of the handler class the JSP page would be dispatched. The exception information can be displayed on the JSP by custom tags of the framework.

We can configure validator chain for an "Action" event. The validator validate form data populated in models and if there are some validation errors it populates the errors in error list and returns true or false to the framework. If it returns true the framework calls next validator in the validator chain other otherwise not. The validation errors will be displayed by the custom tags on web page later.

We can configure validator chain for a "View" event. The validator validates that the view is eligible to be displayed or not. If not than the validator returns other view name instead of current and the other "View" event occurs. But, if the validator returns null then next validator would be called in the validator chain.

We can configure application initializer and application destroyer classes. The classes would be called when application context initialized and destroyed respectively. There are an other configuration too. We can configure a processing tube class which would be called on each "View" or "Action" event.

The framework would generate conversation errors if form data are not the type of mapped model properties. It will be displayed by the custom tags on web page later.

User can generate application messages in any place of application. It will be displayed by the custom tags on web page later.

Other features of the framework:

[1] Model classes for an event ("View" or "Action") can be more than one.
[2] Model class can have below type of properties:
    (1) int, long, short, boolean, char, double, float
    (2) java.lang.Integer, java.lang.Long, java.lang.Short, java.lang.Boolean, java.lang.Character, java.lang.Double, java.lang.Float
    (3) java.lang.String, java.util.Date
    (4) Any user defined object
    (5) Array of above all type (1) to (4)
[3] User defined object property of a model can have any of above type (1) to (5)
[4] The framework provides expressions by which JSP page can fetch data from any depth of model's properties.
[5] A JSP can read data of type (1), (2), (3) and (5) from model using the expressions. The last property should not be (4)th type.
[6] When user inputs some data into form, the data is in string format. But, the framework can convert that data into above types except (4). To convert data we just need to map that property with the input filed of the form.
[7] An enough set of custom tags which are used:
    - to fetch model data to be displayed, to set model data to be processed later
    - to create html forms, input fields, links, buttons etc
    - to display application messages, conversation errors, validation errors
    - to loop for some integer variable
    - to define variable and assign some value to it
    - to display exception info

Please, find the code, binary, example apps, tutorial and control flow diagram of the framework here http://sourceforge.net/projects/zeframework/.
Please, mail me on zeframework@gmail.com for your suggestions and bugs.

For, detailed tutorial about the framework, please go to: http://zeframework.blogspot.in/