com.arsdigita.bebop.event
Interface PrintListener

All Superinterfaces:
EventListener
All Known Implementing Classes:
SearchAndSelect

public interface PrintListener
extends EventListener

Listeners of this class are called just before a Component is about to be output, either in the form of an XML element, or by printing its HTML representation. The prepare method of the listener can make modifications to the target of the event. The target will then be used to produce output instead of the source.

PrintEvents are unicast events, which means that components should only permit the registration of one PrintListener. Since the PrintListener is expected to modify the target, allowing multiple listeners to modify the target of one event would make it impossible to predict the resulting target component, since an individual listener can not know which listeners have run before it and which ones will run after it.

As an example consider the following code:

   Label l = new Label("Default text");
   l.addPrintListener( new PrintListener {
     private static final BigDecimal ONE = new BigDecimal(1);
     private BigDecimal count = new BigDecimal(0);
     public void prepare(PrintEvent e) {
       Label t = e.getTarget();
       synchronized (count) {
         count.add(ONE);
       }
       t.setLabel("Call no." + count + " since last server restart");
     }
   });
Adding the label l to a page will lead to a label that changes in every request and print how many times the containing label has been called.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/event/PrintListener.java#8 $
Author:
Karl Goldstein, Uday Mathur, David Lutterkort

Field Summary
static String versionId
           
 
Method Summary
 void prepare(PrintEvent e)
          Prepare the target component returned by e.getTarget() for output.
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

prepare

public void prepare(PrintEvent e)
Prepare the target component returned by e.getTarget() for output. The target component is an unlocked clone of the source of the event and can be freely modified within this method.

Parameters:
e - Event containing the page state, the source and the target of the event
See Also:
PrintEvent


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC