Mark Tielemans
Mark Tielemans

Reputation: 1568

ADF Invoke operation manually from code

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.

Upvotes: 1

Views: 13746

Answers (3)

Hyangelo
Hyangelo

Reputation: 4812

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();

Upvotes: 1

Joe
Joe

Reputation: 3347

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();

Upvotes: 1

Shay Shmeltzer
Shay Shmeltzer

Reputation: 3721

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

Upvotes: 2

Related Questions