- $().ready(function () {
- $.getJSON("getRecUserTree.action", function (result) {
- $.each(result.tree, function (i, field) {
- $("#cs").append("<li style=\"float:; margin-top:3px;margin-left:10px;\"><a href=\"#\" class=\"\" οnclick=\"aa(" + field.menuid + ");\">" + field.text + "</a></li>");
- //$("#mylx").append(" <option value="+field.menuid + ">" + field.text + "</a></li>");
- });
- });
- });
- <div id="cs" class="stuff"></div>
- public void getMenuTree(HttpServletRequest r, HttpServletResponse rp) {
- try {
- String t = "";
- SessionBean sb =(SessionBean)r.getSession().getAttribute(Function.sessionbean);
- String where = "";
- List<UserRecTreeBean> l = null;
- if ("NORMAL".equals(sb.getUsertype())) {
- where += " vf.activestatus = 1 AND vu.userid = '"
- + sb.getUserid() + "' and vf.imagepath=0";
- l = vfdi.getByUserRecTree(where);
- }
- JSONObject json = new JSONObject();
- if (l != null && l.size() > 0) {
- JSONArray arr = new JSONArray();
- for (UserRecTreeBean oo : l) {
- arr.put(new JSONObject(oo));
- }
- json.put("tree", arr);
- ResponseUtils.renderJson(rp, json.toString());
- } else {
- t = "";
- }
- ResponseUtils.renderJson(rp, json.toString());
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public List<UserRecTreeBean> getByUserRecTree(String where) throws SQLException, Exception {
- Connection con = getConnection();
- try {
- String sql="SELECT vf.menuid as id, vf.menuname as text, vf.menuid as menuid FROM vod_user vu LEFT JOIN vod_menu vf ON vu.menuid = vf.menuid WHERE "+where;
- ResultSetHandler<List<UserRecTreeBean>> rsh = new BeanListHandler<UserRecTreeBean>(UserRecTreeBean.class);
- System.out.println(sql);
- return query(con, sql, rsh);
- } catch (SQLException e) {
- e.printStackTrace();
- } finally {
- Close(con);
- }
- return null;
- }
- package com.avcon.form;
- public class UserRecTreeBean {
- private String id;
- private String text;
- private String menuid;
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- public String getText() {
- return text;
- }
- public void setText(String text) {
- this.text = text;
- }
- public String getMenuid() {
- return menuid;
- }
- public void setMenuid(String menuid) {
- this.menuid = menuid;
- }
- }
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>