Skip to content
This repository has been archived by the owner on Oct 6, 2022. It is now read-only.

Latest commit

 

History

History
144 lines (135 loc) · 5.93 KB

api_event.md

File metadata and controls

144 lines (135 loc) · 5.93 KB

Event Program

////////////////////////////////////////
//web/WEB-INF/efw/event/myEvent.js
////////////////////////////////////////
var myEvent={};
myEvent.service={
	max:10,
	message:'system is busy,please wait a while',
	retriable:true,
	interval:20,
};
myEvent.paramsFormat = { 
                                "#txt_teststring" : "display-name:Test String;max-length:10;",
                                "#txt_testnumber" : "format:#,##0.00;required:true;display-name:Test Number;min:-10.00;max:1,000.00",
                                "#txt_testdate"   : function(){
                                                        var date1=new Date();
                                                        var date2=new Date();
                                                        date2.setDate(date1.getDate()+6);
                                                        return "format:yyyy-MM-dd;required:true;display-name:Test Date;"
                                                               +"min:"+date1.format("yyyy-MM-dd")+";"
                                                               +"max:"+date2.format(,"yyyy-MM-dd")+";" ;
                                                    },
                                ... 
                            };
myEvent.fire         = function ( requestParams ) {
                                return (new Result()).alert("hello world! Your entries are correct.");
                            };

Event Variable

The event variable must be same to the event file name. In the sample, it is "myEvent".

Service Definition

myEvent.service = {
    max: 10,
    message:'System busy please wait.',
    retriable:true,
    interval:20,
};
Parameters Description Attention
max The max requests count can be execute at the same time. "max" is requried for events with service definition.
message the message when the max requests count is reached. "message" is optional.
retriable The event will try to re-execute automatically or not. The default value is false.
interval The interval for re-execution. The default value is 30 seconds. "interval" is enable only when "retriable" is true.

Params Format

myEvent.paramsFormat = {
                     selector1 : null,
                     selector2 : "checkStyle",
                     selector3 : function(){ return "checkStyle"; },
                   { selector4 : ... , },
                 [ { selector5 : ... , } ],
             };
To reference JQuery about the rules of selectors.
Type Description Normal Abnormal
selector : null To get a single input data from the client by the JQuery selector without input checking. If one html tag is matched to the selector, the value attribute or text attribute will be looked as the input data to the fire method. Error if multi tags are matched to the selector.
selector : "checkStyle" To get a single input data from the element matched by the JQuery selector with input checking. If the input data is matched to the check style, it will be used. Error if multi tags are matched to the selector.
Error if the input data is not matched the check style.
selector : function(){ return "checkStyle"; } To get a single input data from the element with input checking matched by the JQuery selector which is created by a function. If the input data is matched to the check style, it will be used. Error if multi tags are matched to the selector.
Error if the input data is not matched the check style.
selector : {...} To get several input datas stored in the element matched by the selector. If one element is matched to the selector, it will be used. And the selector will be as the context to the sub selectors. Error if multi tags are matched to the selector.
selector : [{...}] To get an array of input datas stored in the element matched by the selector. Multi elements matched to the selector will be as the context to the sub selectors. -

Check Style

ItemValueDescriptionError
display-nameStringThe element name which will be shown in the check error message.
max-lengthNumberThe max length for an element.MaxLengthOverMessage
formatStringThe number format or date format expected to an element.NumberIsReuqiredMessage or DateIsReuqiredMessage
minStringThe min (formatted) value to an element.MinOrMaxOverMessage or MinOverMessage
maxStringThe max (formatted) value to an element.MinOrMaxOverMessage or MaxOverMessage
requiredBooleanThe element is must or not.IsRequiredMessage
acceptStringThe extension file-names seperated by "," which will be accepted as uploading files. NotAcceptMessage

Fire Method

Event Return

If the event is called by web, the event return must be void or an instance of Result.
If the event is called by batch, the event return should be an instance of Batch.