Showing posts from June, 2010

Decorate UI with view row Attribute's User Interface hints

This post discusses the possibility of using custom view row attribute hints to decorate your view layer. For example, let us take an Employee table, the use case requirement is to display red icon in a column if the salary is greater than 10000, green icon for all other cases. Please see the below screen shot for reference. Apparently there are multiple ways to achieve this. The approach I followed here is through custom view row attribute hints implementation. The idea is inspired by an earlier post from Steve. A glance at the implementation Implementation is very simple, Override ViewRowAttrHintsImpl::getHint(...) by sub classing ViewRowAttrHintsImpl . Please note that ViewRowAttrHintsImpl::getHint(..) will get invoked whenever the binding layer identifies any custom hints in the EL. The below implementation overrides the default behavior of getHint(...) to return different icons based on the salary, for the custom hint 'statusIcon'. Map iconMap = new H

Style your application in your own way !

Look and feel of your application can be further improved/customized using the Oracle ADF Faces skins and component style attributes. To learn more about this, please refer Chapter 20 Customizing the Appearance Using Styles and Skins from Web User Interface Developer's Guide Customizing the Style Properties of a Component Sometimes you may need to customize display 'style' of a specific set of UI components based on various business conditions. Conventional approach is to add 'inlineStyle' to decorate the components of choice. However this approach has it's own drawbacks like high maintenance cost, increased page size, highly error prone(if the same style needs to repeat across multiple pages) etc. A better approach is to extend the skin that you want to customize and override the style properties as per the use case requirement. Advantage with this approach is that skinning information is specified in one place for an entire application. A Simple Case

My application throws error after enabling jbo.doconnectionpooling = true !

Recently, a few of the developers reported saying that their application started misbehaving after setting jbo.doconnectionpooling = true. Interestingly, in most of the cases, root cause was one and same - incorrect usage of EntityImpl::postChanges(TransactionEvent e) . This method posts changed data to database, and these changes would be only visible within the same transaction associated with current 'Connection' instance. If you are building fusion web application, please don't call this method unless the transaction is getting committed within the same service request. Please note that database transaction is associated with Connection that you are using. If you turn on connection pooling, there is no guarantee that same connection would be available to serve your future service requests (unless you use the reserved release mode for the ApplicationModule). To learn more on the topic, please go through the following topics from Fusion Developer's Guide for Oracl

Enabling multiple selection on <af:table>

A common mistake while enabling multiple selection for a data bound table is to leave the default values for attributes(generated while creating the table in a single selection mode) selectedRowKeys and selectionListener as is. This is wrong, these parameters will override the multiple selection that user makes. So you may need to remove them. To enable multiple select capabilities on a <af:table>, 1. Set rowSelection="multiple" 2. Remove selectedRowKeys and selectionListener attributes(if any) This is well documented in Fusion Developer's Guide for Oracle Application Development Framework. Please see Section 23.5, "Providing Multiselect Capabilities"

Model driven approach for building Dynamic UI

One of the great feature of ADF Rich Client is that support for building User Interfaces on the fly. These dynamic components are smart enough to read the binding metadata and render themselves on the fly. Please read this topic 22.7 Using a Dynamic Form to Determine Data to Display at Runtime , to learn more about this feature. When we talk about the dynamism provided by the ADF Rich Client, story is incomplete without referring support from the ADF BC (business service) layer. You can create dynamic EntityObject, ViewObject and wire them to UI components declaratively, without much effort. In this post, I'm discussing some common 'dynamic UI' based use case requirements and their solutions using ADF. Case 1: Dynamic UI Table built using dynamic ViewObject(database table and attribute definitions change for each invocation) Use case requirement: UI needs to be populated from different database tables, based on various business conditions. Number of displayed attri

Accessing Resource Bundles from a ViewObject

There were couple of threads in ADF BC discussion forums asking for APIs to access associated resource bundle from a ViewObject/EntityObject class. One possibility is to use standard java.util.ResourceBundle API. Another interesting approach is to make use of the oracle.jbo.common.StringManager APIs used by the ADF BC layer. This is a wrapper over standard java ResourceBundle class. The below method is based on the second approach. This help you to retrieve the value for a key from the resource bundle associated with a ViewObject. public String getLocalizedValue(String key) { ResourceBundleDef resourceDef = this.getResourceBundleDef(); Locale locale = this.getApplicationModule().getSession().getLocale(); String retVal = StringManager.getLocalizedStringFromResourceDef(resourceDef, key, false); return retVal; } Where can I see the reference for the 'ResourceBundle&

Create row on a clickToEdit table

Generally developers use 'createInsert' operations associated with the iterator binding to insert a new row. Works perfectly! However, when you use the same technique on a clickToEdit table to create new rows, all goes well, but the newly create record does not become the 'active row'. So the end user can by pass the validation and can create multiple records without key in the mandatory fields for the newly created ones, by clicking the 'Create' button multiple times. A possible work around solution for this scenario is to customize the record creation, and programatically set the ActiveRowKey, as shown below. public void createAction(ActionEvent actevnt) { BindingContext bc = BindingContext.getCurrent(); DCBindingContainer dcb = (DCBindingContainer)bc.getCurrentBindingsEntry(); OperationBinding op = dcb.getOperationBinding("createDept"); Row row = (Row)op.execute(); if (op.getErrors().size()

JBO-27023 Failed to validate all rows

Have you ever experience weird error reporting as shown below, while trying to throw some meaningful validation error from your business methods? Instead of the desired error, UI reports a generic error saying JBO-27023 : “Failed to validate all rows”. What goes wrong? Take a look at your manged bean where you have the code to invoke methods from ApplicationModule(service layer). Your code may look like as shown below, where you are getting instance of ApplicationModule and invoking methods directly on it.This is not the recommended approach, as you are by passing binding layer. Suggested approach is to let the binding layer to do this job as shown under 'Right Implementation' Wrong Implementation public String someAction() { BindingContext bc = BindingContext.getCurrent(); DCDataControl dc = bc.findDataControl(dataControlName); if ((dc != null) && dc instanceof DCJboDataControl) { ApplicationModuleImpl amImpl =