Kod Jasper apisi üzerinden parametre göndererek engine'in render etmesi mümkünmüdür ve bunu nasıl yapabilirim.(Not:http üzerinden istek yapmak istemiyorum)

Yada jasperviewer kullanımı hakkında yardımcı olabilirmisiniz ?

soruldu: 24 Tem '12, 09:37

Alp's gravatar image

Alp
873304447
cevap kabul oranı: 18%

değiştirildi: 28 Tem '12, 02:45


Jasper Report'da parametre işlemleri nasıl yapılır? baslikli soruda cevaplar verilmisti. Yardimci olabilir.

Update Jasper Report Viewer kullanimi: Once iReport programini indirip kurun. iReport bagimsiz program olarak calisabildigi gibi NetBeans IDE plugin'i olarak da NetBeans icine yuklenebiliyor. Ayri program olarak yuklemenizi tavsiye ederim. iReport icinden rapor design yaptiktan sonra java ile gercek veriler kullarak bu raporu Jasper Viewer ile cagirabilirsiniz. Jasper Report Viewer icin guzel bir dokuman burda var.

Jasper Report'lari elle kod yazarak olusturmanizi tavsiye etmem, cok zahmetli, yorucu ve ilerde bakimi zor olur!

permanent link

cevaplandı: 27 Tem '12, 05:43

CemIkta's gravatar image

CemIkta ♦
19.9k29125190
cevap kabul oranı: 36%

değiştirildi: 27 Tem '12, 08:18

Hocam Jasper Viewer'ı kullanmak istiyorum şöyle bir örnek yaptım ama malsef çalıştıramadım nerde hata yapıyorum yada cok yanlış mı gidiyorum yardımcı olabilimisiniz?

package ar.com.fdvs.dj.test;

import java.awt.Color;

import net.sf.jasperreports.view.JasperViewer; import ar.com.fdvs.dj.domain.DynamicReport; import ar.com.fdvs.dj.domain.Style; import ar.com.fdvs.dj.domain.builders.ColumnBuilder; import ar.com.fdvs.dj.domain.builders.DynamicReportBuilder; import ar.com.fdvs.dj.domain.constants.Border; import ar.com.fdvs.dj.domain.constants.Font; import ar.com.fdvs.dj.domain.constants.HorizontalAlign; import ar.com.fdvs.dj.domain.constants.Transparency; import ar.com.fdvs.dj.domain.entities.columns.AbstractColumn;

public class TemplateFileReportTest extends BaseDjReportTest {

public DynamicReport buildReport() {

Style detailStyle = new Style();
    Style headerStyle = new Style();

headerStyle.setBackgroundColor(new Color(230,230,230));
    headerStyle.setBorderBottom(Border.THIN());
    headerStyle.setBorderColor(Color.black);
    headerStyle.setHorizontalAlign(HorizontalAlign.CENTER);
    headerStyle.setTransparency(Transparency.OPAQUE);

Style titleStyle = new Style();
    titleStyle.setHorizontalAlign(HorizontalAlign.CENTER);
    titleStyle.setFont(Font.ARIAL_BIG_BOLD);
    Style subtitleStyle = new Style();
    Style amountStyle = new Style(); amountStyle.setHorizontalAlign(HorizontalAlign.RIGHT);

/**
     * Creates the DynamicReportBuilder and sets the basic options for
     * the report
     */
    DynamicReportBuilder drb = new DynamicReportBuilder();
    drb.setTitle("November 2006 sales report")                  //defines the title of the report
        .setSubtitle("The items in this report correspond "
                +"to the main products: DVDs, Books, Foods and Magazines")
        .setDetailHeight(15)                        //defines the height for each record of the report
        .setMargins(30, 20, 30, 15)                         //define the margin space for each side (top, bottom, left and right)
        .setDefaultStyles(titleStyle, subtitleStyle, headerStyle, detailStyle)
        .setColumnsPerPage(1);                      //defines columns per page (like in the telephone guide)

/**
     * Note that we didn't call the build() method yet
     */

/**
     * Column definitions. We use a new ColumnBuilder instance for each
     * column, the ColumnBuilder.getNew() method returns a new instance
     * of the builder
     */

AbstractColumn id = ColumnBuilder.getNew()
        .setColumnProperty("id", Long.class.getName())
        .setTitle("ID").setWidth(40)
        .build();

/**
     * We add the columns to the report (through the builder) in the order
     * we want them to appear
     */
    drb.addColumn(id);

/**
     * add some more options to the report (through the builder)
     */
    drb.setUseFullPageWidth(true);  //we tell the report to use the full width of the page. this rezises
                                    //the columns width proportionally to meet the page width.

//This look for the resource in the classpath
    drb.setTemplateFile("c:/DenemeJasper.jrxml");

//Portrait (looks the resource as a file in the filesystem)

// drb.setTemplateFile(System.getProperty("user.dir") + "/target/test-classes/templates/TemplateReportTest.jrxml");

    //Landscape  (looks the resource as a file in the filesystem)

// drb.setTemplateFile(System.getProperty("user.dir") + "/target/test-classes/templates/TemplateReportTestPortLandscape.jrxml");

    DynamicReport dr = drb.build(); //Finally build the report!

params.put("leftHeader", "DynamicJasper is the Best!!!");
params.put("rightHeader", "This is the right header");

return dr;

}

public static void main(String[] args) throws Exception { TemplateFileReportTest test = new TemplateFileReportTest(); test.testReport(); JasperViewer.viewReport(test.jp); //finally display the report report }

}

