5 Replies Latest reply on Mar 12, 2013 2:19 PM by Mailsubhra-Oracle

    ADFUtils and AM

      I have a small query here. Say I have an AM VolumeAM which has a method Boolean callCore(String s) which is exposed as a client.
      Now if we want to call this function from a backing bean, then we need to bind this method to the pagedef of the respective jsff page. However, I do not want to bind the function to the pagedef
      The class ADFUtils has a functin getApplicationModuleForDataControl(String) which can give me a oracle.jbo.ApplicationModule object if we call it the following way:
      ApplicationModule volAM = ADFUtils.getApplicationModuleForDataControl("VolumeAMDataControl");
      Unfortunately volAM is of type ApplicationModule and not of type VolumeAMImpl.
      Hence I cannot cast VolumeAMImpl volumeAMImpl = (VolumeAMImpl)volAM;

      But I still want to call the method Boolean callCore(String s) which is in VolumeAMImpl.java
      Is there a way using which we can do this without having to bind callCore() to the pagedef?
        • 1. Re: ADFUtils and AM
          Yes you can.
          SugarCRMappModule service = null;
          service = (SugarCRMappModule)Configuration.createRootApplicationModule("com.sample.model.services.SugarCRMappModule","SugarCRMappModuleLocal");
          Configuration.releaseRootApplicationModule(service, false);
          But this not considered best practice.
          • 2. Re: ADFUtils and AM
            Abhijit Dutta

            you can call findDataControl(String) on the BindingContext and access the application module to invoke a method exposed on the Application Module

            read this http://electrotek.wordpress.com/2008/01/23/how-to-get-an-applicationmodule-in-backing-bean/

            read this best practice doc while invoking service layer methods from managed beans


            Edited by: Abhijit Dutta on Mar 4, 2013 6:18 PM
            • 3. Re: ADFUtils and AM
              Both these posts are really good. But both of them require the model jar to be present in the ui.
              However I do not want that.
              I want to call AMImpl method in bean, but without importing the AMImpl in the bean.
              Please tell me if that will be possible.
              • 4. Re: ADFUtils and AM
                Timo Hahn
                The way to go is definitely to bind the method to the pagedef and use the operation binding to call the method.
                It's not a best practice to get the application module in a bean, do some work on the application module, as the binding layer doesn't know about it and will not reflect the changes.
                If you realy want to use the am method directly you have to cast the application module to your impl class as you don't have access to the method otherwise.
                If you don't want to create an operation binding in the pagedef and don't want to cast the am then you are bust.

                • 5. Re: ADFUtils and AM
                  Thanks a lot Timo. Now I know why this is not recommended. This needs model project to be imported to ui project which will violate the separation of Model and UI code.