Please disable your adblock and script blockers to view this page

Search this blog

Thursday 25 April 2013

Memory Scope For ADF Managed Beans-As per Fusion Developer guide

Scope of managed bean is a very important aspect while developing applications, so it is necessary to clearly understand memory scope of managed bean-
As per Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1)-

Application Scope-

The application scope lasts until the application stops. Values that you store in a managed bean with this scope are available to every session and every request that uses the application.
Avoid using this scope in a task flow because it persists beyond the life span of the task flow.

Session Scope-

The session scope begins when a user first accesses a page in the application and ends when the user's session times out due to inactivity, or when the application invalidates the session.
Use this scope only for information that is relevant to the whole session, such as user or context information. Avoid using it to pass values from one task flow to another. Instead, use parameters to pass values between task flows. Using parameters gives your task flow a clear contract with other task flows that call it or are called by it. Another reason to avoid use of session scope is because it may persist beyond the life span of the task flow.

Pageflow Scope-




Choose this scope if you want the managed bean to be accessible across the activities within a task flow. A managed bean that has a pageFlow scope shares state with pages from the task flow that access it. A managed bean that has a pageFlow scope exists for the life span of the task flow.If another task flow's page references the managed bean, the managed bean creates a separate instance of this object and adds it to the pageFlow scope of its task flow.

View Scope-

Use this scope for managed bean objects that are needed only within the current view activity and not across view activities. It defines scope for each view port that ADF Controller manages, for example, a root browser window or an ADF region.
The life span of this scope begins and ends when the current viewId of a view port changes. If you specify view, the application retains managed bean objects used on a page as long as the user continues to interact with the page. These objects are automatically released when the user leaves the page.

Request Scope-

Use request scope when the managed bean does not need to persist longer than the current request.

Backing Bean Scope-

A backing bean is a convention to describe a managed bean that stores accessors for UI components and event handling code on a JSF page. It exists for the duration of a request and should not be used to maintain state.
Use this scope if it is possible that your task flow appears in two ADF regions on the same JSF page and you want to isolate each instance of ADF region.

Tuesday 23 April 2013

ADFC-00024-oracle.adf.controller.ControllerException:: No ExternalContext could be found.

 ADFC-00024- No ExternalContext could be found.
this is the exception, i have faced while working on my new ADF application and due to this exception application crashed(Internal Server Error-500)
After lot of googling and searching on OTN, i found a solution for this exception- but really don't understand that how it works-
log of ADFC-00024 problem-



 oracle.adf.controller.ControllerException: ADFC-00024: No ExternalContext could be found.  
      at oracle.adfinternal.controller.util.JsfInterfaceImpl.getExternalContext(JsfInterfaceImpl.java:394)  
      at oracle.adfinternal.controller.util.JsfInterfaceImpl.getRequestMap(JsfInterfaceImpl.java:143)  
      at oracle.adfinternal.controller.state.AdfcContext.getCurrentInstance(AdfcContext.java:219)  
      at oracle.adfinternal.controller.ControllerContextImpl.getViewPortByClientId(ControllerContextImpl.java:121)  
      at oracle.adf.controller.internal.binding.DCTaskFlowBinding.getGuardingPermission(DCTaskFlowBinding.java:204)  
      at oracle.adf.model.binding.DCBindingContainer.getGuardingPermission(DCBindingContainer.java:3849)  
      at oracle.adf.model.binding.DCBindingContainer.internalIsViewable(DCBindingContainer.java:3855)  
      at oracle.adf.model.binding.DCBindingContainer.isViewable(DCBindingContainer.java:3826)  
      at oracle.adf.model.binding.DCBindingContainer.resetSuspendedExecutables(DCBindingContainer.java:3490)  
      at oracle.adf.model.binding.DCBindingContainer.resetSuspendedExecutables(DCBindingContainer.java:3492)  
      at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3365)  
      at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2911)  
      at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(PageLifecycleImpl.java:115)  
      at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:149)  
      at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:197)  
      at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$400(ADFPhaseListener.java:23)  
      at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(ADFPhaseListener.java:238)  
      at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:274)  
      at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:75)  
      at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)  
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:439)  
      at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:204)  
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)  
      at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)  
      at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)  
      at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)  
      at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:122)  
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)  
      at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)  
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)  
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)  
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)  
      at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:180)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)  
      at java.security.AccessController.doPrivileged(Native Method)  
      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)  
      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)  
      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)  
      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)  
      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)  
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)  
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)  
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)  
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)  
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)  
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)  
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)  
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)  
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)  
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)  

In my case this was due to Application Module configuration, in adf application we have two configuration .
  1. AMLocal
  2. AMShared
For local configuration ,in Pooling and Scalability there is Maximum Pool Size is 4096 but for shared it is only 1
i am not getting why this is so, then i have set Maximum Pool Size for shared configuration to 4096 and it is working-

Saturday 20 April 2013

Currency Conversion - Google Calculator API integration in ADF using GSON

First ,thanks to this post http://blog.caplin.com/2011/01/06/simple-currency-conversion-using-google-calculator-and-java/ .
I was looking for any API, webservice for retrieving live currency fluctuation, finally i came to this solution that integrates Google Calculator with Java to calculate currenct currency rates and i have integrated this with my Oracle ADF Application

I have created an application using bounded taskflow -
  • Created a .jsff page with two input text , to get value of Base and Term currency and a button, on which rate is calculated

  •  In order to use Goolge Calculator, we have to use GSON (open source java library (API) to convert JSON objects in POJO (pure java object)) 
  • To access GSON library we have to add google-gson-stream-2.2.1.jar in our project library - Download Gson Jar
  • this trick uses google calculator for calculating converion rate, as we all know Google Calculator is very smart, whenever we search like 1 USD ,it always shows results according to locale
As 1 USD searched in India-
As 1 USD searched in UK- 






  • this is also hidden benefit for our application , we can pass locale to get changed values also- now see what is the code that get values from Google Calculator

  •    public void calculateFluctuationButton(ActionEvent actionEvent) throws Exception {  
         String google = "http://www.google.com/ig/calculator?en=hi&q=";  
         /**Get values from page component binding*/  
         String baseCurrency = baseCurrencyBind.getValue().toString();  
         String termCurrency = termCurrencyBind.getValue().toString();  
         String charset = "UTF-8";  
         /**Replace url using your values-*/  
         URL url = new URL(google + baseCurrency + "%3D%3F" + termCurrency);  
         /**Go to url directly to see you result*/  
         System.out.println(url);  
         Reader reader = new InputStreamReader(url.openStream(), charset);  
         Result result = new Gson().fromJson(reader, Result.class);  
         System.out.println(result);  
         // Get the value without the term currency.  
         String amount = result.getRhs().split("\\s+")[0];  
         System.out.println(amount);  
         resultBind.setValue(amount);  
       }  
    

  • See in code i have passed currency notation from page (INR,USD ) to bean and passed it in url of google calculator and this url returns results
Download Complete Application -Sample ADF Application