Friday, May 31, 2013

ADF Application Deployment failure with VALIDATION PROBLEMS WERE FOUND --


ADF Application Deployment failure with VALIDATION PROBLEMS WERE FOUND --




If you notice below kind of application when you are deploying ADF application , Ensure web.xml and weblogic.xml doesn't have any special characters or invalid data.

servers/soa_server1/tmp/_WL_
user/genericHumanTaskUI4_application1/ox604m/genericHumanTaskUI3_ViewController_webapp1.war"
weblogic.application.ModuleException: VALIDATION PROBLEMS WERE FOUND
  problem: cvc-complex-type.2.3: Element 'listener@http://java.sun.com/xml/ns/javaee' with element-only content type cannot have text content.:<null>

Tuesday, May 28, 2013

How to get next DB Sequence number in Java



Below is the snapshot of java code to retrieve the next DB sequence number




Tuesday, May 21, 2013

How to set Width to af:selectOneChoice component ?


How to set Width to <af:selectOneChoice> component ?


How to change Context root in ADF UI Application

Usecase : How to modify the name of an UI application context root path in Fusion ADF application ?

Implementation :

Right click on UI project -> Properties->Java EE Application


Java EE Web Context Root - Specify the whatever context path you want to, By default it will have '<Application Name>-<UI Project Name>-context-root' .

Java EE Web Application Name :

This is how the deployment URL looks like after updating above two values.

Note : Jdeveloper doesn't allow to enter '/' in above dialog box, So you can edit UI project .jpr file in a text pad or note pad and modify manually.

Tuesday, May 14, 2013

How to implement Security to a specific component in ADF

Usecase : How to implement security to a specific component in ADF ?  For eg : Enable/Disable specific component (Button/Inputtext/Panel/etc...) on a page based on the role of the logged in user.

Implementation:

- Create a new class as shown below
- Define a permission in jazn-xml as shown below
- Define 'Disabled' property of a component as shown below


disabled="#{securityContext.userGrantedPermission['permissionClass=fm.core.security.FMADFPermission;target=emp.viewComponents;action=view']}"

Reference :  http://docs.oracle.com/cd/E15523_01/web.1111/b31974/adding_security.htm#ADFFD877


Monday, May 13, 2013

hide or show popup programmatically in oracle adf?

In the managed bean add the following code

public void methodOne() {
        showPopup(editPopup, "p1");
}

// Code to show the popup
// It takes popup ID as the parameter
public static void showPopup(RichPopup popup, String popID) {
         FacesContext context = FacesContext.getCurrentInstance();
         StringBuilder script = new StringBuilder();
         script.append("var popup = AdfPage.PAGE.findComponent('").append(popID).append("'); ")
                 .append("if (!popup.isPopupVisible()) { ")
                 .append("var hints = {}; ");

           script.append("popup.show(hints);}");
           ExtendedRenderKitService erks =
             Service.getService(context.getRenderKit(), ExtendedRenderKitService.class);
           erks.addScript(context, script.toString());
}


How to Access MDS Data in ADF application

Usecase :
       How to store user specific defaults into MDS ?
       How to retrieve user specific defaults from MDS ?
       How to delete user specific defaults from MDS ?

Implementation :

Below blog clearly explains about MDS and installation steps
http://fortunefusionminds.blogspot.com/2013/04/how-to-apply-mds-to-adf-application.html

I will give a quick glance at API to access MDS data in this blog.

How to store user specific defaults into MDS ?

Ans : Below implementation stores the data into MDS in file system or Database.



    public static void saveSearchDefaults(String pSearchName,
                                          ViewObject pViewObject,
                                          ViewRowImpl pViewRow) {
        ViewCriteria vc = pViewObject.createViewCriteria();
        vc.setName(pSearchName);
        ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
        String[] attNames = pViewRow.getAttributeNames();
        for (String s : attNames) {
            Object viewRowAttributeValue = pViewRow.getAttribute(s);
            vcRow.setAttribute(s, viewRowAttributeValue);
        }
        vc.add(vcRow);
        pViewObject.getViewCriteriaManager().putViewCriteria(pSearchName, vc);
        JUSearchBindingCustomizer.createPersonalization(pViewObject, vc);
    }


