Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2007

Tip: Looking for answers? Try searching our database.

JSP Forms based on XML or POJO

Thread view: 
j-hill925 - 09 Feb 2007 19:13 GMT
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
Chris - 09 Feb 2007 22:00 GMT
> Hi All,
>
[quoted text clipped - 19 lines]
> 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.
Daniel Pitts - 09 Feb 2007 23:17 GMT
> Hi All,
>
[quoted text clipped - 19 lines]
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.