Posts

Showing posts from August, 2010

<af:progressIndicator> example

A simple demo application that uses <af:progressIndicator> is attached here . Please refer the tag documentation to learn more about <af:progressIndicator> component. [Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

A composite ViewObject based on multiple data sources

Sometimes you may need to display data from different data sources on a single row. Say for example, part of the row from database and a couple of attributes from a third party data source. ADF BC let you to customize the ViewObject to compose data from different sources by overriding a couple of 'life cycle' methods. Below given sample code illustrates the same. Here, you can see that EmployeesViewObject tries to get value for 'LocationDetails'(transient attribute on Employee ViewObject) from a third party data source exposed through some custom APIs. /** * executeQueryForCollection - overridden for custom java data source support. */ protected void executeQueryForCollection(Object qc, Object[] params, int noUserParams) { thirdPartyDataSource.filterOutValues(params); super.executeQueryForCollection(qc, params, noUserParams); } /** * createRowFromResultSet - overridden for custom java data source support. */ protected ViewRowImpl createRowF...

Customizing the order of posting changes to database

There are some use cases where you may need to control the order of posting changes to database( in other words, control the order in which the entity objects in the 'pending changes list' are processed ). This situation may arise when you want to delete a specific record and modify another record with deleted records attribute values for which 'uniqueness constraint' is defined at database level. Please note that by default, when you commit the transaction the entity objects in the pending changes list are processed in chronological order, in other words, the order in which the entities were added to the list ( Read more... ). All goes well when user opts to delete a record first, and as next step modify an existing records with deleted records attribute values. In this case deleted record gets added to the pending changes list first, followed by the modified one. There are some interesting scenarios where you may need to outsmart the business users to make it work....

Refresh the parent view when a taskflow displayed in a popup returns

Image
This post discusses an interesting use case on refreshing the parent view when an in-line popup taskflow returns. There are two taskflows, both work with separate transaction contexts(Transaction attribute is set as new-transaction). Second taskflow is invoked from the first one as a dialog. The requirement here is to refresh the 'executables' of calling page(from first taskflow) when the second taskflow returns. This scenario usually arises when the second task flow updates tables used by the first one from a different transaction context. To learn more on taskflow, please refer Part III Creating ADF Task Flows in Fusion Middleware Fusion Developer's Guide for Oracle ADF. Cool, now back to the use case. One possible solution for the above scenario is to define a returnListener for secondary window on the command button (which invokes second taskflow as dialog) and add the custom logic to refresh the underlying IteratorBindings used by the parent page. Last step is ...

XML for Queried Data

ADF Business Components helps you to transform queried data into xml format. Interestingly, you can manipulate this xml content without much effort, and the same can be posted back to database as well. Please refer this topic 39.7 Reading and Writing XML in Fusion Middleware Fusion Developer's Guide to learn more. I'm attaching a simple demo application illustrating the usage of ViewObject::readXML(...) and ViewObject::writeXML(...) APIs. You can download the sample workspace from here . Please see CRUDXMLTestClient.java file in the sample project. [Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema] PS: Please note that ViewObject.readXML() will create new row, if the row that you supplied in the xml has not been retrieved by calling findByKey(). New row is inserted into the view object's rowset. Its attributes are populated using the values in any attribute element children of the current row element in the XML. If the primary key for the new row(EntityObject)...

Posting a JSF page to Servlet

There are some use cases which requires posting data to a (legacy) Servlet for further processing and on success, redirect to a JSF page. This example illustrates a possible solution for similar scenarios - posting a JSF page to a Servlet. Basic idea is to invoke a custom javascript method on click of the button and submit the form to a customized 'action' target(Servlet). <af:commandButton text="Post Me" id="cb1"> <af:clientListener type="action" method="customPostHandler"/> </af:commandButton> <af:resource type="javascript"> function customPostHandler(event) { var form = document.forms[0]; form.action = '/some-context-root/sampleservlet'; form.submit(); event.cancel(); } </af:resource> You can download the sample workspace from here . [Runs with Oracle JDeveloper 11g R1 PS2] How to run this sample? Run the login.jspx page. This page is pre-populated wit...