Hello,
I adapted the "booking example" that ships with the seam distribuition and run
into some problems. The User object is a Ejb3 entity object with scope of
Session. It is instantiated and injected by seam as the submit button is
pressed on the register.xhtml page.
For a logged in user, the session scope makes sense. however in this scenario,
it is not desirable to keep the state of the user (the object itself).
It would be desirable to always create a new instance of the user object, when
the register.xhtml page is opened (linked-in).
The example in the demo app only works, because the username is taken as
primary key: it will be set to a new value each time anyway. The same object is
reused over and over again this way.
When using a Long as id like this:
| @Id
| @GeneratedValue(strategy = GenerationType.AUTO)
| public Long getId() {
| return id;
| }
|
...the app will throw an exception. (Detatched object passed to persist).
Instead of using a "form backing (dto style) bean", I did a workaround hack
(from the register method in RegisterAction):
| final User allNewUser = new User();
| allNewUser.setUsername(user.getUsername());
| allNewUser.setName(user.getName());
| allNewUser.setPassword(user.getPassword());
|
| em.persist(allNewUser);
|
Here the var named user is the one passed in by seam and obviously all its
fields are copyied over to a new instance.
This is of course not nice and I would like to learn how to implement this
properly (using seam).
What am I missing?
Thanks a lot for your help, regards raoul
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4108618#4108618
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4108618
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user