11 Replies Latest reply: Feb 13, 2013 1:39 AM by grodno RSS

    commit doesn't work via operation binding

    grodno
      hi,

      i try to commit changes made by selectonechoice boolean .
      why can't this commit invoked in backing bean not work?

      OperationBinding operationBinding = getBindings().getOperationBinding("Commit");
      operationBinding.execute();

      at the same time when i call commit button, everything gets commiited
      jdev 11.1.2.3

      Edited by: grodno on Feb 12, 2013 1:57 AM
        • 1. Re: commit doesn't work via operation binding
          Mohammad Jabr
          what do you mean by i try to commit changes made by selectonechoice boolean .?
          Do you see any exception in the log?
          Is the Commit binding defined in the page definition?
          Can you elaborate more in your question?
          • 2. Re: commit doesn't work via operation binding
            grodno
            the chechbox is a column's value which is based on VO->EO , it reflects changes to the underlying DB right after user cliicks checkbox.
            <af:column sortProperty="#{bindings.DcaRegisterLinesV1.hints.Selected.name}" filterable="true"
            sortable="true" headerText="#{bindings.DcaRegisterLinesV1.hints.Selected.label}" id="c1"
            width="30">
            <af:selectBooleanCheckbox value="#{row.bindings.Selected.inputValue}"
            label="#{row.bindings.Selected.label}" autoSubmit="true"
            valueChangeListener="#{registerBean.socSelectedChangeListener}"
            shortDesc="#{bindings.DcaRegisterLinesV1.hints.Selected.tooltip}" id="sbc1">
            </af:selectBooleanCheckbox>
            </af:column>


            functionality works fine, since it works when i press commit button after the click
            so that i can see changes in the DB immediatly
            the pagedef uses the same definition in pagedef that was created upon button creation.
            sure commit is defined in pagedef
            <action id="Commit" RequiresUpdateModel="true" Action="commitTransaction" DataControl="AppModuleDataControl"/>

            could it be connected with am tuning (some postponed posts), vo passivation mode?

            Edited by: grodno on Feb 12, 2013 2:43 AM
            • 3. Re: commit doesn't work via operation binding
              Timo Hahn
              Where and when do you call the commit operation in your bean?
              Do you do it from inside the valueChangeListener?
              Have you checked for errors after executing the operation?

              Timo
              • 4. Re: commit doesn't work via operation binding
                grodno
                Timo

                you are right!
                i do call it from inside the valueChangeListener!
                are there some limitations for commit in there?
                neither i check for errors - i'll check to check for errors now...
                btw, the workaround for it is to enqueue button pressed action works fine
                • 5. Re: commit doesn't work via operation binding
                  Mohammad Jabr
                  can you try to add these two lines of code before you execute the commit
                  FacesContext contxt = FacesContext.getCurrentInstance();
                  valueChangeEvent.getComponent().processUpdates(contxt);
                  OperationBinding operationBinding = getBindings().getOperationBinding("Commit");
                  operationBinding.execute();
                  • 6. Re: commit doesn't work via operation binding
                    Suresh Karunarathne
                    Hi,
                    Did you add the "Commit" operation to binding layer.(DataControl --> Operation -->Commit)
                    • 7. Re: commit doesn't work via operation binding
                      grodno
                      interesting , what i've never known is

                      valueChangeEvent.getComponent().processUpdates(contxt);

                      what is it meant for?
                      • 8. Re: commit doesn't work via operation binding
                        grodno
                        yes, i've put relevant data from pagedef above
                        • 9. Re: commit doesn't work via operation binding
                          Timo Hahn
                          The process updates pushes the new value into the model layer. That's the reason why it did not work in the first place. Inside the value change event the new value is not processed, meaning it's not pushed into the model layer. So when you execute commit from inside the event listener, the model layer had not changed and the commit will not execute as there are not change to commit..

                          Question is why you commit in a valueChangeListener. This is normally not the right place to do a commit.

                          Timo
                          • 10. Re: commit doesn't work via operation binding
                            Mohammad Jabr
                            >
                            interesting , what i never known is

                            valueChangeEvent.getComponent().processUpdates(contxt);

                            what is it meant for?
                            >
                            check the API [url http://docs.oracle.com/javaee/6/api/javax/faces/component/UIComponent.html#processUpdates%28javax.faces.context.FacesContext%29]processUpdates
                            • 11. Re: commit doesn't work via operation binding
                              grodno
                              the reason for immediate commit is driven by user request
                              the use case implies user can edit a tables column's value (date) which should be reflected in the DB right away...
                              but i was wrong as for where i try to commit.
                              in fact , i try to commit in the bean's method invoked by serverListener()

                              <af:clientListener method="doCommit" type="valueChange"/>
                              <af:serverListener type="CommitEvent" method="#{registerBean.handleEnterEvent}"/>

                              oh, and sorry for confusion...

                              Edited by: grodno on Feb 12, 2013 11:37 PM