|
发表于 2016-2-18 18:11:34
|
显示全部楼层
如下:action中对应的java中的定义
- public static int uniqueName(String name){
- String sql = "select count(AP_RQ) as countname from AP_RQ AP_RQ where AP_RQ.fName = '"+name+"'";
- Table table = KSQL.select(sql, null, "/appdemo/test/data", null);
- Iterator<Row> it = table.iterator();
- int i = 0 ;
- while (it.hasNext()) {
- Row r = it.next();
- BigDecimal conunt = (BigDecimal) r.getValue("countname");
- i = conunt.intValue();
- }
- return i;
-
- }
复制代码
data的onBeforeSave中action的调用
- Model.prototype.bizData1BeforeSave = function(event) {
- var data = this.comp("bizData1");
- var name = data.getValue("fName");
- var params = new biz.Request.ActionParam();
- params.setString("name", name);
- biz.Request.sendBizRequest({
- "context" : this.getContext(),
- "action" : "uniqueNameAction",
- "parameters" : params,
- callback : function(result) {
- if (result.state) {
- if (result.response !== 0) {
- alert("数据重复");
- event.cancel = true;
- }
- }
- }
- });
- };
复制代码 |
|