Jump to content
Changes to the Jaspersoft community edition download ×

AsynchronousFillHandle ???


2004 IR Help

Recommended Posts

By: Tbozu - tbozu

AsynchronousFillHandle ???

2005-08-09 01:09

is there any code or sample that i can look at that implement the AsynchronousFillHandle ? I would like to cancel the report filling but have no idea. Any directions?

 

 

 

 

By: Lucian Chirita - lucianc

RE: AsynchronousFillHandle ???

2005-08-10 00:34

Hi

 

There is no sample code included in the Jasper distribution. The javadocs have been slightly improved since the 1.0.0 release (you could check the CVS).

 

I'm including some very simple swing code to display a frame that uses an AsynchronousFillHandle.

 

final AsynchronousFillHandle handle = AsynchronousFillHandle.createHandle(jasperReport, parameters, connection);

 

JFrame.setDefaultLookAndFeelDecorated(true);

 

JFrame frame = new JFrame("fill");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

 

JButton startBtn = new JButton("Start");

startBtn.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

handle.startFill();

}

});

 

JButton cancelBtn = new JButton("Cancel");

cancelBtn.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

try

{

handle.cancellFill();

}

catch (JRException ex)

{

ex.printStackTrace();

throw new RuntimeException(ex);

}

}

});

 

final JLabel label = new JLabel("Empty");

final JLabel labelE = new JLabel("Epmty");

 

handle.addListener(new AsynchronousFilllListener()

{

public void reportFinished(JasperPrint print)

{

label.setText("Finished");

JasperViewer.viewReport(print);

}

 

public void reportCancelled()

{

label.setText("Cancelled");

}

 

public void reportFillError(Throwable t)

{

labelE.setText("Error" + t);

}

});

 

JPanel panel = new JPanel(new GridLayout(4, 1));

 

panel.add(startBtn);

panel.add(cancelBtn);

panel.add(label);

panel.add(labelE);

 

frame.getContentPane().add(panel);

 

frame.pack();

frame.setSize(new Dimension(400, 200));

frame.setVisible(true);

 

 

HTH,

Lucian

 

 

 

 

By: Tbozu - tbozu

RE: AsynchronousFillHandle ???

2005-08-09 19:47

i was wondering, is there any progress monitor associated with this handler? while the report is filling in another thread, is there any way for me to know how much of the report is already filled?

 

 

 

 

By: Lucian Chirita - lucianc

RE: AsynchronousFillHandle ???

2005-08-10 00:41

There is no way for the filler to evaluate the progress primarily because the data source interface doesn't have a record count method, therefore the filler cannot know how many rows are left to process. Even if we had such a method in the data source interface, the evaluation might be very inexact because of subreports, elements with delayed evaluation and other factors.

 

Regards,

Lucian

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