JSP Forms based on XML or POJO

Discussion in 'Java' started by j-hill925, Feb 9, 2007.

  1. j-hill925

    j-hill925 Guest

    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
    j-hill925, Feb 9, 2007
    #1
    1. Advertising

  2. j-hill925

    Chris Guest

    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.
    Chris, Feb 9, 2007
    #2
    1. Advertising

  3. j-hill925

    Daniel Pitts Guest

    On Feb 9, 11:13 am, "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'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.
    Daniel Pitts, Feb 9, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hilz
    Replies:
    9
    Views:
    3,131
    P.Hill
    Jul 27, 2004
  2. Scott Balmos
    Replies:
    1
    Views:
    638
    Steve W. Jackson
    Aug 31, 2005
  3. mdjj
    Replies:
    0
    Views:
    728
  4. Replies:
    8
    Views:
    3,063
  5. Replies:
    0
    Views:
    503
Loading...

Share This Page