globe with meridians Language: Deutsch · English

open book Event - Object generation

Event rule „Object generation“: 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 during an object generation (before saving). It can be assigned to a object generator.

Structure

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

package org.nuclet.lager; 

import org.nuclos.api.rule.GenerateRule; 
import org.nuclos.api.context.GenerateContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 

/** @name        
  * @description 
  * @usage       
  * @change      
*/

@Rule(name="Arbeitschritt Lager", description="Arbeitschritt Lager")
public class ArbeitschrittLager implements GenerateRule {

    public void generate(GenerateContext context) throws BusinessException { 
    }
}

Context: GenerateContext

The context GenerateContext 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 org.nuclet.company; 

import org.nuclos.api.rule.GenerateRule; 
import org.nuclos.api.context.GenerateContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 
import java.util.Collection;

/** @name        
  * @description 
  * @usage       
  * @change      
*/
@Rule(name="BestellungErstellen", description="BestellungErstellen")

public class BestellungErstellen implements GenerateRule {

    public void generate(GenerateContext context) throws BusinessException { 
        Collection<Anfrage> sourceObjects = context.getSourceObjects(Anfrage.class);
        
        int sumOfArticles = 0;
        
        for (Anfrage a: sourceObjects) {
            // How many articles are in this inquiry
            sumOfArticles += a.getAnfrageposition().size();
        }
        
        Bestellung targetObject = context.getTargetObject(Bestellung.class);
        targetObject.setKurzbeschreibung("Diese Bestellung umfasst " + sumOfArticles + " Artikelpositionen.");
        
    }
}

Related pages

open book Server-side rules


Basics.

Open →

gear Server rule manager


Assign.

Open →

clipboard Rule execution order


Order.

Open →

  • Keine Stichwörter