| Auszug |
|---|
|
Nuclos event rule Print: interface, PrintContext, structure, assignment in the server rule manager, example code (Java). |
Language: Deutsch · English
Event - Print
Event rule „Print“: interface, context and an example – how to react to this Nuclos event.
| Status |
|---|
| colour | Green |
|---|
| title | Updated: Jul 2026 |
|---|
|
| Status |
|---|
| colour | Grey |
|---|
| title | applies to Nuclos 4.2026.x |
|---|
|
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):
| Codeblock |
|---|
|
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 {
}
} |
| Info |
|---|
| title | 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
| Codeblock |
|---|
|
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
Server-side rules
Basics.
Open →
Server rule manager
Assign.
Open →
Rule execution order
Order.
Open →