java.lang.NullPointer
i'm doing birt report integrating with eclipse rcp.
in the action file below:
protected Action printAction = new Action(){
{ setText("Print");
setId("print");
}
public void run() {
String frmSql = "FROM SP_PO inner join SP_PO_ITEM on SP_PO.ID=SP_PO_ITEM.PO_ID ";
String whrSql = "WHERE SP_PO.ID='07' ";
String sql = frmSql+whrSql;
String uri = Global.BIRT_REPORT_PATH+"Sp_Req_print.rptdesign&stmt= "+sql+"";
WebBrowser wb = new WebBrowser();
try {
wb = (WebBrowser)site.getPage().showView(WebBrowser.ID_VIEW);
wb.setUrl(uri);
} catch (PartInitException e) {
e.printStackTrace();
}
}
};
i got this error:
Unhandled event loop exception
Reason:
java.lang.NullPointerException
can anyone tell me how to solve the null pointer error?
[890 byte] By [
moonnya] at [2007-11-26 12:41:39]

thanks,CeciNEstPasUnProgrammeur
then how to unset the null value of them?
the WebBrowser.java is as shown below:
public class WebBrowser extends ViewPart {
public static final String ID_VIEW = "report.WebBrowser";
private Browser browser;
private Text location;
private HTMLPage page;
private Action backAction = new Action() {
{ setText("Back"); }
public void run() {
browser.back();
}
};
private Action forwardAction = new Action() {
{ setText("Forward"); }
public void run() {
browser.forward();
}
};
private Action stopAction = new Action() {
{ setText("Stop"); }
public void run() {
browser.stop();
}
};
private Action refreshAction = new Action() {
{ setText("Refresh"); }
public void run() {
browser.refresh();
}
};
private Action goAction = new Action() {
{ setText("Go"); }
public void run() {
browser.setUrl(location.getText());
}
};
public WebBrowser() {
}
public void createPartControl(Composite parent) {
page = new HTMLPage(parent, SWT.NONE);
//browser = createBrowser(parent, getViewSite().getActionBars());
//browser.setUrl("http://127.0.0.1:8181/birt/"); //$NON-NLS-1$
}
public void setFocus() {
page.setFocus();
/*if (browser != null && !browser.isDisposed())
browser.setFocus();*/
}
public void setUrl(String url){
page.setUri(url);
}
public Browser createBrowser(Composite parent, final IActionBars actionBars) {
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
parent.setLayout(gridLayout);
Label labelAddress = new Label(parent, SWT.NONE);
labelAddress.setText("A&ddress");
location = new Text(parent, SWT.BORDER);
GridData data = new GridData();
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.horizontalSpan = 2;
data.grabExcessHorizontalSpace = true;
location.setLayoutData(data);
browser = new Browser(parent, SWT.NONE);
data = new GridData();
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.FILL;
data.horizontalSpan = 3;
data.grabExcessHorizontalSpace = true;
data.grabExcessVerticalSpace = true;
browser.setLayoutData(data);
browser.addProgressListener(new ProgressListener() {
IProgressMonitor monitor = actionBars.getStatusLineManager().getProgressMonitor();
boolean working = false;
int workedSoFar;
public void changed(ProgressEvent event) {
//System.out.println("changed: " + event.current + "/" + event.total);
if (event.total == 0) return;
if (!working) {
if (event.current == event.total) return;
monitor.beginTask("", event.total); //$NON-NLS-1$
workedSoFar = 0;
working = true;
}
monitor.worked(event.current - workedSoFar);
workedSoFar = event.current;
}
public void completed(ProgressEvent event) {
//System.out.println("completed: " + event.current + "/" + event.total);
monitor.done();
working = false;
}
});
browser.addStatusTextListener(new StatusTextListener() {
IStatusLineManager status = actionBars.getStatusLineManager();
public void changed(StatusTextEvent event) {
//System.out.println("status: " + event.text);
status.setMessage(event.text);
}
});
browser.addLocationListener(new LocationListener() {
public void changed(LocationEvent event) {
location.setText(event.location);
}
public void changing(LocationEvent event) {
}
});
location.addListener(SWT.DefaultSelection, new Listener() {
public void handleEvent(Event e) {
browser.setUrl(location.getText());
}
});
actionBars.setGlobalActionHandler("back", backAction); //$NON-NLS-1$
actionBars.setGlobalActionHandler("forward", forwardAction); //$NON-NLS-1$
actionBars.setGlobalActionHandler("stop", stopAction); //$NON-NLS-1$
actionBars.setGlobalActionHandler("refresh", refreshAction); //$NON-NLS-1$
return browser;
}
public Browser getBrowser(){
return browser;
}
}
thanks in advance again