Mapping the HTTP request to a bean / domain object

Discussions

Web tier: servlets, JSP, Web frameworks: Mapping the HTTP request to a bean / domain object

  1. Mapping the HTTP request to a bean / domain object (4 messages)

    Hi,

    I have some complex JSP pages that deal with a complex underlying domain model. I have written a lot of code that maps the parameters from the HTTP Request object into this domain model. Then I can do things like validation and persistence etc. But as I write this code I begin to feel there has to be a better way. I have A LOT of set() and get() methods and it gets hard to maintain if the domain model changes or the on screen parameters change.

    So, is there a general way of solving this that I should know about?

    Many thanks,
    Mike.
  2. Struts.

    http://jakarta.apache.org/struts
  3. Adam, thanks for the reply.

    I've taken a quick look at struts. From what I have seen so far it seems struts maps the request parameters only into a single, flat bean. But I have a more complex domain model i.e one that involves a hierarchy.

    I need the address.city field in the JSP to be mapper to user.getAddress().getCity(). Can struts do that?

    Thanks again,
    Mike.
  4. Hi Mike,

    I m doing the same thing in my application. We are using struts but for now we are converting the form into domain objects before passing them into the action bean. However when we want to display the data in the jsp we can directly call the hierarchical objects.

    have you found a better way to do it.

    Thanks in advance
  5. Sorry so long in replying. THe nightly builds allow nested parameters. YMMV. We use it.

    The documentation is supplied with the distro for the build