Wednesday, May 25, 2011

ADF BC : Create Method in Application Module and Exposing to Managed Bean

 

If you application need to perform some business operation with multiple entity and view object then best place to put your method Is application module implementation class. I will explain you here just how to use application module method from managed bean.

Create simple ADF Fusion project and double click application module and generate Impl class by going to java tab.

image

Then open impl.java class and write you own java method.

image

How to call this java method from button , hyperlink or even manage bean.

We need to expose this method before calling it.

I opened the client interface and shuttled that method to application module. Now this method will be visible in data control along with viewobjects that are exposed.

So it is as simple as this. This way you can write multiple method for various business operation like PaySalary , IncreaseSalary and more.

image

You can also see that there are other client.java file created to managed this.

Command Button calling this method

I created JSF page with one managed bean in back bean scope , you can also create backing bean.

image

If you refresh the datacontrol window then you will see that method as below.

image

Now just drag and drop this method on JSF page as button or hyperlink and run the page.

If you click the button you will see that sop statement is called and it is printing the message.

image

Calling method from managed bean

Drag and Drop command button on page and double click it and create a method in managed bean.

write following code and run the application and you will see the same printed message as before.

The advantage of calling from managed bean is ,if you have any GUI logic here that will decide which method to call then it is right place.

Eg:- do I need to call salary decrease or salary increase.

image

5 comments:

  1. This is very valuable information to me. Thanks for publishing.


    Nagaraju

    ReplyDelete
  2. thanks...helpful... publish more on data bindings too

    ReplyDelete
  3. Getting NPE after invoking method in AM :(

    ReplyDelete
  4. thanks ..very useful info for beginners

    ReplyDelete