0 Replies Latest reply on Feb 11, 2009 1:26 PM by Roman Rodov

    Seam data binding and changes to entities

    Roman Rodov Newbie

      Hi All,

      I'm asking this question to better understand Seam and how it works in relation to data binding and component outjection.

      Here is an entity and an action component.

      public class MyEntity implements Serializable {
        @Id  private int id;
        private string prop1;
        private string prop2;
        ... getters and setters ...
      public class MyAction {
        @In @Out private MyEntity myEntity;
        public void actionMethod() {

      Say there is a editMyEntity.xhtml view that allows to edit the myEntity and the Save button calls actionMethod(). The doSomethingWithMyEntity() method can perform some business logic and then persist the myEntity object.

      My question is, and I am sure I am not the first one with it: If I change a property of myEntity object when doing business logic in doSomethingWithMyEntity (as a developer, not the user, like change some timestamp or something, which IS visible to the user). And say 10 lines later I encounter some business rule (or an exception) that forces me to stop doing what I'm doing and re-display the screen with an error message for instance. HOW do I rollback the change to the myEntity object that was done in my code?
      When everyone was doing DTOs, it was easy, because you had your serialization layer that translated between your domain objects and your DTOs, so uncommitted changes to your domain objects would not propagate to the screen. But how do you do it now when you are using your domain objects bound in the UI with lazy loading and other nice things Seam provides? Does Seam offer something here? Or do you need to roll your own attaching/detaching objects type scheme that will do it for you (hopefully in a nice way)?
      I am interested in how people are doing it right now!