|
楼主 |
发表于 2015-5-19 07:32:53
|
显示全部楼层
本帖最后由 biyaooo 于 2015-5-19 18:27 编辑
后端利用Baas添加的 queryUserInfo动作代码- private static void queryUserInfo(ServletRequest request, ServletResponse response) throws SQLException, IOException, NamingException {
- // 参数序列化
- JSONObject params = (JSONObject) JSONObject.parse(request.getParameter("params"));
- // 获取参数
- Object columns = params.get("columns"); // 列定义
- Integer limit = params.getInteger("limit"); // 分页查询的行数
- Integer offset = params.getInteger("offset"); // 分页查询的行偏移
- String username = params.getString("username"); // 分页查询的行数
- String password = params.getString("password"); // 检索关键字
- //System.out.println(password);
- // 存放SQL中的参数值
- List<Object> sqlParams = new ArrayList<Object>();
- // 存放SQL中的过滤条件
- List<String> filters = new ArrayList<String>();
-
- filters.add("username = ? and password =?");
- sqlParams.add(username);
- sqlParams.add(password);
-
- Table table = null;
- // 获取数据源连接
- Connection conn = Util.getConnection(DATASOURCE_BLSHOPAPP);
- try {
- // 执行单表数据查询,返回Table
- table = Util.queryData(conn, TABLE_APP_USER, columns, filters, "fID DESC", sqlParams, offset, limit);
- } finally {
- // 必须关闭数据源连接
- conn.close();
- }
- // 输出Table做为返回结果,这里会自动转换为Table的JSON格式
- Util.writeTableToResponse(response, table);
- }
复制代码
通讯录加载对应的JS代码 Content3.js
- Model.prototype.addresslistDataCustomRefresh = function(event){
- var data = event.source;
- //alert(Baas.getDataColumns(data));
- // 构造请求参数
- var params = {
- // 列定义
- // "columns" : data.getColumnIDs(),
- // 应从前端传入完整列定义(Baas.getDataColumns(data)), 以解决oracle等数据库不区分date、time、datetime,导致的数据格式转换问题;
- // 服务端兼容了以前只传入列名字符串(data.getColumnIDs())的写法,但是已不再推荐。
- //"columns" : Baas.getDataColumns(data),
- // 分页信息 - 行数
- "limit" : event.limit,
- // 分页信息 - 行偏移
- "offset" : event.offset,
- // 检索关键字
- "search" : this.getElementByXid("addressInput").value
- };
- // 请求成功后的回调方法
- var success = function(resultData) {
- // 通过event.options.append判断数据是否增量加载
- var append = event.options && event.options.append;
- // 加载返回数据到data
- data.loadData(resultData, append);
- };
- // 发送请求
- Baas.sendRequest({
- "url" : "/blshop", // servlet请求地址
- "action" : "queryAddressList", // action
- "params" : params, // action对应的参数
- "success" : success // 请求成功后的回调方法
- });
- };
-
复制代码
通讯录的代码,我的程序分了4个Content,我只把通讯录里面Content的代码贴出来
Content3.w
- <div class="x-contents-content" xid="content4"><div component="$UI/system/components/justep/panel/panel" class="x-panel x-full" xid="panel3">
- <div class="x-panel-top" xid="top3">
- <div component="$UI/system/components/justep/row/row" class="x-row" xid="row3">
- <div class="x-col" xid="col15">
- <div class="input-group" component="$UI/system/components/bootstrap/inputGroup/inputGroup" xid="inputGroup2">
- <input type="text" class="form-control" component="$UI/system/components/justep/input/input" xid="addressInput" onChange="{operation:'addresslistData.refresh'}"></input>
- <div class="input-group-btn" xid="div6">
- <a component="$UI/system/components/justep/button/button" class="btn x-black btn-only-icon" label="button" xid="button10" icon="icon-android-search" onClick="{operation:'addresslistData.refresh'}">
- <i xid="i3" class="icon-android-search"></i>
- <span xid="span3"></span></a> </div> </div> </div> </div> </div>
- <div class="x-panel-content" xid="content7">
- <div class="x-scroll" component="$UI/system/components/justep/scrollView/scrollView" xid="scrollView1">
- <div class="x-content-center x-pull-down container" xid="div7">
- <i class="x-pull-down-img glyphicon x-icon-pull-down" xid="i16"></i>
- <span class="x-pull-down-label" xid="span5">下拉刷新...</span></div>
- <div class="x-scroll-content" xid="div16">
- <div component="$UI/system/components/justep/list/list" class="x-list" xid="list1" data="addresslistData" limit="-1">
- <ul class="x-list-template" xid="listTemplateUl1">
- <li xid="li1">
- <div component="$UI/system/components/justep/row/row" class="x-row" xid="row2" style="padding:0px">
- <div class="x-col" xid="col12">
- <div component="$UI/system/components/justep/labelEdit/labelEdit" class="x-label-edit" xid="labelOutput1" style="margin:0px">
- <label class="x-label" xid="label2"><![CDATA[姓名:]]></label>
- <div component="$UI/system/components/justep/output/output" class="x-output x-edit" xid="output5" bind-ref="ref('name')"></div></div></div>
- <div class="x-col" xid="col13">
- <label xid="label5"><![CDATA[电话:]]></label>
- <a xid="a1" bind-text="ref('phone')" data-bind="attr:{href:'tel:'+val('phone')}"><![CDATA[]]></a></div>
- </div>
- <div component="$UI/system/components/justep/row/row" class="x-row" xid="row5">
- <div class="x-col" xid="col16" style="padding:0px;border-bottom-style:dashed;border-bottom-width:1px;border-bottom-color:#15800D;"><div component="$UI/system/components/justep/labelEdit/labelEdit" class="x-label-edit" xid="labelOutput3" style="margin:0px">
- <label class="x-label" xid="label4" style="background-color:transparent;"><![CDATA[通讯地址:]]></label>
- <div component="$UI/system/components/justep/output/output" class="x-output x-edit" xid="output7" bind-ref="ref('address')"></div></div></div>
- </div></li> </ul> </div>
- </div>
- <div class="x-content-center x-pull-up" xid="div5">
- <span class="x-pull-up-label" xid="span17">加载更多...</span></div> </div> </div> </div></div>
复制代码
|
|