Showing posts with label ADF. Show all posts
Showing posts with label ADF. Show all posts

Thursday, September 7, 2017

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






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

CaptiveCode


Monday, September 4, 2017

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);
    }
}



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

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();
    }




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

CaptiveCode


Sunday, September 3, 2017

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"


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


How To: Throw an exception in ADF

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




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

CaptiveCode


Saturday, March 25, 2017

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

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


Tuesday, August 30, 2016

How To: Perform "Date Conversion" in ADF/ OAF/ JAVA

I run into the struggle of converting one data type to another all the time. And obviously, I don't recollect instantly how to convert one from another. So here's some notes for me & hopefully they will useful for you as well.

// 1. Get Date from Calendar 
 int year=2016; int month=1; int date=1;
 Calendar cal = Calendar.getInstance();
 cal.set(year, month, date);
 java.util.Date utilDate = cal.getTime();

// 2. Convert java.util.Date to java.sql.Date
 java.util.Date utilDate = new java.util.Date();
 java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());

// 3. Convert java.sql.Date to oracle.jbo.domain.Date
 java.sql.Date sqlDate = new java.sql.Date();
 new jbo.domain.Date(sqlDate);
 /* To get current date & time in jbo.domain.Date */
 java.util.Date utilDate = new java.util.Date();
 java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
 oracle.jbo.domain.Date jboDate = new oracle.jbo.domain.Date(sqlDate);

// 4. Convert java.util.Date to java.sql.Timestamp
 java.util.Date utilDate = new java.util.Date();
 java.sql.Timestamp timestamp_now = new java.sql.Timestamp(utilDate.getTime())

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

CaptiveCode

Thursday, August 25, 2016

How To: Remove all rows from view object (VO) in OAF & ADF

Option 1: 

The executeEmptyRowSet() method can be used to empty the VO. This is my preferred approach.
    /* Use the following snippet in the Application Module (AM) */
    OAViewObjectImpl vo = this.getMyDummyVO();
    vo.executeEmptyRowSet();

Option 2: 

Loop through the VO and remove each row. If the data set is too large this could be cost intensive. I do not prefer this option.
    /* Use the following snippet in the Application Module (AM) */
   OAViewObjectImpl vo = this.getMyDummyVO();
   while(vo.hasNext()){
      vo.next().remove();
   }

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


CaptiveCode


Sunday, March 27, 2016

ADF Skinning: Skin an ADF Pop-up

Mastering the art of ADF Skinning can help you change the look and feel of your application. Please view some of my prior blogs to get acquainted with the basics - How to create an ADF Skin, Applying custom class to ADF Faces

Today, we will discuss a specific use case. I have been asked the question – How to apply a border to an ADF popup? Let’s figure out how!

Skinning a PopUp

1. Create a custom skin MyDemo.css (Refer this post if you don’t know how to do this)

2. Identify the root component within the popUp. For this example, I am considering it to be an dialog box.

2. Add the following class to MyDemo.css
af|dialog.myClass { 
 border: solid; 
 border-width: thick; 
 border-style: solid; 
 border-color: Red;
}

3. Apply the class to the popup component
<af:popup childCreation="deferred" autoCancel="disabled" id="p1">
      <af:dialog id="d2" styleClass="myClass">
              <af:outputText value="This is my dialog box" id="ot2"/>
       </af:dialog>
</af:popup>

4. Run the page. And here’s how the popUp should look



Hope you find this information useful.Please share your feedback below. I would love to hear from you.

CaptiveCode

Sunday, March 13, 2016

ADF: Skinning: Applying ALTA UI Skin to an ADF Application

Oracle’s new ALTA UI (introduced in 12c) provides a modern look to your ADF application. It is simple, clean and at the same time very sleek. Let me share with you how you applying the out of the box ALTA Skin to your application.
  • Note: You do not need to perform these steps when using the latest release of Oracle JDeveloper 12.2.1  as ALTA UI is extended by default when you create a new skin file.

Applying the ALTA Skin

Create a custom skin file MyDemoSkin.css within your ADF application. Refer to my prior post for the detail steps on how to do this.

Your trinidad-config.xml file looks like this:

