Tuesday, May 19, 2015

Read a parameter from URL ADF

HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
System.err.println("GET :" + request.getParameter("name"));
In the taskflow add a method to get the parameter from URL
init method and jsff in the taskflow; add the taskflow to the jspx page
init method is the initiator for the taskflow which gets the parameter from the URL 
Example to pass parameter to  URL: http://vijaysadhu.blogspot.com/search?q=url
http://host:7001/App/faces/home.jspx?name=vijay
set the value to a scope variable to use it in the app;
Another Approach:
        String currencyCode =
            FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("currencyCode") ==
            null ? "0" :
            FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("currencyCode");
        
String reportType =
            FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("reportType") == null ?
            "0" : FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("reportType");
       
        System.out.println("currencyCode - " + currencyCode + " - company - " + company + " - reportType - " +
                           reportType );
Example: http://127.0.0.1/App/faces/demo.jspx?currencyCode=USD&reportType=Q3







No comments: