Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP Forms based on XML or POJO

Reply
Thread Tools

JSP Forms based on XML or POJO

 
 
j-hill925
Guest
Posts: n/a
 
      02-09-2007
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

 
Reply With Quote
 
 
 
 
Chris
Guest
Posts: n/a
 
      02-09-2007
j-hill925 wrote:
> 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.
 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      02-09-2007
On Feb 9, 11:13 am, "j-hill925" <(E-Mail Removed)> wrote:
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert types between axis skeleton and POJO facade service generically cmi@ch.ibm.com Java 0 04-09-2006 08:15 PM
Auto populate POJO.. Is there a library that can do this? muthu.ramadoss@gmail.com Java 8 10-27-2005 04:35 PM
Hibernate Update POJO from JSP mdjj Java 0 09-15-2005 01:15 PM
Adding session variables to a JAX-RPC SOAP POJO? Scott Balmos Java 1 08-31-2005 07:50 PM
POJO design question (mapping Java Objects to a database) hilz Java 9 07-27-2004 05:10 AM



Advertisments