Skip to content

Latest commit

 

History

History
154 lines (141 loc) · 6.24 KB

api_webevent.md

File metadata and controls

154 lines (141 loc) · 6.24 KB

Web Event

////////////////////////////////////////
//web/WEB-INF/efw/event/myWebEvent.js
////////////////////////////////////////
var myWebEvent={};
myWebEvent.service={
	max:10,
	message:'system is busy,please wait a while',
	retriable:true,
	interval:20,
};
myWebEvent.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")+";" ;
                                                    },
                                "#txt_password"   :"secure:true",//the secure value will be encoded before sending.
                                ... 
                            };
myWebEvent.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 "myWebEvent".

Service Definition

myWebEvent.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

myWebEvent.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
secureStringThe element value should be encoded or not.

Fire Method

Event Return

The event return must be void or an instance of Result.

i18n Message Key

For muti-language, you can set mesage keys in next items. To see details in the Sample.
  • display-name in check style.
  • any string value in Result object.