Forum Discussion
FICO
17 years agoCommunity Manager
valueholder validations in RMA
valueholder validations in RMA
We have ruleset template which has a rule template. The rule template contains a string value holder called "Rule Name" which is exposed in the RMA. The requirements are:
1. Restrict the size of the input string to say 10 characters. In the display format section, I tried to set the field size but it had no effect either on the textbox size or the size of the input string. How can we restrict the size or range of an input to a value holder with in RMA. 2. The "Rule Name" supplied by the users has to be unique. I tried duplicating the name and noted that at compile time, advisor does give a warning about duplicate rule names, but I want the warning/prompt with in RMA. Any ways to achieve this? Thanks,Ram.
15 Replies
- FICOCommunity Manager
Hi Ram,
As far as I know, there are 1.5 ways to achieve your first requirement (1 solution and 1 "band-aid" ):
- Create your own Custom Provider. A simple solution would be to subclass the NdStringProvider, which is what you are currently using for your Rule Name value holder. Providers have a method that can be overridden for validation purposes, in which you can throw an NdTemplateException if the value does not satisfy provider constraints.
- If you do not want to create a Custom Provider: Use a conditional block to display a validation error when the length of the string exceeds 10 characters. This will not give you the restriction on the string, but it will signal the error/constraint violation to the user.
I would probably also go for a Custom Provider for your second requirement. Again, in the validation method, you have access to the provider context (NdProviderContext), which gives you access to the entire instance you are a part of. It is actually quite simple to traverse the instantiation model and extract values from it, so you could gather all Rule Name values in a collection and signal an error for duplicates.
Maybe someone from Fair Isaac have other, less complicated solutions, but these are the options I would investigate.
Regards,
Jostein
- FICOCommunity Manager
Hi Jostein,
Thanks for your reply. Since the first option you suggested solves both my needs, I wanted to try that. I read online help on custom providers and also the example. However, I am sure if the java class has to be coded outside the Advisor IDE, since I didn't find a way to do it in the IDE. I am guessing that the custom provider would be of "generic" type. Also, the Generic provider does not have a browse / drop down button to select the class.
I am new to Blaze, so I appreciate your patience with my questions and if possible, a more detailed explanation of how to implement your first option.
Thanks,
Ram.
- FICOCommunity Manager
You have to implement the custom provider outside of the IDE. If you are developing a Java application, that means an external Java class that subsequently have to be on the class path of both Builder and your RMA. If you are developing a .Net application, you create a .Net class (C#, VB, etc) that you register in Builder.
If, for example, you are developing a Java application, I would suggest that you create a separate jar file containing providers for your application. You need to reference innovator.jar and AdvCommon.jar at least, possibly also AdvisorSvr.jar, for the jar file containing the custom provider.
As you are basically just capturing a string value from the user, subclass the com.blazesoft.template.engine.provider.NdStringProvider. Here you can override just the necessary methods, in your case that might be only the method for instantiation value validation. You might also do the same check in convertFromDisplayValue, but you will just have to test a little to see what gives you the best results.
The "are there more names like this"-test is a bit more complicated than the length-test, so start with just validating length. When that works, and you are hungry for more, you can try to tackle the rest
To register your custom provider implementation as a generic provider inside builder, just paste the entire class name into the space beneath the provider (logical) name. That's both the package path and the class name, as Builder/the RMA does a Class.forName() (or similar) to instantiate it.
HTH,
Jostein
- FICOCommunity Manager
Thanks for the detailed explanation. Just one more question, for now that is (http://blaze.i.lithium.com/i/smilies/16x16_smiley-wink.gif). I am not able to find the NdStringProvider class in the javadoc. The doc I am refering is <blaze root>\Advisor66\doc\api\innovator\index.html. Also, are there any reference guides on FI website? Thanks!
- FICOCommunity Manager
You will find the reference docs under
- <blaze root>\Advisor66\doc\html\contents.html (html version)
- <blaze root>\Advisor66\doc\pdf (pdf version)
I haven't seen anything on the FI website, but then again, I haven't really looked for it. The local resources are very good.
The API documentation is the weakest point with Blaze Advisor, unfortunately. I haven't seen the NdStringProvider in the API docs either, but I have subclassed it, so it is entirely doable. It is also mentioned in the reference docs that the existing providers can be subclassed.
If you are using an IDE for your Java development, it will assist you with the class hierarchies and what not, so that will not be a problem. For your validation purposes, just see the API documentation on the NdTemplateValueProvider. That should be sufficient for your first implementation. There are also some Custom Provider API examples in the reference docs/example repositories. These include source code, so that you have something to look at.
Regards,
Jostein
- FICOCommunity Manager
Hey i am also facing similar problem...please suggest me something other than Custom Provider...
Like on click we can call some JS function.Can be done.Please correct me
Regards,
Archu
- FICOCommunity Manager
The HTML that gets generated for input controls include an empty declaration of the onchange-attribute. It seems like this is something that FI has thought about, but I have never used this myself.
I guess you could create an extension to the RMA that registers a JavaScript change listener on selected controls, but this must be confirmed by FI. An example would be nice here (hint, hint Fair Isaac forum members (http://blaze.i.lithium.com/i/smilies/16x16_smiley-happy.gif))
You should be aware, however, that validation in a provider implementation will be a server validation, and it will guarantee that the instantiation model is valid according to the rules implemented in the provider. A JavaScript hook in the RMA will not give that same guarantee, so it is not a complete solution.
Regards,
Jostein
- FICOCommunity Manager
Hi all,
i would like to give small example done with the use of JS function
Well the scenario was that there are 2 valueholder named A and B which contains some values each.. now i have third valueholder named C. i wanted that C should be A+B.(Values A and B holded should come in valueholder C).
for example.. A = Hi and B=2 so i want C=Hi+2.
Here i placed the valueholders the way i want. C=A+B and generated the RMA. after the RMA got generated i did View Source and noted out the ID's or NAMES of A,B and C valueholders. Then i came back in Blaze and wrote javascript where i called the function and wrote this function in Jsfuntion.js file of blaze. I also did some screen data vallidations also in the code.
But here i would say, you should have the permission of FI guys.(We had (http://blaze.i.lithium.com/i/smilies/16x16_smiley-happy.gif))
Hope this helps.
Regards,
Archu
- FICOCommunity Manager
Hi Jostein,
I created a custom provider extending NdStringProvider and overrode validateInstantiationValue method. It works on the length check on the second arg "instantiationValue", but there is an additional challenge. Here is hierarchy in my project
RuleSetTemplate
| | ruleVH (Display Name -- areallylongdisplayname, stores the instances of RuleTemplate below) RuleTemplate | | ruleNameVH (edits are needed on these values, say "rule1", "rule2" etc.) When the user adds a new rule by clicking on blaze generated "<Add areallylongdisplname>" link, validateInstantiationValue method is invoked with a value of "areallylongdisplname1" and this fails the length test causing an exception. How can I restrict the validation to just the values with in ruleNameVH?Thanks in advance.
- FICOCommunity Manager
So, what you are seeing is that the display name of the value holder holding the rule template is used as the rule name when new rules are added?
Interesting challenge
The first two things that come to mind are;
- Provide a default value in the provider. This can be done by implementing the interface com.blazesoft.template.engine.NdProvidesDefaultValue. That way your rule name would have ha default value (obviously) when the rule is instantiated, which might help.
- Check for, and ignore, the display name used for the rule value holder. This isn't very elegant, especially if you hard code it in the provider. An alternative would be to provide the text to ignore as an argument to the provider (implement the com.blazesoft.template.engine.provider.NdDesignProvider interface).
I would probably try number 1 first, as that is the least invasive method.
If none of those works, you could also try wrapping the rule template in a ruleset items template. That way the display name of the value holder will not be used as the rule name, which in turn will not give you that validation error. On the other hand, that will probably mean that you will not see the rule name in the list of items that the user creates, which is bad. Yeah -- all in all I would still go for number 1 (http://blaze.i.lithium.com/i/smilies/16x16_smiley-wink.gif)
Regards,
Jostein
Related Content
Related Content
How to make cuts added in a preIntsol callback globally valid (root node) instead of local to the current subtree?
I'm using the Xpress Optimizer Java API (com.dashoptimization, Xpress 9.4) to solve a MIP with lazy constraints that are generated dynamically. My constraints are all globally valid — they are not lo...2 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread31Views0likes2Comments