How To: Launch a popup programmatically (ADF)

Create a binding for the popUp in the backing bean and use the following snippet to launch it programmatically





Please share your feedback below. Hope you find this helpful!

CaptiveCode


How To: Access one managed bean from another (ADF, JSF)

It is a common requirement to access methods between managed beans defined in varied scopes within ADF. In this post, I am invoking backing bean (method to enable/disable a button) from a request bean. The similar approach can be used for other scopes viz. pageFlow, session, application.


Download Sample Code on GitHub


Define your managed beans in your task flow:
    <managed-bean id="__1">
      <managed-bean-name id="__243">RequestBean</managed-bean-name>
      <managed-bean-class id="__244">ui.bean.RequestBean</managed-bean-class>
      <managed-bean-scope id="__245">request</managed-bean-scope>
    </managed-bean>
    <managed-bean id="__2">
      <managed-bean-name id="__248">BackingBean</managed-bean-name>
      <managed-bean-class id="__246">ui.bean.BackingBean</managed-bean-class>
      <managed-bean-scope id="__247">backingBean</managed-bean-scope>
    </managed-bean>
BackingBean Definition:
package ui.bean;

import oracle.adf.view.rich.component.rich.nav.RichCommandToolbarButton;

public class BackingBean {
    private RichButton submitBtn;

    public void setSubmitBtn(RichButton submitBtn) {
        this.submitBtn = submitBtn;
    }

    public RichButton getSubmitBtn() {
        return submitBtn;
    }
}
RequestBean Definition:
package ui.bean;

import javax.el.ELContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

public class RequestBean {

    public BackingBean getBackingBean() {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ELContext context = fctx.getELContext();
        BackingBean backingBean =
            (BackingBean) fctx.getApplication().getExpressionFactory()
                .createValueExpression(context,"#{backingBeanScope.BackingBean}",BackingBean.class)
                .getValue(context);
        return backingBean;
    }

    public void enableSubmit(ActionEvent actionEvent) {
        /* Invoke BackingBean method to enable/disable Submit Button */
        getBackingBean().getSubmitBtn().setDisabled(false);
    }
}



Please share your feedback below. Hope you find this helpful!

CaptiveCode


How To: Execute View Criteria programmatically

Consider the following view criteria is defined on a view object:




To execute this view criteria programmatically, write the following method in the AMImpl class:
    public void executeInvoiceVOCriteria(String invoiceNum, String poNum){
        ViewObjectImpl vo = getInvoiceVO1();        
        ViewCriteria vc = vo.getViewCriteria("InvoiceVOCriteria");
        vo.applyViewCriteria(vc);
        vo.setNamedWhereClauseParam("p_inv_num", invoiceNum);
        vo.setNamedWhereClauseParam("p_po_num", poNum);
        vo.executeQuery();
    }




Please share your feedback below. Hope you find this helpful!

CaptiveCode


How To: Pass parameters to action listener in ADF

I have commonly come across the requirement to pass parameters to the managed bean method on a button click. The challenge we normally face here is that, the methods attached to the "action" or "actionListener" have fixed signatures that cannot be changed.

Thus, we have to leverage the "<f:attribute>" tag alongwith a "actionListener"


Please share your feedback below. Hope you find this helpful!
CaptiveCode


How To: Throw an exception in ADF

To show an exception on ADF UI, implement the following in your managed bean:




Please share your feedback below. Hope you find this helpful!

CaptiveCode


Using Syntax Highlighter with Blogger

I use syntax highlighter in my blogs. Here is how to use it -

1. Go to Blogger >> Select Theme on the left-hand panel
2. Take a backup of the theme and save it on your desktop
3. Click Edit HTML
4. Add the following just before the </head> tag in the Theme HTML
<!-- START - SyntaxHighlighter -->

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script language='javascript' type='text/javascript'>
   SyntaxHighlighter.config.bloggerMode = true;
   SyntaxHighlighter.defaults.toolbar = false;
   SyntaxHighlighter.all();
</script>
<!-- END - SyntaxHighlighter -->
5. You're all set!


Please share your feedback below. Hope you find this helpful!

CaptiveCode



How To: Deploying applications on WebLogic using command line

This article is a quick reference on how to deploy applications to WebLogic server using command line interface.

Set classpath as follows:
set CLASSPATH=C:\Weblogic\Middleware\wlserver_10.3\server\lib\weblogic.jar


To deploy from your local desktop (remote):


To deploy a WAR file:
java weblogic.Deployer -adminurl <<admin server host:port>> -user weblogic -password ulorcl123$ -deploy C:\JDeveloper\mywork\myApp\deploy\myApp.war -remote -upload
To redeploy a WAR file:
java weblogic.Deployer -adminurl <<admin server host:port>> -user weblogic -password ulorcl123$ -redeploy -source C:\JDeveloper\mywork\myApp\deploy\myApp.war -remote -upload -name myApp.war


Common Errors:


Error:
'ModuleArchive' cannot be null
Resolution:
Make sure the source parameter is specified in the redeploy command

Please share your feedback below. Hope you find this helpful!

CaptiveCode