Thursday, 16 April 2015

useful tricks for ADF and services integration

Nowadays it's though to imagine an application that doesn't consume web services. In my previous post I've described how to add declarative validation on Data Control level. WebService Data Control have been the best example in my opinion. Now I would like to make a step forward about how to combine ADF and web services.

I believe that you have already watched ADF Architecture channel about services integration in ADF. Accodring to the architecture that Frank has described, you'll have web service proxy and kind of java facade. It helps to avoid UI changes caused by WSDL definition changes and gives a mean to cache the values. I assume that all of this is done. Let us explore POJO DC a little bit more.

The start point of this post is creation of transfer object and data access object: Person entity and PojoDataControlImpl class.


The second file is POJO DataControl implementation file. Having all this, please create the Data Control and a test page. Drag and drop persons collection as ADF Form and run it.




Let us focus on the first field which is age. Go to Bindings section and explore it. Right click on the collection in Data Control section. Click on Edit Definition.



What has happend? Framework creates XML file that corresponds with PersonEntity java class. Do you recognize the central part of JDeveloper? It is very similar to BC4J configuration wizard. And it allows to change it and use it in the same manner as BC4J entities. Please do some changes and run the page again.



The changes are applied to view layer by the framework. Nothing more to add. Need to iInternationalize your application? You've got model bundle file. Need to create new page? Just drag and drop attribute or collection and all of the validation, labels, read-only settings are applied.

Hope it is helpful :)

Wednesday, 25 February 2015

validating attributes in pagedef's variables iterator

In the classic ADF stack validations are propagated from the model (entity) up to the view (pages). It is easy. Harder task is when DataControl is based on other type of data source - web service, JMX or just POJO. I'll use Java class to describe how validation can be added in easy, declarative way. First of all setup of the application - implementation and Data Control:





The simplest possible Data Control is there. Now the sample web page:


Now drag and drop the method invocation as ADF Parameter Form, leave defaults:




If we consider a validation flow, it goes through page definitions. How to practically mix with that layer? Please go to the page definition and check what has been created. In variables iterator there is one new variable defined. Select it and go to Property Inspector.


My artificial business requirements specifies that field as mandatory, at most 8 chars and only letters. Above I've implemented two of them. How to handle third one here? Select the node in the Structure window and right click on it:



Fulfill the pattern and run the application. With "test" and "test2" options.



Wednesday, 7 January 2015

create ViewObject in runtime

Usually, during ADF development, you create view objects at the design time. Using java call it is possible to create them also in runtime. The code will describe itself, so don't waste time and:

ViewObject vo = getDBTransaction().getRootApplicationModule().createViewObjectFromQueryStmt("tempDynamicVo", "select 1 from dual");
System.out.println("fitst selected attribute from the first row is: "+ vo.first().getAttribute(0));


And that's it. The VO is there and can be accessed in different part of the code as those designed in common way.

ViewObject vo = findViewObject("tempDynamicVo");
System.out.println("fitst selected attribute from the first row is: "+ vo.first().getAttribute(0));


Because it's dynamic, it doesn't obscure the Data Control and other developer won't use it in their part of the design.

The view object name must be unique. Depends on your use case it may be consider as a best practice to clean it after data consumption. Just call:

vo.remove();

The use cases? There are, the simpliest one is an execution of stored function in the database:

select my_stored_funct(:myBindVar) from dual


Runtime VO approach sounds more BC4J than plain PreparedStatement calls. At least you've got an alternative way to implement it :)