Jump to content
We've recently updated our Privacy Statement, available here ×

How to clone JRDesignXXX objects


barryguild1.com

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

All else fails, I guess I can use something like the following since it is Serializable

 

import java.io.ByteArrayInputStream;

import java.io.ByteArrayOutputStream;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

import java.io.Serializable;

 

public class CloneSerialized {

public final static <T extends Serializable> T cloneObject(T o) throws Exception

{

ByteArrayOutputStream bos = new ByteArrayOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(bos);

 

oos.writeObject(o);

oos.close();

 

ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());

ObjectInputStream ois = new ObjectInputStream(bis);

 

T ret = (T)ois.readObject();

 

return ret;

}

}

Link to comment
Share on other sites

  • 1 year later...

JasperReports version 2.0.3 and later now includes clone support for JRDesign objects. This is exactly the right solution to the problem of dynamically generating templates with multiple columns not known until runtime.

Way to go JR guys!

Link to comment
Share on other sites

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...