Java Pojo entity classes do Birt report data sources

Source: Internet
Author: User
Tags new set set set

Environmental requirements: Download to http://www.eclipse.org/downloads/
Eclipse IDE for Java and report developers tools

First step: Create a Java project Reportjava;
Step Two: Create the package yss.com and write an entity class user as the data object in the report

package com.yss;public class user {    private string name;     private String phone;    private String  Address;        public user () {}         public user (string name,string phone,string address) {         this.name=name;        this.phone=phone;         this.address=address;    }         public void setname (String name)  {         this.name = name;    }     Public string getname ()  {        return name;     }    public string getphone ()  {        return  phone;    }    public void setphone (String phone)  {        this.phone = phone;    }     public string getaddress ()  {         return address;    }    public void setaddress ( string address)  {        this.address = address;     }}

Create a user Pojo factory class Userfactory:

Package Com.yss;import Java.util.arraylist;import Java.util.collection;import Java.util.list;public class        userfactory {public list<user> createUser () {list<user> users=new arraylist<user> ();        User U1=new User ("Qing", "12446", "Shenzhen");        User U2=new User ("Long", "34642", "Changsha");                User u3=new user ("Hai", "74532", "Shanghai");        Users.add (U1);        Users.add (U2);        Users.add (U3);    return users; }}


Step three: Create a new report named Report.rptdesign,
Next: Set up report Templates:blank report completion
and switch to the report design attempt;

Fourth step: Switch to the Layer panel data Explorer operation on the left,
Right-click Data sources to create a new data sources, select scripted data source in this build and name it pojosources;
Fifth step: Right-click on data sets to create a new set dataset, select the newly built data source Pojosources,
In the output columns, enter the information you want to display for the corresponding Pojo class, complete
Select the Script:open of the new set set in the edit area
To add a script:

Count=0;uf=new Packages.com.yss.UserFactory (); Users=uf.createuser ();

Then switch the script to fetch and add the scripts:

if (Count<users.size ()) {row["name"]=users.get (count). GetName ();    row["Phone"]=users.get (count). Getphone ();    row["Address"]=users.get (count). GetAddress ();    count++; return true;} return false;

When you switch script to close, clear the object:
Uf=null;
Users=null;
Sixth step: Switch the editing State of the report to layout, the left side panel switches to palette: Drag a table component into the edit area, and drag the set set previously built onto the table;

Ok. You can switch to preview previews of your results in the edit area again!












Java Pojo entity classes do Birt report data sources

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.