Create custom rule in project should include following steps:
1. Class structure construction.
Class structure means the class details which extends from Embed- and the class details which extends from Rule-.
Custom rule classes are extended from Rule- class. They are concrete classes and does not belong to a class group. The key name commonly have two items, pyClassName and ***Name, which will be saved into database. The Caption will show on the New form of custom rule.
Embed- classes are used for Property and Property Page. Rule- classes are used for the Custom Rules.
Every class has its own required properties. Finally, all the properties are bounded to custom elements in FormBuilder.
2. pyDefault rule definition.
A model named pyDefault must be built for every custom rule.
In pyDefault model, all properties for this custom rule should be initialized as “”, some special case, you can give a default value. No blank here, otherwise, the property you leave it blank will not exposed in Clipboard.
3. Rule-obj-list and listview definition.
List rule and ListView rule should be defined for every custom rule. It is used for the format of custom rules’ display or report. You can refer to other system rules’ List and ListView rule, just Save As is OK. List rule includes three instances as follows: List, pySearch and RuleList. ListView rule has a LookUpList instance.
4. Database configuration.
Create a new table which the columns are the same as pr4_rule, and this table should contain most of the Constrains, Indexes and Trigger like pr4_rule. Additionally, you have to add some columns for your custom rules, column name corresponding to your rule names. Than create a Data-Admin-DB-Table rule to map to this table. After these, the instances of custom rule will be stored in this table automatically.
5. Rule form definition.
Ok, after the steps above have been done. This key step will give you a good experience.
In Class rule’s Advanced tab, Create a Rule Form which the name is the same as custom rule class. In this Rule Form, you can customize your own rule by using FormBuilder.
In FormBuilder, key Elements in the list tree is rulename and pyClassname. The tabStrip can have many tabs, one tab can have many tabLayouts, and one tabLayout can have many tabElements. The tabElement has many Group type such as Group, Repeat, Group NonBound and so on. We just use Group and Repeat in commonly cases.
Data Bounding is important. It will help you to bind the data which fill from rule instance to Embed- class you just created. Group and Repeat are bound for Property Page and Property PageList. If you have not Page or PageList, just leave here blank and bind to element directly.
For example:
1. If there is a class structure Layout.FormID in your rule. Fill Layout to Group’s Propery, and fill FormID to Element’s Property.
2. If there is a class structure ScriptSrc(1).FormID in your rule. SciptSrc is a PageList Property. Just fill ScriptSrc to Repeat’s Propery, and fill FormID to Element’s Property.
3. If If there is a class structure ScriptSrc(1) in your rule. ScriptSrc is a ValueList Property. Jus fill ScriptSrc to Repeat’s Propery, and fill FormID to Element’s Property.
It means Data Bounding.
SmartPrompt is simple. You can just refer to other system rule.
Adding an event to use JavaScript to call an Activity, you can refer to the code of Data-Admin-ServicePackage rule. It uses the AJAX technology to achieve this purpose.
Something should be minded:
- When using FormBuilder to create custom rule. Add your web address such as ‘http://10.225.76.66:7001/’ to your trusted website first. Once you update the rule, Log off PRPC, and then clear Temporary Internet Files, and then Log in. Otherwise, there will be lots of JavaScript errors when creating instances. It’s important.
- Data-Admin-DB-Table specified table name is Case Sensitivity (Commonly, it is Low Case.).
- The database table for custom rule should include the Constrains (Primary), Triggers and Indexes like pr4_rule.
- In Rule-XUI-Obj-Form, you can find out the implementation of JavaScript functions which their names begin with ‘zUtil_’ acceding to this way: ‘zutilitiesrf.js’ -> ‘ruleformutilitymanager.js’ -> ‘ruleformutilitymanager.js’.
- In Rule-XUI-Obj-Form, when using FormBuilder, if you need some custom script functions, just create a file named ‘xxxScript.js’ in PRPC. You’d better not add any separated JavaScript in rule form HTML.
- In FormBuilder, when adding a Rule Class for Text Box SmartPrompt. The Form HTML can add a HTML property ISNS_CLASS=’’
- When you use Repeat function, JavaScript may help you to generate the same rows for you. But the elements IDs are also the same. So you cannot get a specific element of any row. At this time, you can refer to JavaScript method Object.parentElement and TableObject. rows(0).cells(0), just like ElementObj.parentElement.parentElement. rows(0).cells(0) == ElementObj.
- If you want to test that whether the data is bound to class structure, you may just save the rule instance and than refresh the rule, if the data is always exists, bounding is ok.