Wednesday, December 31, 2014

ADF: Show/Hide af:outputText based on Interval

Recently I came across a requirement to show/hide text on page based on certain time interval. I achieved it by using af:poll component. Even though we can do it through setInterval function available in javascript, I faced some problem with clearInterval in different browsers.

af: poll: if you set timeout as -1 it will poll infinitely.

Java Script:
        <af:resource type="javascript">
          var _ivtxt;
          function updateText(evt) {
              evt.cancel();
              var potll = evt.getSource();
              _ivtxt = potll.findComponent("otiv4");
              var vis = _ivtxt.getProperty("visible");
              if (vis) {
                  _ivtxt.setVisible(false);
              }
              else {
                  _ivtxt.setVisible(true);
              }
          }
 </af:resource>


JSF:
           <af:poll interval="#{pageFlowScope.showText? 1000 : -1}"
                       id="p5" timeout="-1">
                 <af:clientListener method="updateText" type="poll"/>
           </af:poll>

           <af:outputText value="Sample Text" id="otiv4" clientComponent="true"/>

ADF:JBO-33001:oracle.jbo.ConfigException

Recently I created a ADF application having multiple models and single view controller project. I exported same application as ADF Library and added to another application. When I tried to run the application, I faced following error.

Error:
javax.el.ELException: oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.ConfigException, msg=JBO-33001: Configuration file /com/bc4j.xcfg is not found in the classpath.
        at com.sun.el.parser.AstValue.invoke(AstValue.java:191)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1459)
        at oracle.adf.view.rich.component.UIXDialog.broadcast(UIXDialog.java:97)

 To fix this problem, I made following changes to View Controller project's Deployment profile.

Solution:
1. Open ViewController project properties dialog, select Deployment option and edit the required deployment profile.
2. In Deployment Profile Edit window, select Library Dependencies node and click the Edit Dependencies icon
3. In Edit Dependencies window, add a dependency on the build output path or on one or more deployment archives.