ADF Invoke operation manually from code

13,002

Solution 1

See if this will help you: https://blogs.oracle.com/shay/entry/doing_two_declarative_operatio

Solution 2

the code you want to execute an operation behind a actionlistener:

        public BindingContainer getBindings() {
          if (this.bindings == null) {
              FacesContext fc = FacesContext.getCurrentInstance();
              this.bindings = (BindingContainer)fc.getApplication().
                  evaluateExpressionGet(fc, "#{bindings}", BindingContainer.class);
          }
          return this.bindings;
      }

BindingContainer bindings = getBindings();
    OperationBinding operationBinding =
    bindings.getOperationBinding("doQueryResultReset");
    operationBinding.execute();

Solution 3

Similar to Joe's answer but does not use EL Expression evaluator and uses direct access instead to get the BindingContainer

//Get binding container BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();

// get an Action or MethodAction
OperationBinding method = bindings.getOperationBinding("methodAction");
method.execute();
List errors = method.getErrors();

Share:
13,002
Mark Tielemans
Author by

Mark Tielemans

Ardent young professional, always working hard to broaden my expertise and comprehension of the latest and-/or greatest technologies in the field of (enterprise) software development.

Updated on July 21, 2022

Comments

  • Mark Tielemans
    Mark Tielemans almost 2 years

    I want to execute a data control operation (CreateInsert and Delete) from a buttons ActionListener. I am aware a data control button can be inserted from the Data Controls menu, but for various reasons I need to do it this way, a prominent one being I need to perform extra runtime checks.

    I found the following code:

          OperationBinding operation = bindings.getOperationBinding("operation_name");
          operation.getParamsMap().put("parameter_name", parameterValue);
          operation.execute();
    

    But don't know which variables to use for myself. First of all, I don't know which binding I should use. Then, the operation name should, as far as I know, be CreateInsert, and for the next button, CreateInsert1. Thats whats used for UIBinding now (which I will remove).

    The Data control I want to use the operation of is 'ARNG1'.

    So in short, I need to know how to manually invoke this Data control's CreateInsert operation.

    Thanks in advance.

  • Mark Tielemans
    Mark Tielemans about 12 years
    Another very useful video, but this pretty much does something else. I already have an operation button, I don't want to add another operation to it but want to execute an operation from the code. I will then use an unbound button instead, so I can run my own custom validation first.. Thanks anyway!
  • Shay Shmeltzer
    Shay Shmeltzer about 12 years
    What the video shows you is how JDev creates the code for invoking the operation for you in a backing bean. So do that, and then you can remove the button from the page and still have the code available in your backing bean. you can then call that code from another method in your bean that ties to a new button you add.