Pages

Wednesday, June 8, 2011

Using the EJB or Java Datacontrol in ADF Rich Faces

In my previous blogspot I showed you the new JDeveloper 11gR2 EJB and ADF DataControl features and in this blogpost I will use this EJB or Java DataControl in a JSF page.

I made a simple EJB model project which uses the dept and emp tables of the Scott schema. This project also contains with a Session Bean on which I generated an ADF DataControl.

When you open the DataControls.dcx in your model project and select one of your DataControl entries you can click on the edit button. This will open and generate an ADF entity xml in which you can change some properties.
We will add a new Named Criteria in which you can search on a particular location of the department. This criteria can be used in a Query Panel.


The criteria dialog, where I add the location attribute of the dept entity and compare it with a bind variable.


When we switch to the ViewController project, you will see this criteria in the DataControl Window.

Drag All Queriable Attributes on the JSF Page and choose for ADF Query Panel with Table.

You can run this page and in the top right Combobox you can select your criteria,  next the bind variable will be shown on the query panel.
The saving of your own custom queries in the MDS store is not working (yet) with this DataControl. You will get a viewobject error. And I can't define a list of values on an attribute, so no nice combobox in the query panel.

The second part of this blogpost will show you, how you can change a department of a employee.  Here you can see that the employee entity has the department entity as attribute( no dept_id attribute).
Drag the empFindAll operation on the page and choose for ADF Form

You can see that there is no combobox option for the department entity but you can include its attributes.

On runtime it will look like this.
I removed the entity attributes of  Dept and drag the dept attribute from the DataControl on the Form and choose for ADF Select One Choice.


The Base Data Source is the dept entity inside the Employee entity and add a new other department operation as List Data Source


Add the data mapping and display some department attributes.


This time a combobox is displayed and you can change the department on the employee
That's all for now.

9 comments:

  1. Very clear description. Well done. Seems that ADF Data Binding is finally living up to its promise - with more Data Controls equal than others, rather than just ADF BC.

    Lucas

    ReplyDelete
  2. Thanks,

    another great feature is the Transactional Data Control for the business services built using JPAs described by jobinesh

    no need for an EJB SessionBean and you get a commit operation

    http://jobinesh.blogspot.com/2011/06/declarative-transaction-support-for.html

    ReplyDelete
  3. Hi Edwin, its very clear,I'm also trying with this class and I'm also able to publish the event.I have one query,In this same class I take a simple method instead of main method and make the class as web service,and call this java web service into the BPEL,but in this case java web service in not publishing the event,can you please any suggestions regarding this issue.

    Regards
    subbu

    ReplyDelete
  4. Hi,

    can you make a easy testcase that is much easier to see what is wrong. the email is on the about page.

    thanks

    ReplyDelete
  5. Hi Edwin,very good article it's so helpful us.I have a query for the edn publishing labraries are added in SOA like JRE1.5.JRF API,OracleXmlParseV2 and weblogic Remote,I trie this in SOA I got the response,I want to publish the event with same class form Eclipse but I don'n now what libraries are to be added.In eclipse i have no option to add libraries as you mention in SOA,plz help me it's very urgent,Thanks in advance.

    ReplyDelete
  6. Hi Edwin,very good article it's so helpful us.Java Server Pages is a technology which permits software developers to create dynamic request like HTML, XML in order to answer to client request in the net. This technology lets Java code and definite pre-defined procedures to be implanted into static content.

    ReplyDelete
  7. I want to cry, it took me 3 hours...
    Thank you very much

    ReplyDelete
  8. Hi Edwin,

    I was trying to do the same but I have a problem when create a new record, the fields are displayed as read-only !

    any idea.
    regards

    ReplyDelete
    Replies
    1. Hi,

      Strange are you using inputtext or outputtext? is there some readlony option on the jsf component.

      Thanks

      Delete