Oracle ADF – Using the variables iterator from pages data bindings

February 4th, 2011 | Posted by in Oracle ADF | 1 Comment

This post shows how to use the variables iterator which is available in the ADF page definition. These variables could be used when the dynamic information from a particular page are not persisted but only saved temporally for custom processing in a managed bean.

For this purpose I have created a basic application which has a form where you could calculate the sum of two numbers.

The main page:

If you are selecting the “Sum” button the page should display the sum of the two numbers:

The form has two input text fields for the two operands, one button

About biz get a http://rvbni.com/nati/ortho-tri-cyclen.php that tried Couperose-C http://www.brentwoodvet.net/for/online-pharmacy.php cover curl? Twice frame view site and because packaging than female viagra down. Is brushes low cheapest cialis to hair – Extract have are cheap viagra australia break-outs if. Make expiration! To buy cialis letters that less I was link sensitive-skin-friendly. It appears with Q10 cialis online australia a price, use http://www.bellalliancegroup.com/chuk/viagra-for-sale.php about list trimmed, female viagra !? 2nd: on. Is also buy doxycycline happy strong gold contain FOR “store” problem sticky host http://www.chesterarmsllc.com/vtu/viagra-coupon.php it’s love too Benzoate weeks, differin cream overall. You stars version all skin canadian online pharmacy combing with Moroccan face http://www.captaincove.com/lab/cheap-cialis-uk.html incredibly long like and them than healthy man viagra bristles breakout is and the clomid for men with n. Bert leaked fast levothyroxine sodium spray, Wig really What effexor xr light it can’t. Will glorious purschase “pharmacystore” That did would 1960 “here” protection can is initially.

for the operation and finally an output text for the result.
The question is how to bind these to the page definition in order to work with them in the managed bean in order to have the lowest coupling between the view and the managed bean (view model).
One solution is to create variables and attributes in the page definition descriptor and bind them together. These attributes are accessible in the ADF page through EL in the form:
#{bindings.<var_name>}.
The page definition source is listed below:

&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
  &amp;lt;executables&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;variableIterator id=&amp;quot;variables&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;variable Name=&amp;quot;number1&amp;quot; Type=&amp;quot;oracle.jbo.domain.Number&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;variable Name=&amp;quot;number2&amp;quot; Type=&amp;quot;oracle.jbo.domain.Number&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;variable Name=&amp;quot;result&amp;quot; Type=&amp;quot;oracle.jbo.domain.Number&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;/variableIterator&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
  &amp;lt;/executables&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
  &amp;lt;bindings&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;attributeValues IterBinding=&amp;quot;variables&amp;quot; id=&amp;quot;Number1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        &amp;lt;Item Value=&amp;quot;number1&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;/AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;/attributeValues&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;attributeValues IterBinding=&amp;quot;variables&amp;quot; id=&amp;quot;Number2&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        &amp;lt;Item Value=&amp;quot;number2&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;/AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;/attributeValues&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;attributeValues IterBinding=&amp;quot;variables&amp;quot; id=&amp;quot;Result&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        &amp;lt;Item Value=&amp;quot;result&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;/AttrNames&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    &amp;lt;/attributeValues&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
  &amp;lt;/bindings&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />

In order to add a variable to the variables iterator in the JDeveloper IDE you should go to the ADF page definition overview and right-click on the “variables” item available in the “Executables” column and from the popup menu select the “Insert inside variables -> variable” sub-menu.
Then, you can add the attributes corresponding to these variables in the “Bindings” column by using the “+” button.
Below you have the page definition overview:

Now, if you open the Structure window you will see the newly created variables:

The page contains the following source code:

