globe with meridians Language: Deutsch · English

open book Event - Status change

Event rule „Status change“: 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 on a status change (before the change). It can be assigned to a status model.

Structure

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

package org.nuclet.lager; 

import org.nuclos.api.rule.StateChangeRule; 
import org.nuclos.api.context.StateChangeContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 

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

@Rule(name="Statuswechsel Lagerbestand", description="Statuswechsel Lagerbestand")
public class StatuswechselLagerbestand implements StateChangeRule {
    
	public void changeState(StateChangeContext context) throws BusinessException { 
    }
}

Context: StateChangeContext

The context StateChangeContext 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.StateChangeRule; 
import org.nuclos.api.context.StateChangeContext; 
import org.nuclos.api.annotation.Rule; 
import org.nuclos.api.exception.BusinessException; 

/** @name 
 * @description 
 * @usage 
 * @change 
*/
@Rule(name="BeauftragungPrüfen", description="Beauftragung prüfen")
public class BeauftragungPrüfen implements StateChangeRule {
	
	public void changeState(StateChangeContext context) throws BusinessException { 
 
		Auftrag neuerAuftrag = context.getBusinessObject(Auftrag.class);
 	
		if (neuerAuftrag.getBestellwert() == null)
			throw new BusinessException("Der Bestellwert darf nicht leer sein.");
	 
		if (neuerAuftrag.getKunde() == null)
			throw new BusinessException("Es wurde kein Kunde für diesen Auftrag hinterlegt.");
 
		if (neuerAuftrag.getAuftragsnr() == null)
			throw new BusinessException("Der Auftrag besitzt keine Nummer.");
 
	}
} 

Related pages

open book Server-side rules


Basics.

Open →

gear Server rule manager


Assign.

Open →

clipboard Rule execution order


Order.

Open →

  • Keine Stichwörter