0% found this document useful (0 votes)
30 views

Public Class: Person

This document defines a Person class with properties for id, name, and lastName. It includes default and parameterized constructors to initialize the properties. Getter and setter methods are provided to access and update each property. The document also contains a JasperAction class that populates a list of Person objects with sample data and compiles a Jasper report template to generate a report using the list as a data source.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Public Class: Person

This document defines a Person class with properties for id, name, and lastName. It includes default and parameterized constructors to initialize the properties. Getter and setter methods are provided to access and update each property. The document also contains a JasperAction class that populates a list of Person objects with sample data and compiles a Jasper report template to generate a report using the list as a data source.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

public class Person {

private Long id;

private String name;

private String lastName;

public Person() {
}

public Person(String name, String lastName) {


this.name = name;
this.lastName = lastName;
}

public Person(Long id, String name, String lastName) {


this.id = id;
this.name = name;
this.lastName = lastName;
}

public Long getId() {


return id;
}

public void setId(Long id) {


this.id = id;
}
public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {


this.lastName = lastName;
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}
}
import java.util.ArrayList;
import java.util.List;

import net.sf.jasperreports.engine.JasperCompileManager;

import com.acme.test.Person;
import com.opensymphony.xwork.ActionSupport;

public class JasperAction extends ActionSupport {

/** List to use as our JasperReports dataSource. */


private List<Person> myList;

public String execute() throws Exception {


// Create some imaginary persons.
Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie");
Person p2 = new Person(new Long(2), "Jason", "Carrora");
Person p3 = new Person(new Long(3), "Alexandru", "Papesco");
Person p4 = new Person(new Long(4), "Jay", "Boss");

// Store people in our dataSource list (normally they would come from a da
tabase).
myList = new ArrayList<Person>();
myList.add(p1);
myList.add(p2);
myList.add(p3);
myList.add(p4);

// Normally we would provide a pre-compiled .jrxml file


// or check to make sure we don't compile on every request.
try {
JasperCompileManager.compileReportToFile(
"S2_WEBAPP/jasper/our_jasper_template.jrxml",
"S2_WEBAPP/jasper/our_compiled_template.jasper");
} catch (Exception e) {
e.printStackTrace();
return ERROR;
}

return SUCCESS;
}

public List<Person> getMyList() {


return myList;
}
}

You might also like