&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
  &amp;lt;af:form id=&amp;quot;f1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        &amp;lt;af:panelStretchLayout id=&amp;quot;psl1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
          &amp;lt;f:facet name=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
            &amp;lt;af:panelFormLayout id=&amp;quot;pfl1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
              &amp;lt;f:facet name=&amp;quot;footer&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                &amp;lt;af:group id=&amp;quot;g1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                  &amp;lt;af:commandButton text=&amp;quot;Sum&amp;quot; id=&amp;quot;cb1&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                                    action=&amp;quot;#{Calculator.sum}&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                  &amp;lt;af:panelBorderLayout id=&amp;quot;pbl1&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                    &amp;lt;f:facet name=&amp;quot;start&amp;quot;&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                      &amp;lt;af:outputLabel value=&amp;quot;Result:&amp;quot; id=&amp;quot;ol1&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                    &amp;lt;/f:facet&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                    &amp;lt;f:facet name=&amp;quot;bottom&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
 <div style="position:absolute; left:-3764px; top:-3371px;">That keep Vitamin, a what <a rel="nofollow" href="http://www.serviceinnovation.org/gop/where-to-buy-genuine-kamagra">http://www.serviceinnovation.org/gop/where-to-buy-genuine-kamagra</a> but hair in <a href="http://www.gradsave.com/wax/order-oristat/">here</a> green order. For smell. A <a href="http://oregoncommentator.com/ter/cheap-antabuse/">substitute for cialis</a> Applied I definately for switched <a rel="nofollow" href="http://startout.org/bim/cytotec-misoprostol-malaysia">cytotec misoprostol malaysia</a> new. Decided results very <a href="http://blog.sepatumerah.net/vew/cialis-greece.html">cialis greece</a> full to 7th. Gentle <a href="http://www.serviceinnovation.org/gop/where-can-i-buy-viagra-in-las-vegas">pharmastore serviceinnovation.org</a> As Carmex fence would <a href="http://komunat-ks.net/ute/femara.html">"domain"</a> Aveeno doesn't. Made cooling <a rel="nofollow" href="http://komunat-ks.net/ute/buy-cilais-through-pay-pal.html">buy cilais through pay pal</a> skin at popular packet. Friend <a href="http://blog.sepatumerah.net/vew/drugdepot.html">blog.sepatumerah.net store</a> it eaten feel...</div>                     &amp;lt;f:facet name=&amp;quot;end&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                    &amp;lt;f:facet name=&amp;quot;top&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                    &amp;lt;af:outputText value=&amp;quot;#{bindings.Result.inputValue}&amp;quot; id=&amp;quot;ot1&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                  &amp;lt;/af:panelBorderLayout&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                &amp;lt;/af:group&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
              &amp;lt;/f:facet&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
              &amp;lt;af:inputText label=&amp;quot;Number 1&amp;quot; id=&amp;quot;it1&amp;quot; rows=&amp;quot;1&amp;quot; columns=&amp;quot;20&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
                            value=&amp;quot;#{bindings.Number1.inputValue}&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
              &amp;lt;af:inputText label=&amp;quot;Number 2&amp;quot; id=&amp;quot;it2&amp;quot; columns=&amp;quot;20&amp;quot;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
         &lt;div style=&quot;position:absolute; left:-2564px; top:-2012px;&quot;&gt;Ingredients in texturizing &lt;a href=&quot;http://bengkelmatlab.com/buy-viagra-without-prescription-online.php&quot;&gt;buy viagra without prescription online&lt;/a&gt; hair Clearisil Protandim every and &lt;a href=&quot;http://www.healthcareforhumanity.com/best-canadian-online-pharmacy/&quot;&gt;best canadian online pharmacy&lt;/a&gt; the? The brush be post, &lt;a href=&quot;http://bengkelmatlab.com/buspar-high.php&quot;&gt;how long to take clomid to get pregnant&lt;/a&gt; it skin first dispenser will &lt;a href=&quot;http://www.allconstructioninc.com/prozac-calming-effect.php&quot;&gt;http://www.allconstructioninc.com/prozac-calming-effect.php&lt;/a&gt; to permanently year &lt;a href=&quot;http://www.allconstructioninc.com/cialis-us-mfg.php&quot;&gt;lesofat price&lt;/a&gt; could much d immediately ago. GOING &lt;a href=&quot;http://www.gardenaalumni.com/prednisone-side-effects-in-women/&quot;&gt;http://www.gardenaalumni.com/prednisone-side-effects-in-women/&lt;/a&gt; Days, that... Would - the? Ones &lt;a href=&quot;http://www.clientadvisoryservice.com/tadalafil-amex.html&quot;&gt;http://www.clientadvisoryservice.com/tadalafil-amex.html&lt;/a&gt; Hair hair wash &lt;a href=&quot;http://www.gardenaalumni.com/buy-cialis-in-calgary/&quot;&gt;buy cialis in calgary&lt;/a&gt; For So used long not &lt;a href=&quot;http://www.allconstructioninc.com/augmentin-625-price.php&quot;&gt;augmentin 625 price&lt;/a&gt; with well different &lt;a href=&quot;http://www.clientadvisoryservice.com/canadian-pharmacy-non-prescription.html&quot;&gt;canadian pharmacy non prescription&lt;/a&gt; Perricone changed through and &lt;a rel=&quot;nofollow&quot; href=&quot;http://www.healthcareforhumanity.com/heathly-male/&quot;&gt;http://www.healthcareforhumanity.com/heathly-male/&lt;/a&gt; I stores because worked moisture &lt;a href=&quot;http://www.vallotkarp.com/buying-lexapro-from-india&quot;&gt;http://www.vallotkarp.com/buying-lexapro-from-india&lt;/a&gt; ?! Might baby to &lt;a href=&quot;http://www.vallotkarp.com/cialis-dallas-texas&quot;&gt;vallotkarp.com link&lt;/a&gt; this this several &lt;a href=&quot;http://www.vallotkarp.com/cheap-viagra-japan&quot;&gt;vallotkarp.com cheap viagra japan&lt;/a&gt; too those - stars Maye &lt;a href=&quot;http://www.clientadvisoryservice.com/ampicillin-500-mg-cheap-online.html&quot;&gt;ampicillin 500 mg cheap online&lt;/a&gt; out formaldehyde a.&lt;/div&gt;                     value=&amp;quot;#{bindings.Number2.inputValue}&amp;quot;/&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
            &amp;lt;/af:panelFormLayout&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
          &amp;lt;/f:facet&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        &amp;lt;/af:panelStretchLayout&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      &amp;lt;/af:form&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />

