-
1. Re: EntityHome Reset
mwohlf Mar 9, 2009 10:51 AM (in response to kabil)same confusion here, what I did was this
- to prevent early flushes from the EntityHome I use flush-mode=
manual
when I start the conversation
- to reset EntityHome I use clearInstance() and additional remove the instance from the conversation scope with Contexts.getConversationContext().remove(
changeRequestError
)
but I am not sure if this is the seam way, manually removing stuff from the conversation context seems a bit hack-ish, in the example apps I have also seen some kind of HolderObject to host an instance during a conversation, if anyone got a better solution to these common problems I would like to know...
- to prevent early flushes from the EntityHome I use flush-mode=
-
2. Re: EntityHome Reset
kabil Mar 9, 2009 11:31 AM (in response to kabil)Well,
In fact I am making new seam-gen templates for gui and back end, I use modal panels for edit, delete new entity creation, it is almost done but I am troubled with this being dirty if any changes is made.I also used manual mode and clearinstance(), but it also sets dirty of course, so clearDirty must be called.
Why I did not want to use manual mode is because after I add a new Entity object when I rerender my datatable (with onComlete event), I could not see the one created newly, but if I reRender manually after whole create object operation, datatable is refreshed with the new one. So to make this work I needed to call seam-gen'ed XXXList component's refresh() method. In fact which must be automatically called while reRendering. This one was another story..
I didnt know Contexts.getConversationContext().remove(
changeRequestError
) be called. It seems really hacking in an unusual way. -
3. Re: EntityHome Reset
mwohlf Mar 9, 2009 5:08 PM (in response to kabil)well err... just to be clear
changeRequestError
is the name of my entity that I want to remove from the conversation scope, I just copied this from my source, I am not really proud of this line of code I admit and still looking for a better way to do this... -
4. Re: EntityHome Reset
hakanm Jan 31, 2011 5:07 AM (in response to kabil)did you have chance to resolve this problem 'cause we are facing with this too.
thanks in advance. -
5. Re: EntityHome Reset
vata2999 Jan 31, 2011 6:29 AM (in response to kabil)Hi,
If u r using EntityHome and i understand your problem correctly
maybe this helps youdefine your Entity in component.xml as Seam Component
<component class="com.mydomain.myproject.model.User" name="user" />
there is a getNewInstance method you can ovveride as below
ValueExpression<User> u; @Override public ValueExpression getNewInstance() { u = Expressions.instance().createValueExpression("#{user}", User.class); return u; }
then u can access newInstance of your object
User u = (User) getNewInstance().getValue();
-
6. Re: EntityHome Reset
serkan.s.eskici.online.nl Feb 1, 2011 2:27 PM (in response to kabil)Use entityManager.refresh(yourEntity) to reload the state from the db.
This is what the EntityManager API says about this method:
refresh(Object entity):
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.What you also can do is call setId(null) in EntityHome, to make sure that you don't make any changes to an existing entity.