posts - 9,  comments - 1,  trackbacks - 0
            2006年10月25日
          <SCRIPT language=javascript1.2>
          function showsubmenu(sid)
          {
          whichEl = eval("submenu" + sid);
          if (whichEl.style.display == "none")
          {
          eval("submenu" + sid + ".style.display=\"\";");
          }
          else
          {
          eval("submenu" + sid + ".style.display=\"none\";");
          }
          }
          </SCRIPT>


          用法:

          <tr>
          ??????????? <td height="26" background="../image/menu.gif" id="menuTitle1" onClick="showsubmenu(1)" style="cursor:hand;">&nbsp;&nbsp;&nbsp;
          ??????????? <font color="#FF9900">■&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#FFFFFF"><strong>知識庫分類</strong></font>
          ??????????? </td>
          ????????? </tr>
          ????????? <tr>
          <td style="display:none" id='submenu1'>
          ???? <table cellspacing="0" align="center" width="100%">
          ??????????????? <tr>
          ????????????????? <td class="nav">· <a href="<%=request.getContextPath()%>/knowledge/knowledgeCategoryList.htm?order=list" target="mainFrame">編輯知識庫分類</a></td>
          ??????????????? </tr>
          ??????????????? <tr>
          ????????????????? <td class="nav">· <a href="<%=request.getContextPath()%>/knowledge/knowledgeCategoryList.htm?order=edit" target="mainFrame">新增知識庫分類</a></td>
          ??????????????? </tr>
          ????????????? </table>
          posted @ 2006-10-25 17:37 lovetq 閱讀(470) | 評論 (0)編輯 收藏
          在很多的列表中,后面的操作一欄會有刪除鏈接,并且會讓你確認。此處的代碼:?
          <a href='javascript:deleteCategory("<%=article.getId() %>")'>刪除</a>
          ?????

          javascript函數(shù)
          <script>
          ?function deleteCategory(articleId)
          ?{
          ??if(confirm('是否真的要刪除該記錄'))
          ???window.location='<%=request.getContextPath()%>/info/infoArticleEdit.htm?order=delete&articleId='+articleId;
          ?}
          </script>

          一些鏈接:
          <input class="button3" type=button value="返回" onclick="javascript:window.location='<%=request.getContextPath() %>/info/infoArticleList.htm'">

          <td>文件名:<a href='<%=request.getContextPath()%>/info/infoArticleEdit.htm?order=download&fileId=<%=accessory.getId() %>'><%=accessory.getFileExt() %></a>
          ?????
          <c:url value="........" />
          ??
          一些傳值
          <input type=hidden name=order value=save>
          <input type=hidden name=id value="<c:out value="${infoArticle.id}" />">
          <input type=hidden name=navId value="<%=request.getParameter("navId") %>">
          <input type=hidden name=fileCount value=1>
          posted @ 2006-10-25 16:32 lovetq 閱讀(181) | 評論 (0)編輯 收藏

          頁面代碼:
          <!--? 這個是顯示的多選框頁面 已有的角色要打勾,可以重新選擇角色-->
          <form action="<c:url value="/sys/userRolesEdit.htm"/>" method="post" >

          ????? <table class="grid" width="100%" cellspacing="1">
          ?????
          ??? <tr>
          ?????? <td colspan="6" class="title">
          ????????? 角色列表
          ?????? </td>
          ??? </tr>
          ??? <tr>
          ??? ? <td class="column"></td>
          ?????? <td class="column">角色ID</td>
          ?????? <td class="column">角色名</td>
          ?????? <td class="column">角色代碼</td>
          ?????? <td class="column">角色描述</td>??????

          ??? </tr>

          ??? <!-- 循環(huán)顯示列表userRoles的每一項,并判斷如果數(shù)據(jù)庫中已有的打勾<c:if test標簽正確才執(zhí)行中間的代碼-->
          ??? <c:forEach items="${roles}" var="item">????
          ???<tr>??????
          ???? <td>
          ???? <input type="checkbox" name="rolesId" <c:forEach items="${userRoles}" var = "selectedRoles">
          ???? <c:if test="${item.srolId == selectedRoles.srolId}">checked="true"</c:if></c:forEach>
          ????? value="<c:out value="${item.srolId}"/>" />
          ???? </td>
          ???
          ???? <td><c:out value="${item.srolId}"/></td>
          ??????? <td><c:out value="${item.srolName}"/> </td>
          ???????????????? <td><c:out value="${item.srolCode}"/></td>
          ???????????????? <td><c:out value="${item.srolDesc}"/></td>????????????????
          ???? <tr>???????
          ??? </c:forEach> ??
          ???
          ??? <tr>

          ?????? <td colspan="6" class="nav">&nbsp;
          ?????? ??? <input type="hidden" name="userID"
          ???value=<c:out value="${userInfo.suinId}"/>>
          ????? <input type="submit" class="button3" value="提交"/>
          ????? <INPUT type="button" class="button2" value="返回" onclick="history.back()" />
          ?????
          ?????? </td>
          ??? </tr>
          ?? </table>?
          ?? </form>

          控制器代碼:
          protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
          ??// TODO Auto-generated method stub
          ??
          ??Map result = new HashMap();
          ??
          ??SysUserinfo userInfo = null;
          ??????? String id = request.getParameter("userID");

          ??????? System.out.println(id);
          ??????? if (id != null && !id.equals(""))
          ??????? {
          ??????????? userInfo = (SysUserinfo) sysService.get(SysUserinfo.class,
          ??????????????????? new Long(id));
          ???????????
          ??????? }
          ??????? else
          ??????? {
          ???????????
          ??????? }
          ???????
          ??????? result.put("userInfo", userInfo);
          ??????? result.put("roles", sysService.getSupportData("SysRole", null));
          ??????? if (userInfo != null)
          ??????? {
          ??????? ?result.put("userRoles", sysService.getUserRoles(userInfo));
          ??????? }
          ???????
          ?
          ???????
          ??????? SysUserRole sysUserRole = null;
          ??????? SysRole sysRole = null;
          ??????? String roleId = null;
          ???????
          ??????? // 記錄父列表ID
          ??????? result.put("parentlistID", request.getParameter("parentlistID"));
          ??????? result.put("userInfo", userInfo);
          ????????
          ?????????//遍歷所有map里的key
          ??????? Iterator it = result.keySet().iterator();
          ??????? while (it.hasNext())
          ??????? {
          ??????????? String key = (String) it.next();
          ??????????? request.setAttribute(key, result.get(key));
          ??????? }
          ????????
          ?????????//這里就是從列表多選框傳過來的數(shù)值。根據(jù)name屬性獲得所有的value
          ??????? String[] rolesId = null;
          ??????? rolesId = request.getParameterValues("rolesId");
          ??????? System.out.println("------------------------" + rolesId + "-------------------");
          ???????
          ??????? if (rolesId == null || rolesId.equals(null))
          ??????? {
          ??????? ?return new ModelAndView(formView);
          ??????? }
          ???????
          ??????? else
          ??????? {?????
          ??????? ?List userRoles = (List)sysService
          ??????? ??.getUsersUserRoles(userInfo.getSuinId());


          ??????//先刪除數(shù)據(jù)庫中所有的,再插入所選的值
          ?????????for (int k = 0; k < userRoles.size(); k++)
          ??? ??{
          ??? ???SysUserRole userRole = (SysUserRole)userRoles.get(k);?? ???
          ??? ???sysService.delete(userRole);
          ??? ???
          ??? ??}
          ??????? ?
          ??????? ?for (int i = 0; i < rolesId.length; i++)
          ??????? ?{
          ??????? ??roleId = rolesId[i];
          ??????? ??
          ??????? ??sysRole = (SysRole)sysService.get(SysRole.class, new Long(roleId));
          ??????? ??sysUserRole = new SysUserRole();
          ??????? ??sysUserRole.setUser(userInfo);
          ??????? ??sysUserRole.setRole(sysRole);
          ??????? ??sysService.save(sysUserRole);?????? ?
          ??????? ?}

          ?????????//如果在###-servlet.xml配置文件中,successView不能傳遞參數(shù),可在這里直接有response導(dǎo)向別的頁面
          ?????????response.sendRedirect(request.getContextPath()
          ??????? ???+ "/sys/userRolesList.htm?userID=" + userInfo.getSuinId().toString());
          ??????? ?return null;
          ??????? }

          ?}


          posted @ 2006-10-25 09:27 lovetq 閱讀(1787) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 沈丘县| 巴林左旗| 玉树县| 久治县| 二连浩特市| 融水| 治多县| 玛纳斯县| 城口县| 盐边县| 禹州市| 鹰潭市| 伊宁市| 龙门县| 如东县| 大荔县| 六安市| 汉阴县| 富源县| 兴和县| 武陟县| 大渡口区| 清苑县| 涟水县| 荣成市| 临澧县| 井陉县| 定西市| 霍州市| 姜堰市| 金川县| 类乌齐县| 曲靖市| 大荔县| 九龙坡区| 贵港市| 新田县| 富裕县| 彰化市| 永胜县| 兰溪市|