Jump to content
Changes to the Jaspersoft community edition download ×

New to Jasper!!!!Please Help!!!!!Urgent


2005 IR Help

Recommended Posts

By: Preethi N - preethin

New to Jasper!!!!Please Help!!!!!Urgent

2004-03-11 01:35

Please help me out....

This is my code.....

 

JasperDesign jaspDesign = new JasperDesign();

JRDesignBand band = new JRDesignBand();

JRDesignFont designFont = new JRDesignFont();

designFont.setFontName("Times");

designFont.setBold(true);

designFont.setItalic(true);

band.setHeight(0);

jaspDesign.setTitle(band);

jaspDesign.setPageHeader(band);

jaspDesign.setColumnHeader(band);

JRDesignBand band1 = new JRDesignBand();

band1.setHeight(20);

JRDesignStaticText tf = new JRDesignStaticText();

tf.setX(30);

tf.setY(50);

tf.setWidth(300);

tf.setHeight(20);

tf.setTextAlignment(JRTextElement.TEXT_ALIGN_CENTER);

tf.setFont(designFont);

JRDesignExpression expression = new JRDesignExpression();

expression.setValueClass(java.lang.String.class);

String val = "Blah blah blah.nBlah blah blah.n";

expression.setText("""+val+""");

tf.setText(val);

band1.addElement(tf);

jaspDesign.setDetail(band1);

jaspDesign.setColumnFooter(band);

jaspDesign.setPageFooter(band);

jaspDesign.setSummary(band);

 

JasperReport jasperReport = JasperCompileManager.compileReport(CCRptWrapperDataSourceForPDF.createPDF());

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,parameters,lDataSource);

 

and the lDataSource is nothing but just an instantiation of the below class

 

public class CCRptWrapperDataSourceForPDF implements JRDataSource

{

private ArrayList arrLineList;

private ArrayList arrItemList;

int index = -1;

int indexItem = -1;

 

public void setDataList(ArrayList aDataList)

{

arrLineList = aDataList;

}

public void setItemArray(ArrayList aItemList)

{

arrItemList = aItemList;

}

 

public boolean next()

{

index++;

// com.cc.utils.Debug.out_println("INDEX"+index);

com.cc.utils.Debug.out_println(arrLineList.size());

return (index<arrLineList.size());

}

 

public Object getFieldValue(JRField aField)

{

Object lObj=null;

CCRptWrapperDataForPDF lData = (CCRptWrapperDataForPDF)arrLineList.get(index);

String asFieldName = aField.getName();

Class lClass = lData.getClass() ;

//System.out.println("Field Name :"+asFieldName);

if(asFieldName.equalsIgnoreCase("ItemName")){

//CCRptWrapperDataForPDF lDataItem = (CCRptWrapperDataForPDF)arrItemList.get(indexItem);

 

}

// com.cc.utils.Debug.out_println("PRINTING LINES");

try

{

 

Method lMethod = lClass.getMethod("get"+asFieldName,null);

lObj = lMethod.invoke(lData,null);

}

catch (Exception aEx){aEx.printStackTrace();}

return lObj;

 

}

 

}

 

 

when I run this code I get the following exception

 

java.lang.NullPointerException

at dori.jasper.engine.design.JRVerifier.verifyDesignAttributes(JRVerifie

r.java:161)

at dori.jasper.engine.design.JRVerifier.verifyDesign(JRVerifier.java:126

)

at dori.jasper.engine.design.JRVerifier.verifyDesign(JRVerifier.java:117

)

at dori.jasper.engine.design.JRCompiler.compileReport(JRCompiler.java:96

)

at dori.jasper.engine.JasperCompileManager.compileReport(JasperCompileMa

nager.java:190)

at com.cc.common.servlet.CCContractPrintHandlerServlet.performTask(CCCon

tractPrintHandlerServlet.java:121)

at com.cc.common.servlet.CCContractPrintHandlerServlet.doPost(CCContract

PrintHandlerServlet.java:32)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm

pl.java:265)

at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm

pl.java:200)

at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe

rvletContext.java:2495)

at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm

pl.java:2204)

at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)

at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

 

where did I go wrong??

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...