Friday, June 6, 2014

ADF : Accessing column value from ADF table row

There are cases where we need to show only a number in the Ui that comes from a different ViewObject .. Infact the real case scenario is ViewObject that has count(*) as result and we need to print that to the user in a tab or textbox.. look at the example

The Tab displays the Total Countries ..

select countries(*) as Count from COUNTRY group by countries ; This will return a single value..we generally tend to use VO.getEstimatedRowCount to get all the rowvalues and display .. The way to achieve and retrieve this is very simple ...

Following code snippet will help to achieve that

 public int getCount() {

        Long val = 0;
        ViewObject vo = this.getCountryVO();
        RowSetIterator rsIterator = vo.createRowSetIterator(null);
       while (rsIterator.hasNext()) {
            Row row =;
            val = ((BigDecimal)row.getAttribute("Count1")).longValue();

        return val;


Expose this method in the AM Client Interface .Add this method  to the page bindings as methodAction. Go to executable section in the pagedef , add invokeAction to this method . This will get invoked every time when the page is loaded . This brings the count available during pageload

Add this expr to the place where you need to print the result .

You can also access that method directly on clicking some button or link via ActionListener without having to InvokeAction under executables section ...

No comments:

Post a Comment