Written by

Senior Software Engineer
MOD
Question Ashok Kumar T · Sep 28, 2025

InitialExpression Not Working in %CSP.Page Subclass

Hello Community

The InitialExpression keyword values does not to set default values for properties in classes that extend %CSP.Page, unlike in other class types such as %Persistent or %RegisteredObject, where it works as expected during object instantiation (typically via %New()).

  1. Is %CSP.Page instantiated using %New() under the hood, or does it use a different initialization mechanism?
  2. Are there specific limitations or behaviors in CSP pages that prevent InitialExpression from working as expected?

Thank you!

Product version: IRIS 2025.1
$ZV: IRIS for Windows (x86-64) 2025.1 (Build 223U) Tue Mar 11 2025 18:18:59 EDT

Comments

DC AI Bot · Sep 28, 2025 Bot

The InitialExpression keyword works for setting initial values during object instantiation via %New() in certain types of classes, such as %Persistent, %RegisteredObject, etc., but this behavior does not apply consistently to %CSP.Page or its subclasses. %CSP.Page utilizes specific mechanisms for customization and instantiation, which differ from standard object creation through %New()[1][2][3].

Key points to consider:

  1. Initialization Mechanism: %CSP.Page class is designed for web-based processing, with lifecycle methods like OnPage(), OnPreHTTP(), and OnPostHTTP() controlling request and response handling rather than relying on object instantiation semantics from %New()[3][2].

  2. Property Initialization: For most applications, properties in %CSP.Page are set during request handling or by explicitly overriding lifecycle methods. Using parameters or configuration settings might be more effective to achieve default values during response construction [3][5].

  3. Alternative Callbacks for Initialization: Override lifecycle methods like OnPreHTTP() or OnPage() within your subclass of %CSP.Page to implement default value assignments or initialization logic explicitly [2].

For further details regarding limitations or behaviors specific to %CSP.Page, you can consult its related documentation on callbacks, lifecycle management, and property interactions [2][5][6].

Sources:

0
Robert Cemper · Sep 28, 2025

Simplified:  %CSP.Page is a collection of methods and event handlers without any own properties.
Related data are kept outside in %CSP.Request and %CSP.response.
But you may mimic InitialExpressions by using PARAMETERS 

0
Julius Kavay · Sep 28, 2025

My guess is, because abstract classes (%CSP.Page is an abstract class) can't be instantiated, your subclass lacks the generator methos for property initialisation.

But there is a simple solution:

Class Your.Page Extends (%RegisteredObject, %CSP.Page)
{
Property Name As%String [ InitialExpression = "Joe" ];
}

Well, the world is right again

set page=##class(Your.Page).%New()
write page.Name --> Joe
0
Ashok Kumar T  Sep 28, 2025 to Julius Kavay

Hello @Julius Kavay 

Thanks for pointing that out — you're absolutely right. The generator method for property initialization is missing. However, we are able to create an instance of %CSP.Page

0
Julius Kavay  Sep 28, 2025 to Ashok Kumar T

Oh yes, you are able to create an instance of

Class Your.Page Extends%CSP.Page
{
Property Name As%String [ InitialExpression = "Joe" ];
}

class because the inheritance goes as follows:
Your.Page <-- %CSP.Page <-- %Library.Base <-- %Library.SystemBase
and the %Library.SystemBase donates you the %New() method.

0