Making the Expander Conditional
Not all expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. and features should be applied to each element. Most expandersExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. only run when some option is defined or a certain setting is used. For this, we can use the isApplicable condition.
Testing the condition
A guide to test and implement the condition can be found in the developer hub: isApplicable Condition
Implementing the isApplicable condition
To implement the condition as an OGNL expression in the xml:
<isApplicable>dataElement.getOption('demo.includeSomeClass').defined</isApplicable>
Each element with options has the getOption(String optionTypeName) which will return an object with a value and isDefined()/isEmpty() methods.
Context Variables
The isApplicable condition shares most of its context variables with regular expanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. mapping, namely:
- the currently expanded element as an instance of its composite projectionProjectionA tailored subset of fields on a DataElement designed to encapsulate data for a specific technical or functional view.
- e.g.
dataElementis instance ofDataElementComposite
- e.g.
expansionContextfor the current element type and expanded element,- e.g.
expansionContextis instance ofDataElementExpansionContext
- e.g.
And convenience shortcuts:
- applicationApplicationThe overarching model container grouping all components, domain logic, and configurations for an enterprise solution.
- applicationInstance
- businessLogicSettings
- globalOptionSettings
- presentationSettings
- technicalInfrastructure
Note that you can access these elements by navigating through the model.
For example the following two conditions are the same (for a dataElement expanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact.):
<isApplicable>globalOptionSettings.enforceHttpMethod</isApplicable>
<isApplicable>dataElement.component.application.applicationInstance.globalOptionSettings.enforceHttpMethod</isApplicable>