Monthly Archives: July 2010

Getting the value of Saved search – programatic way

QueryModel qm = (QueryModel)evaluateEL("#{bindings.SearchViewCriteriaQuery.queryModel}");
 for(int indexCount=0; indexCount
 QueryDescriptor qd = qm.getUserQueries().get(indexCount);
 String queryDescriptorName = qd.getName();
 m = qd.getUIHints();
 isDefault = (Boolean) m.get(QueryDescriptor.UIHINT_DEFAULT);
 isRunAutomatically = (Boolean) m.get(QueryDescriptor.UIHINT_AUTO_EXECUTE);
 if (Boolean.TRUE.equals(isDefault) && Boolean.TRUE.equals(isRunAutomatically){
 queryDescriptorName = null;

Snippet to check if the transaction is dirty

We can use the following code snippet to check if the transaction is dirty or not

BindingContext bctx = oracle.adf.controller.binding.BindingUtils.getBindingContext();
if (bctx.findDataControlFrame(bctx.getCurrentDataControlFrame()).isTransactionDirty()) {
 //show the timestamp
 //don't show

Show dialog when a page is fully loaded

1. Add popup and outputText component at the end of your page (make sure popup is before outputText in the page structure)

2. Create bean binding for popup as well as outputText.

3. In the getter of outputText, launch popup programatically.

4. Set visible=false for outputText

Thoughts on Java that works

Disclaimer: This is just to get an idea of the implementation, please do not copy the source code

The problem reads like

Basic sales tax is applicable at a rate of 10% on all goods, except books,
food, and medical products that are exempt. Import duty is an additional
sales tax applicable on all imported goods at a rate of 5%, with no
When I purchase items I receive a receipt which lists the name of all the
items and their price (including tax), finishing with the total cost of the
items, and the total amounts of sales taxes paid.  The rounding rules for
sales tax are that for a tax rate of n%, a shelf price of p contains
(np/100 rounded up to the nearest 0.05) amount of sales tax.
Write an application that prints out the receipt details for these shopping

Find the complete solved solution here

A squad of robotic rovers are to be landed by NASA on a plateau on Mars.
This plateau, which is curiously rectangular, must be navigated by the
rovers so that their on-board cameras can get a complete view of the
surrounding terrain to send back to Earth.

A rover’s position and location is represented by a combination of x and y
co-ordinates and a letter representing one of the four cardinal compass
points. The plateau is divided up into a grid to simplify navigation. An
example position might be 0, 0, N, which means the rover is in the bottom
left corner and facing North.

In order to control a rover, NASA sends a simple string of letters. The
possible letters are ‘L’, ‘R’ and ‘M’. ‘L’ and ‘R’ makes the rover spin 90
degrees left or right respectively, without moving from its current spot.
‘M’ means move forward one grid point, and maintain the same heading.

Assume that the square directly North from (x, y) is (x, y+1).

Find the complete solved solution here

How to change the default text title of Detached table/treetable

have trindad-skins.xml in your web-inf folder and have the following tag

 <id>dummy.desktop</id> // you are overriding the style
 <extends>fusion.desktop</extends> // this should be from the trinidad-config.cml
 <bundle-name></bundle-name> // your skin bundle to override the name

here dummy.css is used to override any visual property of the faces component defined in fusion theme
to override the label, use in the SkinBundle like (The java bundle file should be registered as a managed bean in adfc-config.xml)

 import java.util.ListResourceBundle;
public class SkinBundle
 extends ListResourceBundle
 public Object[] getContents()
 return _CONTENTS;

static private final Object[] _CONTENTS =
 { "af_panelCollection.LABEL_DETACH_TABLE_DLG", "Any name for the Detachable Table" },
 { "af_panelCollection.LABEL_DETACH_TREE_TABLE_DLG", "Any name for the Detachable Tree Table" }

Decompiler for Jdeveloper

You can use JAD or any other decompiler with JDeveloper to show you the decompiled version of the source instead of the standard stub view with the following command line argument.

The property is ‘jcncmd’, and to use for instance ‘jad.exe’, you would use:

“-J-Djcncmd=D:\bin\jad.exe -b -ff -nl -p -pi99999 -space -t2”

There are two conditions: – the external decompiler must send its output to stdout – the external decompiler must accept as its last argument the full path to the Java class file to decompile. In the line above, -p forces the output to stdout.

Also you can invoke using control click by editing $JDEV_HOME\jdeveloper\jdev\bin\jdev.conf and add the following line

“AddVMOption -Djcncmd=D:\bin\jad.exe -b -ff -nl -p -pi99999 -space -t2”

Database answers

Found this useful link for all your db design related queries

Ways to set the Query Mode programatically

The following snippet will be helpful in setting up the mode of the query criteria in programmatic way.

public Boolean setAdvancedMode(){
              QueryDescriptor descriptor =
             return true;

public Object evaluateEL(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =
        ValueExpression exp =
            expressionFactory.createValueExpression(elContext, el,
       return exp.getValue(elContext);

Easiest way to get the current binding from the bean

use the following snippet to get the current binding

BindingContainer bindings =  BindingContext.getCurrent().getCurrentBindingsEntry();
 AttributeBinding at = (AttributeBinding)bindings.getControlBinding("Period");

The above mentioned code is useful only in case of retrieving values of any attribute binding in the page definition file. To retrieve specific information use it like

//For search binding use it like
FacesCtrlSearchBinding fc =
FacesCtrlSearchBinding fc =

//For LOV binding use it like
FacesCtrlLOVBinding fc = (FacesCtrlLOVBinding)bindings.get("PeriodLOV");

some of the useful methods that can also be used for retrieving binding is

private BindingContainer getBindings() {
BindingContainer bindings =
(BindingContainer)fc.getApplication().evaluateExpressionGet(fc, "#{bindings}",
return (bindings == null) ? null : bindings;

to retrieve the bindings  or executable you use it like

//to retireve the tree/table bindings
FacesCtrlHierBinding fc = (FacesCtrlHierBinding)bindings.get("Period");

//to retireve the tree/table iterator
DCIteratorBinding dc = (DCIteratorBinding)bindings.get("PeriodIterator");

Pictorial representation of JSF Life Cycle