-
1. Re: Unintentional Entity Update when changing form
bemar Apr 6, 2011 6:59 AM (in response to bemar)No ideas?
-
2. Re: Unintentional Entity Update when changing form
lvdberg Apr 6, 2011 7:47 AM (in response to bemar)Hi,
This happens because you're using a
managed bean
inside your application. I can't see the rest of the code, but as soon as you start changing attributes, these chages will be persisted. To prevent this, switch to manual flushing andconnect
the final save/flush to the confirm button.You need to change some things:
- Start the converation when you enter the properties page. You can add the manual flush in the page-definition in the begin tag, or as an attribute in the Begin-annotation.
- Put the entitymanager.flush() in the confirm method and put the end-annotation also there.
Hopefullly this helps
Leo
-
3. Re: Unintentional Entity Update when changing form
bemar Apr 6, 2011 7:58 AM (in response to bemar)Hi,
thx for your answer. Will try it asap and let you know.
Best regards
Ben
-
4. Re: Unintentional Entity Update when changing form
bemar Apr 7, 2011 6:06 PM (in response to bemar)Sorry, isn't working.
I will describe my workflow:
1. IncidentEdit.xhtml
EditPage. Inserting your values. BaseBean is incidentHome
Having
`
<begin-conversation join="true" flush-mode="MANUAL" />
`
in incidentEdit.page.xml
`
<h:commandButton id="view"
value="#{messages.text_view}" action="#{incidentHome.confirm}" />
`
2. incidentHome.confirm
`
@Begin(join = true)
public String confirm()
{
return "confirmed";
}
`
3. page redirection to incident.xhtml via incidentEdit.page.xml
"<begin-conversation join="true" flush-mode="MANUAL" />
<!-- <action execute="#{incidentHome.wire}"/>-->
<param name="incidentFrom" />
<param name="incidentIdIncident" value="#{incidentHome.incidentIdIncident}" />
<navigation from-action="#{incidentHome.confirm}">
<rule if-outcome="confirmed">
<redirect view-id="/Incident.xhtml" />
</rule>
</navigation>"
When I debug into incidentHome.confirm button the update will right executed after leaving the method.
I have the debug information on all of my xhtml sites on the conversion will be displayed as long-running. After the update the conversiation ID is still the same and the conversation is still long-running. -
5. Re: Unintentional Entity Update when changing form
kragoth Apr 7, 2011 8:12 PM (in response to bemar)@Begin(join = true) public String confirm() { return "confirmed"; }
I think you need to reread what Leo wrote.
- Start the converation when you enter the properties page. You can add the manual flush in the page-definition in the begin tag, or as an attribute in the Begin-annotation.
- Put the entitymanager.flush() in the confirm method and put the end-annotation also there.
You do not want @Begin on the confirm method. You are ALREADY in a long running conversation. You possibly want an @End but certainly not @Begin.
I do my conversation management a very different way these days so I'm not as knowledgeable as Leo in this area so, read what he said carefully.