tags:

views:

312

answers:

3

Hi,

I would like to create little higer-level framework on top of Struts2 which can take form element description from Action and render a complete form, in order to avoid having a separate JSP files with hardcoded form elements for every form in a large web application (so if I manage to do this I will have just a few generic JSPs for data form and few for layout). Application is extremely data-driven.

My idea is to create form description using custom objects in the Action (i.e. Button, TextInput etc.) and then to create a single JSP page that will render eveything out.

What is the best way of doing this? Can you propose some concrete way to do this?

I don't want to write something if I can reuse the existing code with some effort.

Any ideas are appreciated.

Kind regards,

Bozo

A: 

It seems to me you are trying to build a web framework on top of another, I doubt Struts2 is appropiate for that. If you have a data-driven web app for which you dont want to write many similar JSP (or whatever view lang) pages, perhaps you'd better look at some frameworks with scaffolding abilities , eg Grails http://www.grails.org/Scaffolding

leonbloy
A: 

I did what I asked in the question myself - I have created a few generic JSP templates (list, edit etc.) which take application parameters and create output grids and forms using the struts2 and simple HTML tags. Using this method generic tiles definitions can also be created and used. So at the end using simple definition in the struts2 action, the grid and form is generated.

bozo
A: 

Hi, can you please share something in detail..I am also looking for similar kind of approach.. but struts 2 is my constraint..I need to use the same framework to generate dynamic form and to handle data on submit. I mean how can I generate dynamic getters and setters so that I could be able to handle the data from that particular field. my mail id is [email protected]

Thanks Deepansh

Deepansh
Write a hierarchy of objects in Java that will be stored in Struts action. Then write JSP page that will go through this list and draw various form elements. That's it.Of course, the whole thing is pointless in many cases since there are already JSF and similar technologies that do exactly this but in a more low-level way so that you don't have to. But if you really want you can use the approach from my 1st paragraph in this comment.
bozo