Call Application Module method(Function) from maanged bean

Hi Experts,
JDEV 11.1.2
I created method in application module which access two parameters and returns a string value, then binded in pagedefinition file as method action.
Now i wisht to call from a managed bean by passing two parameters , give me a sample code of it..
Thankz in advance
PMS
Edited by: pms on Feb 18, 2012 11:56 AM

am code
public void checkLoginCredentials(String ename,String pwd_form)
System.out.println(ename + " " + pwd_form);
EmpLoginViewObjImpl vo = (EmpLoginViewObjImpl)getEmpLoginViewObj1();
//set the bind variable value to last name
vo.setNamedWhereClauseParam("LastName",pwd_form);
vo.executeQuery();
int rowCount=vo.getEstimatedRangePageCount();
System.out.println("rowCount="+rowCount);
if(rowCount==0) {
throw new JboException("Password doesn't match");
bean code
public String commandButton_action() ()
String returnStr="error";
System.out.println("Inside loginBtn_action");
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("checkLoginCredentails");
Object result = operationBinding.execute();
System.out.println(result);
if (operationBinding.getErrors().isEmpty()) {
returnStr= "success";
System.out.println("returnStr= " + returnStr);
return returnStr;
}

Similar Messages

  • Best practice for calling application module methods and plsql code

    In my application I am experiencing problems with connection pooling, I seem to be using a lot of connections in my application when only a few users are using the system. As part of our application we need to call database procedures for business logic.
    Our backing beans, call methods on the application module which in turn call a database procedure. For instance in the backing bean we have code like this to call the application module method.
    // Calling Module to generate new examination/test.
    CIGAppModuleImpl appMod = (CIGAppModuleImpl)Configuration.createRootApplicationModule("ky.gov.exam.model.CIGAppModule", "CIGAppModuleLocal");
    String testId = appMod.createTest( userId, examId, centerId).toString();
    AdfFacesContext.getCurrentInstance().getPageFlowScope().put("tid",testId);
    // Close the call
    System.out.println("Calling releaseRootApplicationModule remove");
    Configuration.releaseRootApplicationModule(appMod, true);
    System.out.println("Completed releaseRootApplicationModule remove");
    return returnResult;
    In the application module method we have the following code.
    System.out.println("CIGAppModuleImpl: Call the database and use the value from the iterator");
    CallableStatement cs = null;
    try{
    cs = getDBTransaction().createCallableStatement("begin ? := macilap.user_admin.new_test_init(?,?,?); end;", 0);
    cs.registerOutParameter(1, Types.NUMERIC);
    cs.setString(2, p_userId);
    cs.setString(3, p_examId);
    cs.setString(4, p_centerId);
    cs.executeUpdate();
    returnResult=cs.getInt(1);
    System.out.println("CIGAppModuleImpl.createTest: Return Result is " + returnResult);
    }catch (SQLException se){
    throw new JboException(se);
    finally {
    if (cs != null) {
    try {
    cs.close();
    catch (SQLException s) {
    throw new JboException(s);
    I have read in one of Steve Muench presentations (Oracle Fusion Applications Team' Best Practises) that calling the createRootApplicationModule method is a bad idea, and to call the method via the binding interface.
    I am assuming calling the createRootApplicationModule uses much more resources and database connections that calling the method through the binding interface such as
    BindingContainer bindings = getBindings();
    OperationBinding ob = bindings.getOperationBinding("customMethod");
    Object result = ob.execute()
    Is this the case? Also is using getDBTransaction().createCallableStatement the best way of calling database procedures. Would it be better to expose plsql packages as webservices and then call them from the applicationModule. Is this more efficient?
    Regards
    Orlando

    Thanks Shay, this is now working.
    I successfully got the binding to the application method in the pagedef.
    I used the following code in my backing bean.
    package view.backing;
    import oracle.binding.BindingContainer;
    import oracle.binding.OperationBinding;
    public class Testdatabase {
    private DCBindingContainer bindingContainer;
    public void setBindingContainer (DCBindingContainer bc) {this.bindingContainer = bc;}
    public DCBindingContainer getBindingContainer() {return bindingContainer;}
    public static String validateUser()
    // Calling Module to validate user and return user role details.
    System.out.println("Getting Binding Container from Home Backing Bean");
    BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
    System.out.println("Obtain binding");
    OperationBinding operationBinding = bindings.getOperationBinding("calldatabase");
    System.out.println("Set username parameter");
    operationBinding.getParamsMap().put("p_userId",userId);
    System.out.println("Set password parameter");
    operationBinding.getParamsMap().put("p_testId",examId);
    Object result = operationBinding.execute();
    System.out.println("Obtain result");
    String userRole = result.toString();
    System.out.println("Result is "+userRole);
    }

  • Manage bean methods not able to call application module methods

    Hi,
    I have an ADF application where in my managed bean method needs to call AppModuleImpl methods. I use the code as below:
    public void getSummary() {
    DCBindingContainer binding = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    OperationBinding op = binding.getOperationBinding("getVOData");
    op.execute();
    The code works fine when I run the application in my IntegratedWeblogicServer and I am able to get the data on my .jsp pages.
    I have installed weblogic server on another machine and I need to deploy and run my application on that server. But when I try doing that, the above code is not able to call the AppModule method and I see no data on my page (Also there is no error or exceptin thrown). Seems that the ViewController project is not able to interact with the Model project.
    Is there any extra configuration to be done on the newly installed weblogic server to get this work? Or will some change in the application code help?
    Please suggest.
    Thanks and regards,
    Ansh

    Hi,
    While creating the weblogic domain, we had the following checkboxes checked:
    1. Basic weblogic server domain [wlserver_10.3]
    2. Oracle JRF [oracle_common]
    I hope this is what we need.
    Yes, I also have the adf runtime installed.

  • Execute application module method automatically from uix page

    Hi,
    We are developping an application using Jheadstart 10.1.2.2 (build 32) with UIX pages as a view.
    We have build a custom method on our application module class that creates and saves in a directory a chart in function of a parameter we pass to this method.
    We would like to execute this method every time we acces a form page since this pages has to show the chart that our method creates. We would like to know if it is possible to execute this method automatically every time we acces this form page without having to press a button each time.
    Thanks in advanced.
    Xavier

    Xavier,
    I am not sure UIX works as JSPX and JHS 10.1.2 as 10.1.3, but that is what I would do if I wanted to execute a method on page load:
    1. Create a new managed bean(MyBean) in your faces-config which implements oracle.adf.controller.v2.PagePhaseListener interface
    2. Go to the pagedef file of your page, right click it in structure pane and set the controller class to 'MyBean'
    3. in MyBean and in beforePhase() method access App Module and call your function [see 4]. I quote this from ADF Dev.Guide 10.1.3 for how you can get App Module and call your function on it:
    // 1. Access the FacesContext
    FacesContext fc = FacesContext.getCurrentInstance();
    // 2. Create value binding for the #{data} EL expression
    ValueBinding vb = fc.getApplication().createValueBinding("#{data}");
    // 3. Evaluate the value binding, casting the result to BindingContext
    BindingContext bc = (BindingContext)vb.getValue(fc);
    // 4. Find the data control by name from the binding context
    DCDataControl dc = bc.findDataControl("SRServiceDataControl");
    // 5. Access the application module data provider
    ApplicationModule am = (ApplicationModule)dc.getDataProvider();
    // 6. Cast the ApplicationModule to its client interface
    SRService service = (SRService)am;
    // 7. Call a method on the client interface
    service.doSomethingInteresting();
    4. Check the phase and call your function in beforePhase method of your MyBean (implementing PagePhaseListener)
    public void beforePhase(PagePhaseEvent event) {
    FacesPageLifecycleContext ctx =(FacesPageLifecycleContext)event.getLifecycleContext();
    if (event.getPhaseId() == MY_DESIRED_PHASE) service.doSomethingInteresting();
    Probably, there is a shortcut to all these, or an alternative approach, which I myself will be happy to know about.

  • How do I call an Application Module method from a EntityImpl class?

    Guys and Gals,
    Using Studio Edition Version 11.1.1.3.0.
    I've got a price update form, that when submitted, takes the part numbers and prices in the form and updates the corresponding Parts' price in the Parts table. Anytime this Parts view object's ReplacementPrice attribute is changed, an application module method needs to be called which updates a whole slew of related view objects. I know you can modify view objects via associations (How do I call an Application Module method from a ViewObjectImpl class? but that's not what I'm trying to do. These AppModuleImpl methods are the hub for all price updates, as many different operations may affect related pricing (base price lists, price buckets, etc) and hence, call the updatePartPricing(key) method.
    For some reason, the below code does not call / run / activate the application module's method. The AppModuleDataControl exists and recordPartHistory(key) is registered and public. At runtime, the am.<method> code is simply ignored, and as a weird side-effect, I cannot navigate out of my current page flow.
      public void setReplacementPrice(Number value)
        setAttributeInternal(REPLACEMENTPRICE, value);
        AppModuleImpl am = (AppModuleImpl)this.getDBTransaction().findApplicationModule("AppModuleDataControl");
        Key key = new Key(new Object[]
            { getPartNumber() });
        am.recordPartHistory(key);  // AppModuleImpl method which records pricing history
        am.updatePartPricing(key); // AppModuleImpl method which updates a whole slew of related pricing tables
      }Any ideas?

    Thanks Timo.
    Turns out the code provided was correct, but the AppModuleImpl method being called was not. A dependent ViewObject wasn't returning the row I was expecting. I then tried to perform some operations on that row, which in turn ... just stopped everything, but didn't give me an error.
    It was the lack of the error that threw me off. I had never messed with calling an AppModuleImpl method from the EntityImpl so I assumed that's what was messing up.
    You are correct. It is available from the ViewRow, but I thought it better to put it in the EntityImpl. This method will be called every time the replacement cost is modified. If I didn't put it in the EntityImpl, I'd have to remember to call it every time a replacement cost changed.

  • Calling function from Backing Bean or JSP page

    We are on Jdeveloper 10.1.3.3.0, ADF Faces, JSF Faces .., Currently there is a function call from Javascript event (onmouseover) in the JSP page. I want to call this function from a backing bean or JSP page, as I have to pass some values to this function.
    For Ex., I have a function call like return submit('A','B','Test'); on the Javascript event (onmouseover) in jsp page. I want to remove this function from the javascript event and call from backing bean or jsp page to pass some values into the submit() function. I appreciate if anyone can give some example of how to call this function from backing bean or jsp page in the <SCRIPT> or <SCRIPTLET>
    Thanks,
    Ram

    A use case would be helpful so that we can get a better idea of what you want to do.
    As a general rule, there is no way to call a client side Javascript function from a backing bean, which is server side. However, there are ways to inject information from a backing bean into your Javascript call. For instance, I have an application that uses Google Maps API. It has an onload call to a Javascript function that builds the map and designates it's center point. The center point comes from a backing bean as latitude and longitude properties. So here is my body tag:
    <afh:body onload="initialize(#{backing_searchResults.latitude},#{backing_searchResults.longitude},#{searchCriteria.distance})"
              onunload="GUnload()">onload calls the Javascript function called initialize, and passes the latitude, longitude, and distance from the bean. Is the function really being called from my backing bean? No - the parameters are hard coded into the onload event code when the page is rendered. Does it do the job? Sure it does.

  • ADF Question: call javascript function from backing bean?

    Hi all,
    I am running JDeveloper 10.1.3.3 with ADF BC.
    Heres my situation:
    I have a table, and after inserting a new row, then committing, I want to call a javascript function. I tried using the onkeyup javascript to force a click of the save button, and then call my function after that. However, I really only want the second function to be called AFTER the commit has occurred.
    I have tried putting a setTimeout on the second function, but this never executes then. Is there some way that I can call the second javascript function from the backing bean? Is there a better workaround for this? Here is some code:
            function submitCreate(e) {
                var _event = (window.event) ? event : e;
                var KeyID = _event.keyCode;
                switch (KeyID)
                    case 13:
                        document.getElementById("form1:tvoTable:commitButton").onclick();
                        doAjax();
                        break;
            function doAjax() {
                var item = document.getElementById("form1:inputText3").innerHTML;
                getAjax(item, "FULL");
            }Thanks,
    Heather

    Maybe try adding an af:script block in your jsp as a partial target in your backing bean when you commit to the database? We are doing something similar when we get a tab DisclosureEvent but the principle should be the same.
    In our jsp we have:
    <af:script id="scriptID" text="alert('javascript here');"/>
    In the backing bean we have:
    method(DisclosureEvent de) {
    // get a component somehow or the component, we get it from the disclosure event
    // but you could use a binding also. if you don't have the exact script element you need
    // to find it like we do below.
    UIComponent c = de.getComponent();
    // Find our real script component
    UIComponent target = c.findComponent(":scriptID");
    // get the adf context
    AdfFacesContext adfContext = AdfFacesContext.getCurrentInstance();
    // add the script as a partial target.
    if(target != null) {
    adfContext.addPartialTarget(target);
    This relies on PPR though, which you may not be doing. If you are navigating to a new page you could set an indication in a backing bean and then access that in an <af:script> block in the new page or even generate the Javascript you want depending on your logic and access all of it via an EL binding on the af:script tag:
    <af:script id="scriptID" text="#{bbean.generatedScript}"/>
    Hope this helps!
    Steve

  • Problem in calling application module's custom functions

    i m facing problem in calling application module's custom functions in jsp pages.
    i'll highly appreciate any reply to this mail.
    anant

    Hi,
    I also need to know how to call custom methods
    within an application module implementation.
    I have tried the <jbo:ApplicationModule id=am ...\>
    then later in the JSP <% am.customMethod() %>
    and this does not work. Any hints?I don't know how it works with JSPs, but if you want to call a custom method on a ApplicationModule, you first have to cast it to your custom class type.
    Somethin like this:
    MyAppModule am = (MyAppModule) sessionCookie.useApplicationModule( ... )
    or maybe in your JSP
    <jbo:ApplicationModule id="am">
    <% MyAppModuleClass am = (MyAppModuleClass) am; %>
    I think you forgot to do something like this in your JSP. Note that the code is not tested.
    Hope that helps
    Benjamin

  • How to invoke Application Module method from entity object methods

    Hi,
    We have an existing Application Module which provides some validation logic. We are using OperatingBinding or getting the Application Module instance from the bindings and then invoking the app module methods in the view controller project.
    But in our current scenario, We need to invoke the application module method from the setAttribute method in the entity object when ever an entity attribute value is changed . I believe we can call createRootApplicationModule method to create application module instance. But this may lead to performance overhead.
    Can you please suggest, if there is any alternative to invoke the application module method inside the business components.
    What is the best way to create

    We have a pricing service, which was developed as a separate application. We need to invoke the pricing service with the change in certain attributes of the entity object and update some of the attributes of the current entity object. At present we are handling these calls to the pricing service in the ui layer in the valueChangeListener.
    But we would like to move this service call into setAttribute method as we are unable to prevent the call to the service if the model validations fail. I am looking for the best possible approach for invoking the service calls from the entity objects.
    Thanks and Regards,
    S R Prasad

  • How to call a Javascript function from backing bean without any event

    Hi,
    Someone knows how to call a Javascript function from backing bean without any event ?
    thanks

    Please review the following thread:
    ADF Faces call javascript
    Luis.

  • Calling a pure C function from JNI method

    Is it posible to call a pure C function from a JNI method.?
    I am communicating with an external device whose API is written in C language.
    Would it work this way
    If I declare empty native methods in Java and those methods in C call pure C methods?
    Thank You...

    Hello,
    I have a similar problem and I posted it here http://www.velocityreviews.com/forums/t724826-jni-calling-an-outside-function-in-the-c-file-which-is-being-called-by-the-java-file.html. If you can answer the question, it would greatly help me.
    Thanks
    Nick

  • Without calling stored procedure or functions from database

    Hi,
    I am using Jdeveloper 11.1.1.5.0.
    =>How to do PL/SQL procedures and functions in ADF without calling stored procedure or function from DB?

    S, PL/SQL procedures and functions are done in Application Module class or in managed bean..By calling the stored procedures or functions from DB.
    But I am asking how to do if DB doesn't have any procedures,triggers and functions.

  • Is it possible to call the Print Quote functionality from Custom ADF page

    Hi,
    We are researching if it is possible to call the Print Quote functionality from the Custom ADF application.
    Goal is to pop up the PDF report upon clicking the Print Quote button on the custom page. Is it possible ?
    Atleast advice on the direction to go forward is appreciated.
    Thanks
    Sai

    Hi ,
    Please check following thread on forum -
    Re: ADF: Calling OAF Page from ADF page
    Check this may also be useful-
    https://blogs.oracle.com/shay/entry/to_adf_or_oaf_or
    I have not tried yet but Steven Chan (Sr. Director OATG) suggest following methodolgy for this-
    https://blogs.oracle.com/stevenChan/entry/appsdatasource_jaas_ebs
    Thanks,
    Ashish

  • Calling an external C function from a C file in JNI

    Hello,
    I am trying to call an external C function, from a C file which is being called by a Java file. I am getting an unresolved symbol error. I have tried many things like, making the external C function in the format of JNI, etc, etc. It is still not working. I think it has something to do with linking the two C files. If anyone can please answer this, it would greatly help me. here is the code:
    HelloWorld.c:
    #include <jni.h>
    #include <stdio.h>
    #include "MyOldHello.h"
    #include "HelloWorld.h"
    JNIEXPORT void JNICALL
    Java_HelloWorld_print(JNIEnv *env, jobject obj)
         helloPrint();
         return;
    HelloWorld.java:
    class HelloWorld
         private native void print();
         public static void main(String[] args)
              new HelloWorld().print();
         static
              System.loadLibrary("HelloWorld");
              System.loadLibrary("MyOldHello");
    MyOldHello.c:
    #include <jni.h>
    #include <stdio.h>
    #include "MyOldHello.h"
    void helloPrint()
         printf("\nHello World!\n");
    MyOldHello.h:
    void helloPrint();
    Now i use the Visual C++ command prompt to compile this by saying:
    javac HelloWorld.java
    javah -jni HelloWorld
    cl -Ic:\Java\jdk1.6.0_20\include -Ic:\Java\jdk1.6.0_20\include\win32 -MD -LD HelloWorld.c -FeHelloWorld.dll
    and now it gives me the error saying that there is an unresolved external symbol, which is the call to helloPrint in the file HelloWorld.
    If anyone knows how to solve this, or how to call external C functions from a C file that is being called from a Java file using JNI, please respond.
    Thanks
    Nick

    Hi,
    In your post on velocity review, you did not compile MyOldHello.c. You compiled a C file that included the header file for it and called a method defined in the header. The linker is never going to be able to find the code for this if you do not include the object file for this.
    Try this. You will also have to add in any JNI libraries you need to link against but I am sure you could work that out.
    cl /c MyOldHello.c
    cl /c -Ic:\Java\jdk1.6.0_20\include -Ic:\Java\jdk1.6.0_20\include\win32 -MD HelloWorld.c
    cl /LD MyOldHello.obj HelloWorld.obj /FeHelloWorld.dll
    [http://msdn.microsoft.com/en-us/library/f35ctcxw(VS.80).aspx]
    Cheers,
    Shane

  • Calling a PL/SQL function from java

    I would like to call a pl/sql function from java. My pl/sql function is taking arrays of records as parameters. How do i proceed? Which specific oracle packages do I have to import?
    Please send an example.
    TIA,
    Darko Guberina

    Documentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
    says JPublisher can publish records too.
    But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
    PACKAGE "COMPANY" AS
    type emp_rec is record (empno number, ename varchar2(10));
    type emp_list is varray(5) of emp_rec;
    type factory is record (
    name varchar(10),
    emps emp_list
    function get_factory(p_name varchar) return factory;
    END;
    then I see <unknown type or type not found> at sql or java files generated. Any ideas?

Maybe you are looking for

  • Populating the date field

    Hi All,  I am trying to populate the "datefield" (cv58) when the "validated" field (cv55) is set to a specific string from the dropdown menu. I have used the following code in the change event of (cv55).    if (form1.P1.client.variable_option_client.

  • Music played in itunes skips

    When I try to play music in Itunes the music skips and then picks up and skips again at about 1/2 second intervals. I think I need to deinstall Itunes and then reinstall but will this delete my library?

  • Search query not able to find node under a specific site structure (eg. 2013/05)?

    Hi,     We are saving our data on a node under year/month site structure, eg. (2013/05/node1) but when we search for the data using a query in a custom workflow., it does not fetch any results.The query being fired is something like :    SELECT * FRO

  • Smart Form, Data Element and Parameters

    1.- I created an Smart Form with an import parameter. The import's parameter type is a data element. 2.- I create an executable to call the Smart Form, I need to declare a parameter of the type of the same data element. The problem is that when I try

  • Data Source and Data Store

    Are both Data Source and Data Store the same in BI? If not can someone explain what each one of these terms mean. Thanks for the help