Please disable your adblock and script blockers to view this page

Search this blog

Monday 22 October 2012

Refresh Page in Oracle ADF by Java Code, Set partial trigger programmatically

Some times we need to refresh whole page , then we can use this managed bean code to refresh whole page in ADF.


    
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;

//Method to reload page
    protected void refreshPage() {

        FacesContext fctx = FacesContext.getCurrentInstance();
        String page = fctx.getViewRoot().getViewId();
        ViewHandler ViewH = fctx.getApplication().getViewHandler();
        UIViewRoot UIV = ViewH.createView(fctx, page);
        UIV.setViewId(page);
        fctx.setViewRoot(UIV);

    }

Partially refresh any UIComponent, Set partial trigger programmatically-




import oracle.adf.view.rich.context.AdfFacesContext;

AdfFacesContext.getCurrentInstance().addPartialTarget(UIComponentBinding);



Wednesday 17 October 2012

Uncommitted/Unsaved Data Warning on page Navigation-Oracle ADF

When we visit some websites and try to close browser tab, it shows warning message like this image

Browser Confirmation Dialog when leaving page 
    To do this in Oracle ADF you have to do nothing complex, if you are using .jspx then it is so simple.

  1. Select af:document from page structure and go to property inspector, now Set UncommitedDataWarning to on.
    af:document tag in Oracle ADF

    UncommittedDataWarning property in ADF
     
    Now when you have uncommitted data in your page and you want to navigate yo other page or want to close same page it will show a message

    When Navigate to another page and page has Uncommitted Data-




    Warning Message when there is unsaved data on page
     
    When try to close tab and page has Uncommitted Data-

Tuesday 16 October 2012

ADF Basics: Show FacesMessage in Oracle ADF


How to use FacesMessage in ADF

FacesMessage is used to show confirmation, warning, information .In this tutorial, you will see that how to use FacesMessage to show any information, warning or any error. Suppose you want to show a confirmation when you save your records, here we use FacesMessage.

Managed Bean Code to use FacesMessage(Information)-



      FacesMessage Message = new FacesMessage("Record Saved Successfully!");   
      Message.setSeverity(FacesMessage.SEVERITY_INFO);   
      FacesContext fc = FacesContext.getCurrentInstance();   
      fc.addMessage(null, Message);   


To use for Error and Warning just change FacesMessage.SEVERITY_INFO to SEVERITY_ERROR or SEVERITY_WARN.
It will look like this



FacesMessage in Oracle ADF

You can change your Message accordingly