4 Replies Latest reply: May 6, 2012 8:47 AM by Jan Vervecken RSS

    using BindingContext.getCurrent().getCurrentBindingsEntry()

    Jan Vervecken
      hi

      - A blog entry from Steve Muench, "Nice One-Liner to Reference BindingContainer in 11g"
      at http://radio-weblogs.com/0118231/2008/10/15.html
      ... suggest that using BindingContext.getCurrent().getCurrentBindingsEntry() is an improvement over resolving the EL expression #{bindings} .
      - the Fusion Developer's Guide for ADF 11g R1 currently does not seem to mention "getCurrentBindingsEntry"
      see http://www.oracle.com/pls/as111130/search?remark=quick_search&word=getCurrentBindingsEntry&partno=b31974
      - that same Fusion Developer's Guide for ADF 11g R1 currently does suggest to resolve the EL expression #{bindings} in "Example 9-15 Helper Method for Backing Bean Class"
      at http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcservices.htm#BABHAFEF
      - recent feedback I got from development (in SR 3-2190488381) suggesting how to implement a workaround also resolved the EL expression #{bindings}

      Can someone please refer to an authoritative online resource that confirms that using BindingContext.getCurrent().getCurrentBindingsEntry() is preferable over resolving the EL expression #{bindings} ?
      Or maybe an Oracle product manager can confirm it in this forum thread?

      many thanks
      Jan Vervecken
        • 1. Re: using BindingContext.getCurrent().getCurrentBindingsEntry()
          Frank Nimphius-Oracle
          Jan,

          BindingContext and this "getCurrent().getCurrentBindingsEntry()" was added in 11g for convenience reasons to get rid of having to use EL. The reason you see #{bindings} used in the documentation is that usually docs are carried forward and obviously not all samples are revisited and checked for the latest and greatest use of APIs. For the same reason #{data} should no longer be used in 11g. Its however not doing anything wrong when you use #{bindings} instead, its just an unnecessary EL parsing that is involved. The coding disadvantage of 4 lines of code more to write doesn't count as many customers use ADFUtils or a custom version of it.

          To quote the JavaDocs of the BindingContext class

          * Returns the current BindingContainer for the execution context.
          *+
          * This will return the value of the 'bindings' variable on the
          * ADFContext requestScope.  This is equivalent to evaluating the
          * 'bindings' expression using an expression evaluator in the current
          * execution context.


          Frank

          Edited by: Frank Nimphius on Dec 30, 2010 6:16 AM
          • 2. Re: using BindingContext.getCurrent().getCurrentBindingsEntry()
            Jan Vervecken
            Thanks for your reply Frank.

            And for referring to the BindingContext API documentation
            at http://download.oracle.com/docs/cd/E14571_01/apirefs.1111/e10653/oracle/adf/model/BindingContext.html#getCurrentBindingsEntry%28%29

            regards
            Jan
            • 3. Re: using BindingContext.getCurrent().getCurrentBindingsEntry()
              Jan Vervecken
              fyi

              Another illustration of the use of getCurrentBindingsEntry() is the code that JDeveloper 11.1.1.3.0 generates when double-clicking a button with an action binding and having the "Generate ADF Binding Code" checkbox checked.
              public class SomePage
              {
                   public SomePage()
                   {
                   }
              
                   public BindingContainer getBindings()
                   {
                        return BindingContext.getCurrent().getCurrentBindingsEntry();
                   }
              
                   public String commitAction()
                   {
                        BindingContainer bindings = getBindings();
                        OperationBinding operationBinding = bindings.getOperationBinding("Commit");
                        Object result = operationBinding.execute();
                        if (!operationBinding.getErrors().isEmpty())
                        {
                             return null;
                        }
                        return null;
                   }
              }
              regards
              Jan
              • 4. Re: using BindingContext.getCurrent().getCurrentBindingsEntry()
                Jan Vervecken
                fyi

                see also JIRA issue ADFEMG-21, "evaluate bindings or use getCurrentBindingsEntry()",
                at http://java.net/jira/browse/ADFEMG-21

                regards
                Jan