3 Replies Latest reply on Feb 3, 2008 7:22 PM by pmuir

    Unwanted datamodel update on action cancel

    blabno

      I have 2 pages :
      A) data table with entities representing countries
      B) edit form used to edit name of selected country
      Now, when i select country on page A, the form loads with input field loaded with country's name. I change value of that field to whatever else and press cancel button which takes me back to page A. But name of country that i just quit editing is changed (and even persisted) ! I do not want such bahaviour. What should I do ?
      btw. same thing happens in demo application dvd-store when you change products quantity in cart and press "Continue shopping" instead "Update and recalculate total", which in my opinion should not cause amount in cart be changed.

      <?xml version="1.0"?>
      <pageflow-definition
       xmlns="http://jboss.com/products/seam/pageflow"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://jboss.com/products/seam/pageflow http://jboss.com/products/seam/pageflow-2.0.xsd"
       name="addCountry">
      
       <start-state name="start">
       <transition to="addCountry"/>
       </start-state>
      
       <page name="addCountry" view-id="/locations/addCountry.jspx" no-conversation-view-id="/locations/browseLocations.jspx">
       <redirect/>
       <transition name="next" to="evaluateSuccess">
       <action expression="#{countryManager.save}" />
       </transition>
       <transition name="cancel" to="cancel"/>
       <transition name="addRegion" to="addRegion"/>
       </page>
      
       <process-state name="addRegion">
       <sub-process name="addRegion"/>
       <transition to="addCountry"/>
       </process-state>
      
       <decision name="evaluateSuccess" expression="#{countryManager.error}">
       <transition name="false" to="complete"/>
       <transition name="true" to="addCountry"/>
       </decision>
      
       <page name="complete" view-id="/locations/complete.jspx" no-conversation-view-id="/locations/browseLocations.jspx">
       <end-conversation before-redirect="true"/>
       <redirect/>
       </page>
      
       <page name="cancel" view-id="/locations/browseLocations.jspx">
       <end-conversation before-redirect="true"/>
       <redirect/>
       </page>
      
      </pageflow-definition>


        • 1. Re: Unwanted datamodel update on action cancel
          blabno

          Hey guys, you sure know some way to work it out !

          I do not want to put view-id in form buttons, but only transition names. When I do that, then form gets submitted and my injected object gets changed according to data entered into form (event PK). Can i somehow block inserting submitted form data into object attributes ?

          • 2. Re: Unwanted datamodel update on action cancel
            javichi_fer

            You are probably using an Extended Persistet Context. If you really need it try making the country field (the one you edit) a String property of some backing bean and dont use the Entity property directly.

            If the user clicks to save the country set the Entity property with the new value and if he clicks cancel just do nothing but redirect to the appropiate view.

            • 3. Re: Unwanted datamodel update on action cancel
              pmuir

              Use manual flushmode and use the none conversation propagation. I wouldn't do what javichi_fer suggests -thats pretty ugly.