Home » getting null pointer exception in referring table to get child count in export rows to Excel

getting null pointer exception in referring table to get child count in export rows to Excel

0

Error is coming at int childCnt = t2.getChildCount();can u pl help me?

package com.att.logo.view.backing.lookup;

import java.io.OutputStream;

import java.io.OutputStreamWriter;

import java.util.ArrayList; import java.util.List;

import javax.faces.context.FacesContext;

import oracle.binding.BindingContainer; import oracle.adf.model.BindingContext; import oracle.adf.model.binding.DCBindingContainer; import oracle.adf.model.binding.DCIteratorBinding;

import oracle.adf.view.rich.component.rich.data.RichColumn;

import oracle.adf.view.rich.component.rich.data.RichTable;

import oracle.jbo.Row; import oracle.jbo.RowSetIterator; import oracle.jbo.ViewObject;

public class LocationSearchBean { public LocationSearchBean() { }

private RichTable t2;

public void ExportAllRecords(FacesContext facesContext, OutputStream outputStream) {
    // Add event code here...

    try {
        BindingContext bindingctx = BindingContext.getCurrent();
        System.out.println("bindingctx:"+bindingctx);
        BindingContainer binding = bindingctx.getCurrentBindingsEntry();
        System.out.println("binding:"+binding);
        DCBindingContainer bindingsImpl = (DCBindingContainer)binding;
        System.out.println("bindingsImpl:"+bindingsImpl);
        DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("XxLogoLocationVO1Iterator");
        System.out.println("dciter:"+dciter);
        ViewObject vo_rep = dciter.getViewObject();
        System.out.println("vo_rep:"+vo_rep);
        OutputStreamWriter w = new OutputStreamWriter(outputStream);
        System.out.println("w:"+w);
        System.out.println("Value in childCnt: " + t2.getChildCount());
        int childCnt = t2.getChildCount();
        System.out.println("Value in childCnt: " + childCnt);
        RichColumn col = null;
        List c = new ArrayList();
        c = t2.getChildren();
        for (int i = 1; i < c.size(); i++) {
            if (i == 1)
                continue;
            col = (RichColumn)c.get(i);
            w.append("");
            w.append(col.getHeaderText() + "\t");
            w.append("");
        }
        w.append("\n");
        w.append("");
        Row r = null;


        RowSetIterator iter = dciter.getRowSetIterator();
        iter.first();
        r = iter.getCurrentRow();

        while (r != null) {
            w.append("");
            if (r.getAttribute("LogoLocationCode") != null)
                w.append("" + r.getAttribute("LogoLocationCode") + "\t");
            else
                w.append("" + "\t");
            r = iter.next();
        }
        w.close();
    } catch (Exception e) {
        System.out.println("Error in Locations Export:" + e.getMessage());
        e.printStackTrace();
    }

    }

}

Your Answer

Please login first to submit.