<?xml version="1.0" encoding="windows-1252"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
<skin-family>myDemoSkin</skin-family>
</trinidad-config>


Update the Trinidad-config.xml and add a version number for your skin-family. 

  • Best Practice - "Always version your skin families"

<?xml version="1.0" encoding="windows-1252"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
<skin-family>myDemoSkin</skin-family>
<skin-version>v1</skin-version>
</trinidad-config>


Your trinidad-skins.xml looks like this:


<?xml version="1.0" encoding="windows-1252"?>
<skins xmlns="http://myfaces.apache.org/trinidad/skin">
<skin>
<id>myDemoSkin.desktop</id>
<family>myDemoSkin</family>
<extends>skyros-v1.desktop</extends>
<render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
<style-sheet-name>skins/myDemoSkin/myDemoSkin.css</style-sheet-name>
<bundle-name>com.demo.view.skinBundle</bundle-name>
</skin>
</skins>

Notice that your skin (MyDemoSkin) extends the out of the box skyros skin (skyros-v1.desktop). We will update this to extend ALTA skin.


Update the trinidad-skins.xml to modify the <extends> property:
<?xml version="1.0" encoding="windows-1252"?>
<skins xmlns="http://myfaces.apache.org/trinidad/skin">
<skin>
<id>myDemoSkin.desktop</id>
<family>myDemoSkin</family>
<!--extends>skyros-v1.desktop</extends-->
<extends>alta-v1.desktop</extends>
<render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
<style-sheet-name>skins/myDemoSkin/myDemoSkin.css</style-sheet-name>
<bundle-name>com.demo.view.skinBundle</bundle-name>
</skin>
</skins>

Now your ADF UI will follow the ALTA look and feel. Furthermore, you can create custom classes within your MyDemoSkin.css and enhance the appearance of your UI.

Learn how to define custom style classes and apply them to ADF Faces components here.


Hope you find this information useful. Please share your feedback below. I would love to hear from you. 

CaptiveCode


ADF: Skinning: Creating a custom skin for an ADF Application

Applying style to your ADF application can radically change its look and feel. Here’s the basics on how!

Creating a Skin File

Using the new component wizard à JSF/Facelets à ADF Skin

New Gallery > JSF Facelets > ADF Skin

Provide a file name and the skin family

Enter FileName for ADF Skin

Select the base skin custom skin (MyDemoSkin.css) will be based on

Inherit skyros in ADF Skin 

Add your custom classes to the MyDemoSkin.css file

Add custom class to ADF Skin


Understanding the Impact

An entry is made in the trinidad-skins.xml
  • You can define multiple skin files within the trinidad-skins.xml file
  • You can define multiple skin files within the skin family
Review ADF Skin

An entry is created the trinidad-config.xml file defining the skin family that is used by the application.
  • You can have multiple skin families defined within your application. The <skin-family> tag specifies the skin family that is currently being used by the application.
  • You can use EL expression to programmatically apply skin family programmatically  here:
    • <skin-family> #{mybean.value}</skin-family>

Review ADF Skin


Learn how to define custom style classes and apply them to ADF Faces components in my next post.


Hope you find this information useful. Please share your feedback below. I would love to hear from you.

Captive
Code


ADF: Skinning: Applying a custom style class to an ADF Faces component

In my previous post we learnt how to create and apply a skin file to an ADF application. In this post, we shall learn how to add custom style classes and make your application look great!

Define your custom style class in the myDemoSkin.css file

.myFirstClass{      
        Color: Red;
Font-weight: bold;
}
  • You can use the property inspector on the right to edit your style class


Applying the skin to a ADF Faces Component

Set the style class property of the ADF Faces component to your custom class' name

    <af:outputText value="This is how my styling looks on an outputText component." id="ot1" styleClass="myFirstClass"/>

This is how the result looks:


ADF 12c supports CSS 3.0 standards and is very powerful. You can do a range of things using CSS style your components, programmatically apply style classes and use expressions within style classes to control property values. We will discuss further more in my upcoming posts.


Hope you find this information useful. Please share your feedback below. I would love to hear from you.

Captive
Code