On 3/20/07, ZedroS Schwart <[EMAIL PROTECTED]> wrote:
> Thanks again for all these answers.
>
> I just don't get right the last one :
> > They are also good for when you work with value objects ('thin'
> > representations of the your domain objects).
>
> Could you be more explicit please ?

http://wiki.java.net/bin/view/Javapedia/ValueObject

I guess that's still a bit of a broad definition as well. What I meant
it was that if you have domain objects mapped by e.g. Hibernate for
instance a class like:

class School implements Serializable {
  long id;
  String name;
  Address address;
  Region region;
  List memberShips;
}

some people say you shouldn't use these objects directly in forms, as
you can run into all kinds of problems like not having the (Hibernate)
session available at the right time and if you defined transactions
over requests (e.g. by using a filter, which for the record I'm
personally not crazy about) you can end up saving more than you
should.

A solution is to use objects that map certain properties of these
domain for specific cases. For instance, if I wanted to edit the
address of a school in a form, I could create an object like this:

class SchoolVO implements Serializable {
  final long schoolId; // not editable
  String addressLine;
  String postalCode;
  String regionCode;
}

and then in onSubmit

School school = schoolService.load(schoolVO.getSchoolId());
schoolVO.merge(school);
schoolService.save(school);

Personally, I'm not a fan of this pattern as it results in code
duplication and can be a bit of a pain to maintain when the domain
model changes. Though *if* you use per request transactions it's
probably sensible to use it as you'll avoid potentially hard to track
down problems and inefficiencies.

My 2c,

Eelco

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to