Posts

Showing posts from December, 2010

Displaying special characters on UI

Image
You can use Unicode to display special charters on UI components. You may need to use the resource bundle to hold the Unicode values (of the special characters), and the same can be referred from the UI using the key.

ResourceBundle Entry ----------------------- view.copyRightSymbol=\u00a9 JSF ---- <c:set var="viewcontrollerBundle" value="#{adfBundle['view.ViewControllerBundle']}"/> <af:outputText value="Copyright #{viewcontrollerBundle['view.copyRightSymbol']}" id="ot1"/>
The output on the page may look like as shown in the following image.

Updating supporting business data before committing the transaction

Image
In some specific business scenarios you may need to manipulate(create/modify/delete) related business records before committing the parent record(EntityObject). For example, inserting entries in to an audit table whenever some business data changes. Here the audit table its not updated by a user, instead the table is populated based on the updated data from the transaction tables. This post discusses a recommended pattern for such scenarios where you may need to create/modify child/supporting entities whenever the parent entity changes.

Where do I keep the extra 'code' to deal with related entities?

Here you are looking for a place to hook your logic for creating/modifying supporting entities whenever the parent entity gets modified. The right place to keep this 'extra' logic is your parent EntityObject's prepareForDML(int operation, TransactionEvent e) method. With this approach, the newly created EntityObject(s) would get a chance to participate in the 'entit…

Programmatically disclosing a ShowDetailItem in a <af:panelTabbed>

Image
In this post I'm sharing an example illustrating the programmatic disclosure of <af:showDetailItem> which is added inside a <af:panelTabbed>. Please note that while programmatically disclosing a showDetailItem, it's your responsibility to set the 'Disclosed' to false for the previously displayed item. To illustrate this, take a look at the following code snippet:
RichPanelTabbed richPanelTabbed = getPanelTabbed(); for (UIComponent child : richPanelTabbed.getChildren()) { RichShowDetailItem sdi = (RichShowDetailItem)child; sdi.setDisclosed(isThisItemToBeDisclosed(sdi)); }
Updated on 05 August 2013: See the code snippet in the following post if you application uses customization  http://www.jobinesh.com/2013/08/revisiting-topic-programmatically.html

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2]

How to run this sample?

Run the test.jspx. This page displays drop down list displaying the tab names and a button…

Identifying the source of a Class file

Sometimes you may need to identify the jar file from where a specific Class has been loaded. This information is useful when you need to deal with some weird ClassLoader issues. The following API may help you here.
YourClz.class.getProtectionDomain().getCodeSource().getLocation();

Tips on configuring timezone for a fusion web application

Update:
#{adfFacesContext.timeZone.ID} does not bring the browser timezone any more(this has been turned off in Trinidad layer sometime back and it will display time zone of the underlying JRE instead). this is because there are no fool proof mechanism available to identity the timezone settings for the client browser. The below blog post is no longer valid if the requirement is to read timezone set for the end-user machine/browser.

You can set the timezone for a fusion web application using the time-zone element in trinidad-config.xml
Doc says:
Apache Trinidad will attempt to default the time zone to the time zone used by the client browser. If needed, you can use an EL expression that evaluates to a TimeZone object. This value is used by org.apache.myfaces.trinidad.converter.DateTimeConverter while converting strings to Date.

Please note that the above configuration is valid only for the view layer. ADF BC layer would use the time zone configured in the adf-config.xml. And this value…

Why do I get oracle.jbo.JboException: JBO-29000 ORA-01882: timezone region not found

Some of you you might have encountered the below shown error while deploying the ADF application on a stand alone weblogic server.

oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.sql.SQLDataException, msg=ORA-01882: timezone region not found at oracle.jbo.server.OracleSQLBuilderImpl.setSessionTimeZone(OracleSQLBuilderImpl.java:4964) ((OracleConnection) conn).setSessionTimeZone(regionName);
What goes wrong here?

Let us take a step back and see what happens when a client checks out an ApplicationModule to serve it's request. Please note that, on each checkout of an application module from the pool, that application module pool will acquire a connection from the database connection pool and would try to refresh the connection metadata to reflect the current use context. The timezone from the current locale context is set on the database connection by calling

oracle.jdbc.OracleConnection::setSessionTimeZone(regionName)
API Doc Says:
This method is used to set t…

Sorting a Transient ViewObject

Transient ViewObject is a value holder for non persistable data. In this post I'm sharing a very simple example illustrating the built in sorting support for a transient ViewObject. Please note that if you have table built using a transient ViewObject, a click on the sort icon for a column in turn would invoke ViewObjectImpl::setSortBy(String sortBy) to perform in memory sorting. Whereas for a non transient VO, sorting is done by setting the OrderByClause using ViewObjectImpl::setOrderByClause(String orderByClause). This example is built based on the above theory :). I'm populating the the rows programmatically from the overridden ViewObjectImpl::executeQueryForCollection(...) and the rest is taken care by the framework. Please see Fusion Developers Guide to know the key framework methods to override for programmatic View Objects

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

How to run this sample?

Run the main.jspx and t…

Using oracle.jbo.domain.Array with ViewCriteria

Image
Sometimes you may need pass multiple values to the SQL WHERE clause. Apparently you may end up in using SQL IN clause to pass values. A possible solution (using ADF BC) for such use case has been shared in one of my previous post(Using bind variable for....). This is not the only one possibility, you can realize similar use cases using oracle.jbo.domain.Array as well. This approach doesn't require the custom database function that we used in the previous post to parse the comma separated input string. In this post I'm sharing sample application built using oracle.jbo.domain.Array to pass multiple arguments to a SQL statements with IN clause.

A glance at the implementation

In this example user can search departments using comma separated values as shown in the following diagram.


Custom Converter for oracle.jbo.domain.Array

As you can see in the above picture, DepartmentName field in the search panel takes comma separated values. This inputText has a custom converter(view.Custom…

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of my employer.