How to retrieve user specific defaults from MDS ?
Answer : 


  /**
     * Retrieves all the saved search names from MDS for a given
     * Viewobject based on logged in user ID
     * @param pViewObject
     * @return
     */
    public static String[] getAllSavedSearchNames(ViewObject pViewObject) {
        String[] result =
            pViewObject.getViewCriteriaManager().getAllViewCriteriaNames();
        return result;

    }

How to apply User specific defaults to a given Row from MDS ?

Ans:


  /** Get the user specific default row from MDS based on
   *       logged in user ID, Provided view object name and search name
   *   Set the rows retrieved from MDS defaults row to provided row Impl class
     * Applies search preferences for saved search.
     * @param pSearchName
     * @param pViewObject
     * @param pViewRow
     */
    public static void applyUserSpecificDefaults(String pSearchName,
                                             ViewObject pViewObject,
                                             ViewRowImpl pViewRow) {
        ViewCriteria vc =
            pViewObject.getViewCriteriaManager().getViewCriteria(pSearchName);
        ViewCriteriaRow vcRow = (ViewCriteriaRow)vc.get(0);
        String[] attNames = vcRow.getAttributeNames();
        StringBuffer buf = null;
        for (String s : attNames) {
            Object vcRowAttributeValue = vcRow.getAttribute(s);
            if (vcRowAttributeValue != null) {
                pViewRow.setAttribute(s, vcRowAttributeValue);
            }
        }
    }

How to Delete User Specific defaults from MDS
Ans:

  /**
   * Deletes the saved search defaults from MDS based on
   * logged in user, search Name and given VIew Object
   * @param pSearchName
   * @param pViewObject
   */
  public static void deleteUserSpecificDefaultsFromMDS(String pSearchName,
                                            ViewObject pViewObject)
  {
    JUSearchBindingCustomizer.deletePersonalization(pViewObject,
                                                    pSearchName);
    pViewObject.getViewCriteriaManager().removeViewCriteria(pSearchName);
  }


Tuesday, May 7, 2013

How to invoke javascript function from Backing Bean in ADF

Usecase :   Invoke a java script method from backing bean based on some condition satisfies from managed/backing bean using ADF

Implementation :  Have below code in managed/backing bean.


         FacesContext fctx = FacesContext.getCurrentInstance();
         ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);      
         // Invoke a java script method name called showConfPopup()' with two parameters, You can pass any value 
         erks.addScript(fctx, "showConfPopup('" + popupClientId + "', '" + tabClientId + "')");  

Java Script Method , 

Include below code in any jspx in <af:document> element


<af:document>
<f:facet name="metaContainer">
          <af:resource type="javascript">

                  function showConfPopup(popupId, tabId){
                       alert("Hello");
                  }

          </af:resource>
        </f:facet>

Another way of invoking

<af:document id="d1">
 
  <af:clientListener method="onPageLoad" type="load"/>
  <f:facet name="metaContainer">
    <af:resource type="javascript">
      function onPageLoad(evt) {
        alert("Hello");
      }
    </af:resource>
  </f:facet>
</af:document>



Saturday, May 4, 2013

AND Operator in af:resource in javascript throwing error , Expected name instead of &



If you have encountered an error message using '&&' operator in <af:resource> , then try replacing '&&' with '&amp:&amp;'

 if (butPressed == 'YES' &&  (editGenInfo == 'Y'))


 if (butPressed == 'YES' &amp;&amp;  (editGenInfo == 'Y'))

How to invoke a backing bean method before ADF Life cycle ends using finalizer

Use case : Invoke a method in backing bean just before ADF life cycle ends, For eg : Whenever use closes the browser window of a specific page fragment, Want to invoke a method in backing bean.

Implementation

Define a finalizer entry in taskflow corresponds to the page fragment as shown below, releaseLock() is the method defined in CustomerBean.

This will invoke releaseLock() method whenever exit from specific page fragment.

<finalizer id="1">#{pageFlowScope.CustomerBean.releaseLock}</finalizer>