QOW #2: What is wrong in my action binding setting?

See the answer for last QOW#1 here

QOW#2 (14 July 2013):
This time it's easy:)
I've exposed a method from AM that takes two parameters,  public void findEmps(String firstName, String email). Exposed it through data control for use by client and then dropped it as methodAction to a JSF page, binding to a af:commandButton. While dropping the method, I used the following setting in the editor. Do you see anything wrong here?



Answer (Updated on 21 July 2013)

Both Thanvir  Parthan and Sharath Ram has done a great job in answering this query, and in fact nothing is left to me in answering this one except sharing link to one of my old post.  Read this post - http://www.jobinesh.com/2009/06/detailed-look-at-binding-model.html

To summarize the answer, while defining parameters for an action binding, better do not set any value for Option type.  If you specify Option as Mandatory, you are telling framework that do not consider the EL or literal value specified in the binding definition, so parameter value may come as null if you use this method action binding from UI.  With this setting, you may want to use OperationBinding API for invoking this method action definition passing the value as parameter map

 DCBindingContainer bc = (DCBindingContainer)bcx.getCurrentBindingsEntry();
   OperationBinding opb = (OperationBinding)bc.getOperationBinding("someMethod");
   // someMethod is with signature public void someMethod(String someArg)
   opb.getParamsMap().put("someArg", "someValue");
   opb.invoke();



Comments

  1. The email parameter is set as mandatory.

    ReplyDelete
  2. I guess you can still set the email parameter as mandatory but the value cannot be passed from a binding definition?

    The email parameter has to be explicitly set.

    ReplyDelete
  3. Thank you all. Updated the post with the answer.

    ReplyDelete

Post a Comment