Flipkart Search

Tuesday 27 January 2015

Using google / custom fonts in the ADF application

In ADF use can use any google font as you used to use default fonts provided by ADF or Webcenter.
Here are the steps.

  1. Register the css file in the page through the af:resource tag
<af:resource type="css" source="http://fonts.googleapis.com/css?family=Lobster"/>

     2. Make an entry in the application's css file.

.inText {
    font-family: 'Lobster', cursive;
    font-size: medium;

   3. Put the above styleclass in the component
<af:outputText styleClass="inText " value="Text with google font"

Precaution while using javascript in a page fragment or in ADF region

Don't include javascript in the page Fragment just after the jsp:root tag . It will cause undesired effects if this page is navigated from somewhere else.
This will be a wrong approach for a jsff page
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
  <af:resource type="javascript" source="/js/custom.js"/>

The right approach is to include this resource component inside a  container component . Like this
  <af:resource type="javascript" source="/js/custom.js"/>

Tuesday 13 January 2015

ADF Performance Tuning part-1 - Production tuning

  1. animation-enabled=false in trinidad-config.xml file
  2. in web.xml file do the following changes if not done already
    1. oracle.adf.view.rich.automation.ENABLE=false
    2. oracle.adf.view.rich.ASSERT_ENABLED=false
    3. org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION=false
    4.  org.apache.myfaces.trinidad.COMPRESS_VIEW_STATES=true
    5. org.apache.myfaces.trinidad.DEBUG_JAVASCRIPT=false
    6. org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION=false
    7. oracle.adf.view.rich.libraryPartitioning.DISABLED=false 
    8. oracle.adf.view.rich.LOGGER_LEVEL=false
    9. javax.faces.STATE_SAVING_METHOD=client 
    10. oracle.adf.view.rich.versionString.HIDDEN=true

  3.  Use the ADFLogger
  4. Don't use System.out.* or System.err.* - These have major impact on performance
  5. Remove commented out code
  6. Do not import view or controller classes
  7. Close callableStatement, preparedStatements and RowSetIterators
  8. Use application module JDBC data source only not  JDBC URLs.
  9. Run with Enable Application Module pooling on for production .
  10. Define at least one entity object key attribute per entity object.
  11.  Ensure entity object UI Hints and messages are internationalized
  12. Avoid read only view objects as far as possible
  13. Use view criteria over editing view object where clauses
  14. Never use view object select *
  15. Limit custom code in bean accessors -ie. in getters and setters
  16. Use beans only defined in the task flow for reuse 
  17. Avoid applicationScope and sessionScope variables
  18. Define applicationScope and sessionScope beans in adfc-config.xml
  19. Only create backing beans when actually needed, do not bind unnecessary component references into backing beans.
  20. Avoid long component ID lengths.
  21. Avoid unnecessary use of clientComponent=true
  22. Use rendered=false over visible=false wherever possible.
  23. Never rely on UI side validation.
  24. Avoid inline page/fragment JavaScript and CSS
  25. Manual tests for UIs should include stretch / shrink behavior.
  26. Manual tests for UIs should include changing font size[Zoom-in and Zoom-out testing]
  27. url.rewriting.enabled should be false in weblogic.xml
  28. Make sure jbo.debugoutput  is disabled for production
  29. Make HA available. Add this entry in adf-config.xml file
  <adf-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">

Monday 5 January 2015

Useful methods in Oracle ADF part-2

//1. Method to call a flow in taskFlow programatically 

 public static void gotoFlow(String flowName) {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        NavigationHandler handler = app.getNavigationHandler();
        handler.handleNavigation(context, null, flowName);
//2. Util method to show error and Success Msg
 public static void showMsg(String msgBody, String msgSeverity) {
        FacesMessage fm = new FacesMessage(msgBody);
        if (msgSeverity.equals("info")) {
        } else if (msgSeverity.equals("warn")) {
        } else if (msgSeverity.equals("error")) {
        } else {
        FacesContext fctx = FacesContext.getCurrentInstance();
        fctx.addMessage(null, fm);
//3. Get Cookie value in ADF
        public static String getCookieValue(String cookieName) {
        FacesContext fctx = FacesContext.getCurrentInstance();
        ExternalContext ectx = fctx.getExternalContext();
        Map vRequestCookieMap = ectx.getRequestCookieMap();
        Cookie cookie = (Cookie)vRequestCookieMap.get(cookieName);
        if (cookie != null) {
            return cookie.getValue();
        return null;
//4. Load a jsp or jspx page (redirect to a page)
  public static String loadPage(String pageName) {
        FacesContext vFacesContext = FacesContext.getCurrentInstance();
        ExternalContext vExternalContext = vFacesContext.getExternalContext();
        ControllerContext controllerCtx = null;
        controllerCtx = ControllerContext.getInstance();
        String activityURL = controllerCtx.getGlobalViewActivityURL(pageName);
        try {
        } catch (IOException e) {

        return null;
//5. Initializing the ADFLogger

private static ADFLogger _logger = 
//6. Clear the ADF table filter
    public static void removeFilter(RichTable tableBind,String processQueryName) {
        FilterableQueryDescriptor queryDescriptor =
        if (queryDescriptor != null &&
            queryDescriptor.getFilterCriteria() != null) {
//processQueryName can found in queryListner of table eg:- #{bindings.Employee1Query.processQuery}
                                              Object.class, QueryEvent.class,
                                              new QueryEvent(tableBind,
// 7.Implementing like type filter in ADF table filter
public static void likeFilter(RichTable tableBind,String processQueryName) {
        FilterableQueryDescriptor queryDescriptor =
        if (queryDescriptor != null &&
            queryDescriptor.getFilterCriteria() != null) {
            Map m=queryDescriptor.getFilterCriteria();
            Set keys = m.keySet();
           Map modified=new HashMap();
            for (Iterator i = keys.iterator(); i.hasNext();) {
                  String key = (String) i.next();
                  String value = (String) m.get(key);
                if(value!=null && !value.equals("")){
                  System.out.println(key + " = " + value);
                                              Object.class, QueryEvent.class,
                                              new QueryEvent(tableBind,
                                              Object.class, QueryEvent.class,
                                              new QueryEvent(tableBind,
// 8. Launching / Invoking a PopUp from Bean. [popupBind is binding of popup inside the bean]
RichPopup.PopupHints hints = new RichPopup.PopupHints();