Sunday, September 8, 2013

Page Definition Variables to Store Temporary Page Values

Back to the basics. In most of the cases data is coming from Model layer, from ADF BC or EJB. When user is changing data on the screen, frameworks takes care and preserves temporary data. However, what about such screens where we have temporary fields, without any relation with the Model layer - transient data fields. What if there is no corresponding Model implementation, and still we need to store field data between requests - where should we store it? I believer, one of the best techniques is to use Page Definition variables, this is old approach back from ADF 10g times - but it still works very well. Main advantage - we are able to store transient temporary data between requests and there is no need to define session scope bean.

It happened to see scary things - developers are defining managed beans in Page Flow Scope, just because they want to make sure temporary UI values are preserved between requests :)

This sample implements two input components - inputText and inputNumberSlider. Both components are enabled with autoSubmit, as well as value change listener is defined for both. Once value is changed for one of the components, we recalculate total sum of both fields and display as total:


Both input components exist only in UI, there is no Model layer representation - user types values, total is recalculated immediately. However, we still need to store entered values, otherwise once we select number slider - partial request will be invoked and value entered for income will be lost. ADF developer would try to store input value inside Backing Bean:

It would be wrong to store temporary value inside Backing Bean - this bean lifetime is as long as request, in other words - once we will enter second input value, first will be always lost. You may think to define Session or even Page Flow Scope bean - that would make it work, but why to waste server memory - only if you want to make your ADF applications slow.

We can use Page Definition variables to store temporary values, these values will be preserved between requests. Open Page Definition, associated with the page, expand executables and select to insert new variable:

Give a name and specify a type for new variable:

In my example, I will define all three variables in the same way - for each of the fields:


 Once variables are defined, we are not done yet with Page Definition. For every defined variable we need to define corresponding attribute (will be accessed from the page). Insert new item under bindings - Attribute Value:



When creating new Attribute Value, make sure to select variables as Data Source and map related variable (defined one step above) name:


Once all done, we should have following picture - each variable is assigned with attribute value:


Go back to UI now, input component should have its value property mapped with attribute value (not with variable directly, because data will not be stored/retrieved) from Page Definition. For example: bindings.incomeVarAttr.inputValue:


Once again - UI component value you should map with attribute value, not with variable directly:


Finally, you may ask question - how to access attribute values defined in Page Definition programmatically? Easy - use ADFUtils wrapper class. There are two methods available for your convenience - getBoundAttributeValue("name") and setBoundAttributeValue("name", value):

Its how it looks on UI:




This is HA compatible, In cluster this will work fine.

Thursday, September 5, 2013

ADF Mobile Links

Sequence number generation in EO

 To generate Primary key sequence generation in EO , Best practice is generate Data Manipulation Methods and in that we have to check condition if DML_INSERT?

 If we call createInsert in Updataable VO and while commit time it will call doDML() method,



 While insertion time if you want Primary key generation then we need to keep condition
if(operration==this.DML_INSERT)
and we have to set sequence number to primary key column (EmployeeId).

Tuesday, September 3, 2013

Accepting input from JDeveloper Console

Run--> Choose Active run Configuration --> manage configuration -->Edit Default configuration -->
Tool settings --> Additional Runner Options --> Select "Allow Program Input"


Monday, September 2, 2013

ADF Samples

Disabling connection for Non DB projects


In bc4j.xml file under AppModuleConfig tag we have to put
 <Custom RequiresConnection="false"/>  tag.
So that when ever we creates AM or VO Jdeveloper will not ask connection, And while running also it will not give error like "java:comp/env/jdbc/hrDS" or Connection1 not available errors.

ADF Mobile Documentation

Auto calling and e-Mailing in ADF Mobile App

In ADF mobile if you want to implement email functionality ,you have to use below code.
With this code when you click on this link ,this will automatically will ask you to send with which email domain you want to send.
<amx:goLink url="mailto:sreedhar.reddy@3disystems.com"></amx:goLink>

You Can keep Subject , CC , BCC and Body also configurable.

<tr:goLink styleClass="messageText"
text="#{sessionScope.empDetails.Email}"
destination="mailto:#{sessionScope.empDetails.Email}?subject=howdy&cc=myboss@oracl
e.com&bcc=me@oracle.com&body=howdy partner!"/>

If you want to auto calling functionality in ADF mobile ,use below code.
<tr:goLink text="3256897589" destination="tel:3256897589/>

Revert Shared library name in weblogic server