File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Blog around the Campfire and the fly likes Ze Framework - A simple lightweight java web application framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Other » Blog around the Campfire
Bookmark "Ze Framework - A simple lightweight java web application framework" Watch "Ze Framework - A simple lightweight java web application framework" New topic
Author

Ze Framework - A simple lightweight java web application framework

Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 24
Hi Developers,

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.

Thanks
Manan V. Panchal
Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 24
I am seeking some consideration on the framework. I don't think that without your opinions and views the framework will become mature.

Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41839
    
  63
I'm sceptical. Web frameworks have largely moved away from XML configuration towards using annotations and convention-over-configuration. How does this framework compare to other request-oriented web framework framework like the XML-configured Struts 1 or the annotation-configured Stripes? When (or why) would I use ZE instead?


Ping & DNS - my free Android networking tools app
Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 24
Thank you very much Ulf

Actually I need this kind of suggestions and reviews on this. This is actually my innocent trial to develop a useful stuff. I should keep in mind that what configuration techniches I have used with this is really old. I am thinking about using annotations and other missing features in next release. Actually I have already a list ready to be added.

I was not comparing the framework with the Struts1 or Stripes. Its are milestones in java web development.

But, I would try to say some better features for the framework and for that I need to compare it with others.

- Struts cannot have java.util.Date as a property of ActionForm, whereas here we can have. And we can provide timezone and date format to convert the submitting string value into date. The same is true for getting the date value to display as a string.

- Struts can have array as ActionForm property, but cannot have multidimensional array. We can have any dimension array in ze framework. In general scenario, we can have a form like table with multiple input controls. This type of form can be easily handled with defining two dimension array as model property. The values of each cell will separately be set to elements of two dimension array by framework. The other possibility is that we have list box where multiple items are chosen to be submitted, then a whole selected values array will be assigned to the array property of model.

- Struts can have a nested hierarchy of user defined object inside ActionForm, but it needs to use nested tag for that, whereas here it is simple as setting or getting a string property in model.

- With Struts we think about actions like; do login, do order, do logout. Whereas with JSF we think about components of page, we actually think about data on page. Web page is second matter with struts whereas event is second matter with JSF. Whereas with Ze, we can think about both independently.

Suppose, a scenario where we submit a page in struts. The data will be populated in ActionForm and Action will process it. Now, we need a page to be sent redirect to display after the data processing. So, Action will return ActionForward for the page. The next page should have some data to be displayed. Where do we do this data loading? Surely inside Action. Right? Now, the page is sent redirect and data is displayed on web page. But, what if data is changed in back end and we refresh the page. We will not see the changes on refreshing. To handle this scenario we need to return an ActionForward of another action which actually handles data loading task for the page. Now, if we refresh the page we get latest data. There are separate "View" and "Action" event in ze framework to avoid this tricky programming.

Suppose, we need to display a page with data. We need model classes which carry the data and a loader class which loads the data into the models. We haven't think about any action yet. If we need to put any action on page we can simply do it by defining models classes which carry submitted data, an action handler class which process the data and simply returns next view name. To define view we don't need to think about action and to define action we don't need to think about view. If we need latest data we simply refresh the page and we get freshly loaded data. If session is expired at server side for this user and user submits the form the models will be created again and populated with submitted data. The models need not to be in state with browser data because we can use different models to carry action data. The "Action" is not dependent on "View" and vise a versa. With JSF, an event is dependent on components. The components should be exist at server side when an event generated from browser otherwise it would result in exception. With Struts, web page data is dependent on Action if we don't use tricky programming of creating another action for data loading.

- With Struts, next page are bound with action. We need to define that how many forwards are there after finishing action. With Ze, this is not the case. We can return any view name from action handler. The view event is generated and will take care of loading data for web page. Action event need not to bother about that.

These is my try to say some features of the framework. I compared ze with struts and JSF, I used some hard words for the frameworks. I actually sorry for this. I know that there are many cons exits in Ze framework. There might be some bug exits. Struts are very big framework, there are lot many other features that is not exits in Ze framework. Struts have very large collection of custom tags. JSF is far more big and full of features that I never think that it will be added ever in Ze framework.

Please, let me know your thinking on my described points.

Thanks again Ulf.

Manan


Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 24
I have added "RichDemoExample" at sourceforge.

This demo shows how the framework handles user defined object's hierarchy with multidimensional array of that objects.

The syntax of getting date value from a model is: <zfw: out valuefrom="m{testmodel.udo1s[1][2][3].udo2s[4][5][6].udo3s[7][8][9].dates[5][5][5]}f{MM/dd/yyyy HH:mm:ss}t{GMT}"/>
And setting a date value to the model is: <zfw: textfield name="testdate" valueto="m{testmodel.udo1s[1][2][3].udo2s[4][5][6].udo3s[7][8][9].dates[4][4][4]}f{MM/dd/yyyy HH:mm:ss}t{GMT}"/>
The udo1s is an three dimensional array as property of model. This hierarchy goes on till dates array.

Thanks
Manan Panchal
Greenhorn

Joined: Nov 17, 2008
Posts: 24
I have uploaded a "FullArchitectureDemoExample" at sourceforge.

The example shows most of the execution path of the framework. It includes most of the facility the framework provides.
Please, read comments in xml config file and java files of the example for more information.
When you see output on browser, java codes and config file of the example you would get all the architecture knowledge of the framework.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ze Framework - A simple lightweight java web application framework