 package ar.com.fdvs.dj.test;

import ar.com.fdvs.dj.core.DynamicJasperHelper; import ar.com.fdvs.dj.core.layout.ClassicLayoutManager; import ar.com.fdvs.dj.core.layout.LayoutManager; import ar.com.fdvs.dj.domain.DynamicReport; import ar.com.fdvs.dj.util.SortUtils; import junit.framework.TestCase; import net.sf.jasperreports.engine.JRDataSource; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;

import java.sql.Connection; import java.sql.DriverManager; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map;

public abstract class BaseDjReportTest extends TestCase {

public Map getParams() {
    return params;
}

protected static final Log log = LogFactory.getLog(BaseDjReportTest.class);

protected JasperPrint jp; protected JasperReport jr; protected Map params = new HashMap(); protected DynamicReport dr;

public abstract DynamicReport buildReport() throws Exception;

public void testReport() throws Exception { dr = buildReport();

    /**
     * Get a JRDataSource implementation
     */
    JRDataSource ds = getDataSource();

    /**
     * Creates the JasperReport object, we pass as a Parameter
     * the DynamicReport, a new ClassicLayoutManager instance (this
     * one does the magic) and the JRDataSource
     */
    jr = DynamicJasperHelper.generateJasperReport(dr, getLayoutManager(), params);

    /**
     * Creates the JasperPrint object, we pass as a Parameter
     * the JasperReport object, and the JRDataSource
     */
    log.debug("Filling the report");
    if (ds != null)
        jp = JasperFillManager.fillReport(jr, params, ds);
    else
        jp = JasperFillManager.fillReport(jr, params);

    log.debug("Filling done!");
    log.debug("Exporting the report (pdf, xls, etc)");
     exportReport();

     log.debug("test finished");

}

protected LayoutManager getLayoutManager() { return new ClassicLayoutManager(); }

protected void exportReport() throws Exception { ReportExporter.exportReport(jp, System.getProperty("user.dir")+ "/target/reports/" + this.getClass().getName() + ".pdf"); exportToJRXML(); }

protected void exportToJRXML() throws Exception { if (this.jr != null){ DynamicJasperHelper.generateJRXML(this.jr, "UTF-8",System.getProperty("user.dir")+ "/target/reports/" + this.getClass().getName() + ".jrxml");

} else {
    DynamicJasperHelper.generateJRXML(this.dr, this.getLayoutManager(), this.params, "UTF-8",System.getProperty("user.dir")+ "/target/reports/" + this.getClass().getName() + ".jrxml");
}

}

protected void exportToHTML() throws Exception { ReportExporter.exportReportHtml(this.jp, System.getProperty("user.dir")+ "/target/reports/" + this.getClass().getName() + ".html"); }

/* * @return JRDataSource / protected JRDataSource getDataSource() { Collection dummyCollection = TestRepositoryProducts.getDummyCollection(); dummyCollection = SortUtils.sortCollection(dummyCollection,dr.getColumns());

JRDataSource ds = new JRBeanCollectionDataSource(dummyCollection);      //Create a JRDataSource, the Collection used
                                                                        //here contains dummy hardcoded objects...
return ds;

}

public Collection getDummyCollectionSorted(List columnlist) { Collection dummyCollection = TestRepositoryProducts.getDummyCollection(); return SortUtils.sortCollection(dummyCollection,columnlist);

}

public DynamicReport getDynamicReport() { return dr; }

/* * Uses a non blocking HSQL DB. Also uses HSQL default test data * @return a Connection * @throws Exception / public static Connection createSQLConnection() throws Exception { Connection con = null; Class.forName("oracle.jdbc.driver.OracleDriver" ); con = DriverManager.getConnection("url, "user", "password");

 return con;

}

}

(27 Tem '12, 06:42) Alp Alp's gravatar image

Jasper Viewer icin cevaba ekleme yazdim, umarim yardimci olur.

(27 Tem '12, 08:12) CemIkta ♦ CemIkta's gravatar image

Hocam Dynamic web Project olarak oluşturdum.Classları,raporları ve jar dosyalarını ekledim. Fakat projem ayaga kalkmıyor.

Hata vermiyor sadece warning var acaba hatam nerede?

WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:dene' did not find a matching property. .. org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor C:\...deneme.xml ..org.apache.catalina.startup.SetContextPropertiesRule begin WARNING:[SetContextPropertiesRule]{Context} Setting.server:deneme' did not find a matching property.

(27 Tem '12, 09:16) Alp Alp's gravatar image

Sanirim farkli seylerden bahsediyoruz. Eger jasper report'u web projesi ile kullaniyorsan Jasper Viewer ile raporlari gosteremessin. Jasper Viewer swing programi ve desktop da calisir. Eger web projesi ile kullaniyorsan pdf, excel gibi formatlara donusturup client a gondermelisin. Bunun ornegi de yukaridaki onceki jasper sorusundaki cevaplarda mevcut.

(27 Tem '12, 09:26) CemIkta ♦ CemIkta's gravatar image

Hocam şu kitaptaki örnegi yapmaya çalıştım. İlk amacım raporları bu şekişde browserda açmak. Kitap sayfalarına göre söylüyorum 64. sayfadaki örnege bakabilirsiniz. http://www.packtpub.com/sites/default/files/SampleChapter-JasperReports.pdf

Yardımlarınız için çok teşşekürler.

Dediginiz gibi yaptım oldu aslında ama applet olarak jsp sayfasında açmaya çalışıyorum ve hata alıyorum.

(27 Tem '12, 11:22) Alp Alp's gravatar image

Jasper da böyle bir şey yapılabilecegi söylenmiş fakat olmadı hocam http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=30410

Servlet içinde pdf çıktısı alabiliyorum fakat jasperviewer'ı applet olarak kullanarak içinde açmayı başaramadım.

(30 Tem '12, 01:12) Alp Alp's gravatar image

Aldıgım hatayı paylaşıyorum

Aşagıda verdigim linkte de aynı hatayı veriyor http://www.royalswimteam.com/hello.html

Java Plug-in 1.6.0_33

Using JRE version 1.6.0_33-b03 Java HotSpot(TM) Client VM User home directory = C:\Users\Universal


c: clear console window f: finalize objects on finalization queue g: garbage collect h: display this help message l: dump classloader list m: print memory usage o: trigger logging q: hide console r: reload policy configuration s: dump system and deployment properties t: dump thread list v: dump thread stack x: clear classloader cache 0-5: set trace level to <n>


load: class EmbeddedViewerApplet.class not found. java.lang.ClassNotFoundException: EmbeddedViewerApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.ClassNotFoundException: EmbeddedViewerApplet.class load: class EmbeddedViewerApplet.class not found. java.lang.ClassNotFoundException: EmbeddedViewerApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.ClassNotFoundException: EmbeddedViewerApplet.class load: class HelloSwingApplet.class not found. java.lang.ClassNotFoundException: HelloSwingApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.ClassNotFoundException: HelloSwingApplet.class load: class EmbeddedViewerApplet.class not found. java.lang.ClassNotFoundException: EmbeddedViewerApplet.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.ClassNotFoundException: EmbeddedViewerApplet.class

(30 Tem '12, 03:32) Alp Alp's gravatar image

Bu konuda yeterli bilgi sahibi değilim fakat gördüğüm kadarıyla sürüm ile ilgili bir hata alıyorsun. Sürüm üzerinden araştırma yaparsan sorunu kısa sürede çözebileceğini düşünüyorum.

Kolay gelsin.

(30 Tem '12, 03:39) creseos creseos's gravatar image

Versiyon ile alakası yok EmbeddedViewerApplet.class'ını görmüyor. İndirdigim jar'lar içerisinde de böyle bir class yok

(30 Tem '12, 06:42) Alp Alp's gravatar image
9 yorumdan 5 tanesi gösteriliyor hepsini göster
Cevabınız
toggle preview

Bu soruyu takip et

E-Posta üzerinden:

Üyelik girişi yaptıktan sonra abonelik işlemlerini yapabilirsiniz

RSS üzerinden:

Cevaplar

Cevaplar ve Yorumlar

Yazı Formatlama

  • *italic* ya da _italic_
  • **bold** ya da __bold__
  • link:[text](http://url.com/ "başlık")
  • resim?![alt text](/path/img.jpg "başlık")
  • liste: 1. Foo 2. Bar
  • temel HTML etiketleri de kullanılabilir

Bu sorunun etiketleri:

×1,079
×8

Soruldu: 24 Tem '12, 09:37

Görüntüleme: 1,016 kez

Son güncelleme: 30 Tem '12, 06:42

powered by BitNami OSQA