JSP Forms based on XML or POJO

J

j-hill925

Hi All,

I'm looking at building a new J2EE/struts/spring web application, and
after building several other apps with my company, I've found a common
problem. We are constantly adding new fields in the POJO's and then
we have to mirror that change in the JSP forms.

I have tried to do some importing of different form sections to get
allow me to reuse form sections, like addresses, but I'd like to take
a step further and map POJO's directly to JSP forms.

One example of this might be an address, I already have a populated
Address Object, which I want to display in a browser...right now I
have to create a JSP form that matches up with that object. Can't I
have something automatically generate a form with those fields? What
about something that could automatically turn a Struts Form into a JSP/
UI form?

I'm really in a design stage, I'd appreciate hearing about any of your
experiences, technologies and thoughts!!

Thanks,
Jeff
 
C

Chris

j-hill925 said:
Hi All,

I'm looking at building a new J2EE/struts/spring web application, and
after building several other apps with my company, I've found a common
problem. We are constantly adding new fields in the POJO's and then
we have to mirror that change in the JSP forms.

I have tried to do some importing of different form sections to get
allow me to reuse form sections, like addresses, but I'd like to take
a step further and map POJO's directly to JSP forms.

One example of this might be an address, I already have a populated
Address Object, which I want to display in a browser...right now I
have to create a JSP form that matches up with that object. Can't I
have something automatically generate a form with those fields? What
about something that could automatically turn a Struts Form into a JSP/
UI form?

I'm really in a design stage, I'd appreciate hearing about any of your
experiences, technologies and thoughts!!

Thanks,
Jeff

I think you're better off doing things in two different places. The
reason is that the POJO and the JSP serve different purposes. The POJO
reflects the data. The JSP reflects the display. It's usually a bad idea
to mix business logic with display logic. Google the term "MVC" to learn
more.
 
D

Daniel Pitts

Hi All,

I'm looking at building a new J2EE/struts/spring web application, and
after building several other apps with my company, I've found a common
problem. We are constantly adding new fields in the POJO's and then
we have to mirror that change in the JSP forms.

I have tried to do some importing of different form sections to get
allow me to reuse form sections, like addresses, but I'd like to take
a step further and map POJO's directly to JSP forms.

One example of this might be an address, I already have a populated
Address Object, which I want to display in a browser...right now I
have to create a JSP form that matches up with that object. Can't I
have something automatically generate a form with those fields? What
about something that could automatically turn a Struts Form into a JSP/
UI form?

I'm really in a design stage, I'd appreciate hearing about any of your
experiences, technologies and thoughts!!

Thanks,
Jeff

I've thought of several ways to do this, and I have to agree with
Chris on this one.
You're data layer, business layer, and presentation layer shouldn't
have to figure anything out from each other.

I know it seems like more work to add "address" to the database table,
AND the java bean, AND the JSP, but imagine this situation:

You have a NiftyLibrary that will update your JSP and database tables
based on any changes you make to your POJO.

Now, NiftyLibrary is pretty complex, relying on reflection and other
"interesting" features. Adding new features to NiftyLibrary is likely
to be a difficult process that requires regression testing, and still
uncaught bugs. But that shouldn't matter, because its all automatic,
and you only want to change your JSP and database when your POJO
changes...

So, you add a new property to your POJO:
Address myAddress;

NiftyLibrary does its job and you have everything done already.

Then, your manager comes along and says. "Oh, on this specific page,
when these conditions are met, we want the Address to only display the
Street name and City".

What would have been a simple change in a JSP, is now a week long
project to update NiftLibrary to take that special case.

Trust me on this, I've done it both ways.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top