Forum Discussion
FICO
13 years agoCommunity Manager
RMA - Generic Recursive Template
RMA - Generic Recursive Template
In the RMA there is a way to expose your object model to allow the users to add condition's to each rule they create by drilling down into the object model.
I have done this before however cannot remember the exactly how to set this up correctly.
Basically I want the user to be able to select the first lot of class properties from the 'top most' class which (when selecting a complex type within this class) would recuse and show the next lot of class properties until the terminating statement of property would show the is equal to value.
eg: obj.obj.... obj.prop...
This is actaully a challenge question within the RMA training book. but I cannot remember how I did it.
Currently I have the following: Templates
- Ruleset Template [Ruleset Template]
- Rule Template [Rule Template]
- Condition Template [Code Template]
- Operation Template [Code Template]
Else Supply the Operation Template which simply just provides a Property Type, Type Operator and a Type Value for the user to select.
The Problem I’m having is when It recurses it doesn’t seem to push the Arguments down the recursion even though I have specified it too in the subTemplateArgument overrides. Any help here appreciated.
5 Replies
- FICOCommunity Manager
Alright this is a BUMP!...
But I also want to add some more information:
At a basic level, the only way to get a list of Properties is through the Class Properties provider, but then I cannot create a recursion with this provider when the user selects the complex type
I’ll explain what I have done so far:
Generic Ruleset Template [ Generic Template]
VH - Generic Rule Template [Rule Template] VH – RecursiveTemplateList [Template List Provider] NormalTemplateList [Template List Provider] PropertyCodeTemplate [Code Template] ObjectCodeTemplate [Code Template] NormalTemplateList [Template List Provider] Recursive Code Template [Code Template] NormalTemplateList [ Template List Provider] RecursiveTemplateList [ Template List Provider]This setup contains 2 recursive structures. 1 being the Template Lists (see recursive template list is inside the recursive template list) and the other being the Object Template (inside the Normal Template List)
This setup gives me the ability to recurse when the user wants to add multiple conditions…
Now at the moment my Choices in the ‘NormalTemplateList’ drop down is limited to what I put in the Template list and the template display names.
What I want instead is basically the Class provider displaying all the properties of and class (including the complex types) and when they select an object that is a complex type (not an integer, bool, string etc), then I want it to recurse and therefore give me an extra drop down with all of the selected's properties and so traverse down the object model (if the user selects it) until you hit the lowest object in the model which would have basic types and then cannot recurse.
My problem is that With this technique I have to use a Template list provider and the display names take the place in the drop down list. If I use a Class Properties Provider (to display the properties) I cannot get it to recurse without causing a circular reference.
Can you suggest the correct structure to get Object.Object.property
- FICOCommunity Manager
You have to work around circular references by adding an "uneccesary" extra level of template. Eg. you design it something like this:
TopLevelPropertiesTemplate (Here you select the initial class):
classVH [Exactly 1]: Classes provider
propertyVH [Exactly 1]: Class properties provder,
propertyClass [Exactly 1]: Property Type Provider (dynamic argument override: classVH, propertyVH),
subProperty [0 or 1]: SubPropertyTemplate1 (dynamic argument override: propertyClass)
SubPropertyTemplate1 (recursive template):
parentClass [single argument]: Class provider (count: single Argument)
propertyVH [Exactly 1]: Class Properties provider (dynamic argument override: parentClass)
propertyClass [Exactly 1]: Property Type Provider (dynamic argument override: parentClass, propertyVH)
subProperty [0 or 1]: SubPropertyTemplate2 (dynamic argument override: propertyClass)
SubPropertyTemplate2 (recursive template):
parentClass [single argument]: Class provider (count: single Argument)
propertyVH [Exactly 1]: Class Properties provider (dynamic argument override: parentClass)
propertyClass [Exactly 1]: Property Type Provider (dynamic argument override: parentClass, propertyVH)
subProperty [0 or 1]: SubPropertyTemplate1 (dynamic argument override: propertyClass)
This will not take care of properly avoiding exposing subproperties templates when it's a simple type, for that you probably need to create a conditional block in each template checking the propertyClass string against simple type strings. Or maybe theres a smarter way to do it by utilizing the properties filter functionality of the Class properties provider, and/or restructuring the templates.
- FICOCommunity Manager
Alright I have tried your solution and I'm convinced this structure is right. However Im having some problem:
I dont have to specify [0 or 1] for the subTemplates as I dont want to make the user have to click 'add sub property'. So I changed it to Exactly 1. This should in theory work. However I cannot see my Dynamic Overrides coming through to the subTemplate1 which is then giving me an error:
[Argument 'property' missing for provider 'com.blazesoft.template.repository.provider.NdPromSrlClassPropertyTypeProvider' (defined in template '/PropertyTypeProvider') invoked from value holder 'propertyTypeVH' of template 'SubPropertiesTemplate1']
This is all because the ClassArg (or in your emample the parentClass) isn't being passed down the template through the Dynamic override as it should. Why is this??
- FICOCommunity Manager
If you make them "exactly 1", they will create a recursion which will lead to either invalid arguments when the property is a native type, or possibly endless loop depending on the object model and default selected properties.
You need to be able to control when the recursion stops.
For debugging purposes you can add placeholders for both "outgoing arguments" and "incoming arguments" in the templates' display part.
Be sure that for outgoing arguments from PropertyTypeProvider are recieved as incoming arguments with the ClassProvider. I've tested the example and it works.
- FICOCommunity Manager
Yes this is true however I dont want to give the user control over clicking <add new property> link which also puts everything on a new line.
Using this method do you know a way to get everything on 1 line?
Is there another way of doing all of this besides using this circular reference with a [0 to 1] count?
Related Content
Related Content
- 0Views0likes3Comments