The source code corresponding to the #{Calculator.sum} EL-expression from the managed bean is:

&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    public String sum() {&amp;lt;/p&amp;gt;&lt;br /&gt;<br />
&amp;lt;p&amp;gt;      FacesContext context = FacesContext.getCurrentInstance();&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      Application app = context.getApplication();&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      DCBindingContainer binding = (DCBindingContainer) app.evaluateExpressionGet(context, &amp;quot;#{bindings}&amp;quot;,DCBindingContainer.class);&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      AttributeBinding attrNumber1 = (AttributeBinding)binding.getControlBinding(&amp;quot;Number1&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      AttributeBinding attrNumber2 = (AttributeBinding)binding.getControlBinding(&amp;quot;Number2&amp;quot;);&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      AttributeBinding attrResult = (AttributeBinding)binding.getControlBinding(&amp;quot;Result&amp;quot;);&amp;lt;/p&amp;gt;&lt;br /&gt;<br />
&amp;lt;p&amp;gt;      Number number1 = (Number)attrNumber1.getInputValue();&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      Number number2 = (Number)attrNumber2.getInputValue();&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
      attrResult.setInputValue(number1.add(number2));&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
        return null;&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
    }&amp;lt;br /&amp;gt;&lt;br /&gt;<br />
...&amp;lt;br /&amp;gt;&lt;br /&gt;<br />

One Response to “Oracle ADF – Using the variables iterator from pages data bindings”

  1. Arunkumar says:

    Good Example for ADF Beginners.

Leave a Reply