globe with meridians Language: Deutsch · English

open book Event - Print

Event rule „Print“: interface, context and an example – how to react to this Nuclos event.

REFERENZ DEVELOPER UPDATED: JUL 2026 APPLIES TO NUCLOS 4.2026.X

On this page

When does the rule fire?

This server-side rule runs when a form/report is printed (before output). It can be assigned to a business object.

Structure

Skeleton of the rule class (the rule editor creates it automatically):

package org.nuclet.businessentity; 
import org.nuclos.api.rule.PrintRule; 
import org.nuclos.api.context.PrintContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 
/** @name        
  * @description 
  * @usage       
  * @change      
*/
@Rule(name="Printouts Vorfiltern", description="Printouts Vorfiltern")
public class PrintoutsVorfiltern implements PrintRule {
    public void print(PrintContext context) throws BusinessException { 
    }
}

Context: PrintContext

The context PrintContext provides the affected BusinessObject via context.getBusinessObject(...); the RuleContext functions (providers) are also available. A BusinessException aborts the operation.

Assignment

Assign it to the target via drag-and-drop in the server rule manager. Optionally restrict execution to a status or an action; control the order with the arrow buttons.

Example

package de.mynuclet; 
import org.nuclos.api.rule.PrintRule;
import org.nuclos.api.context.PrintContext;
import org.nuclos.api.printout.Printout;
import org.nuclos.api.annotation.Rule;
import org.nuclos.api.exception.BusinessException;
import org.nuclos.api.printout.PrintoutList;
import de.mynuclet.formulare.*;
 
/** @name           PrintRuleBeispiel      
  * @description    Zeigt ein einfaches Anwendungsbeispiel für die Modifizierung der Ausgabeformate  ueber eine PrintRule
  * @usage      
  * @change     
*/
@Rule(name="PrintRuleBeispiel", description="PrintRule Beispiel")
public class PrintRuleBeispiel implements PrintRule {
    public void print(PrintContext context) throws BusinessException {
        final Auftrag auftrag = context.getBusinessObject(Auftrag.class);
        context.log("printoutlist " + context.getPrintoutList());
        if ("EUR".equals(auftrag.getWaehrung())) {
            context.log("Die Währung \"EUR\" wurde angegeben");
            for (final Printout printout : context.getPrintoutList()) {
                if (AuftragsbestaetigungLiefergeschaeftPO.class.equals(printout.getClass())) {
                    context.log("attach output format " + AuftragsbestaetigungProjektgeschaeftPO.Auftrag_Projektgeschaeft.getClass().getName());
                    printout.getOutputFormats().add(AuftragsbestaetigungProjektgeschaeftPO.Auftrag_Projektgeschaeft);
                    context.log("after attach" + printout.getOutputFormats().size());
                } else {
                    context.log(printout.getClass() + " != " + AuftragsbestaetigungLiefergeschaeftPO.class.getName());
                }
            }    
        }
    }
}

Related pages

open book Server-side rules


Basics.

Open →

gear Server rule manager


Assign.

Open →

clipboard Rule execution order


Order.

Open →

  • Keine Stichwörter