【JSP开源代码栏目提醒】:网学会员,鉴于大家对JSP开源代码十分关注,论文会员在此为大家搜集整理了“selectmenu_minglimin.jsp”一文,供大家参考学习!
<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="java.util.*,java.util.StringTokenizer ,java.text.*,oa.main.DealString,javax.swing.tree.DefaultMutableTreeNode,java.util.Hashtable"%>
<%@page import="oa.main.DealString"%>
<q id="this" align=left>
<table border="1" cellpadding="2" style="border-collapse: collapse; color:#FFFFFF" bordercolor="D0E7FF" width="95%" height="18" bgcolor="#007EAE">
<tr>
<td align="left" width="16%"> <b>选择版面</b></td>
</tr>
</table>
<%
oa.bean.MenuChildBean myBean = null;
oa.bean.MenuBean parentBean = null;
oa.bean.ArticleBean myArtBean = null;
try{
myBean =new oa.bean.MenuChildBean();
parentBean =new oa.bean.MenuBean();
myArtBean =new oa.bean.ArticleBean();
DealString ds=new DealString();
String uid=ds.toString((String)session.getAttribute("zgbh"));
int sub = 1;
int nItem = 0;
String outPrint = "";
String strmenu = "";
String strradio = "";
boolean showall = false;
int whichceng = 0;
String tHead1="<div style=\"display:none\" id=\"" ;
String tHead2="\"><table><tr>";
String tEnd="</tr></table></div>";
DefaultMutableTreeNode myTree = parentBean.buildMenuTree(uid);
DefaultMutableTreeNode root, currentNode, lastNode;
root = myTree;
outPrint = "选择版面";
%>
<!-- 处理根节点------------------------------------------------------------------- -->
<table border="1" cellpadding="2" style="border-collapse: collapse; color:#FFFFFF" bordercolor="D0E7FF" width="95%" height="18" >
<tr>
<td ><q class="MOUT" onclick=<%="\"Expand(0)\""%> style="cursor:hand;" ><font color="blue"><b><%=outPrint%></b></font></q></td>
</tr>
</table>
<!----------------------------------------------------------------------------- -->
<% if (root.getChildCount()!=0)
{
currentNode = (DefaultMutableTreeNode) root.getFirstChild();
sub++;
out.println(tHead1+nItem+tHead2);
while ((currentNode != null) && (currentNode != root))
{
if(sub==2)
outPrint = (String) ((Hashtable) currentNode.getUserObject()).get("MENU1");
if(sub==3)
outPrint = (String) ((Hashtable) currentNode.getUserObject()).get("MENU2");
if(sub==4)
outPrint = (String) ((Hashtable) currentNode.getUserObject()).get("MENU3");
if(sub>4)
outPrint = (String) ((Hashtable) currentNode.getUserObject()).get("MENUCHILD");
strmenu = (String) ((Hashtable) currentNode.getUserObject()).get("ID");
String menuname = "";
if(sub<=4)
{
parentBean.setID(Integer.parseInt(strmenu));
menuname = parentBean.toname();
}
else
{
myBean.setID(Integer.parseInt(strmenu));
Hashtable hashid4 = (Hashtable)myBean.getOneData();
Hashtable hashid3 = (Hashtable)myBean.getID3();
parentBean.setID(Integer.parseInt((String)hashid3.get("ID")));
menuname = parentBean.toname()+"\\"+(String)hashid4.get("MENUCHILD");
}
menuname = ds.Replace(menuname,"\\", "\\\\");
if(whichceng>=sub)
{
showall = false;
}
strradio = (String) ((Hashtable) currentNode.getUserObject()).get("Enabled");
if(!showall)
{
if(strradio!=null&&strradio.equals("True"))
{
showall = true;
whichceng = sub;
}
}
%>
<table border="1" cellpadding="2" style="border-collapse: collapse; color:#FFFFFF" bordercolor="D0E7FF" width="95%" height="18"><tr><td >
<%
//控制
for (int i = 1; i < sub; i++)
out.print(" ");
if ((currentNode.getChildCount()) != 0) {
nItem++;
%>
<!-- 处理有子节点的树--------------------------------------------------- -->
<q class="MOUT" style="cursor:hand;" onclick=<%="\"Expand("+nItem+")\""%> ><font color="blue"><%if(showall&&(sub>3)){%><input type=radio name=menuradio onclick="selectmenu('<%=strmenu%>',<%=sub%>,'<%=menuname%>');"><%}else{%> <%}%><b><%=outPrint%></b></font>
</q>
</td>
</tr></table>
<!-- ----------------------------------------------------------- -->
<%
out.println(tHead1+nItem+tHead2);
} else {
%>
<!-- 处理无子节点的叶--------------------------------------------------- -->
<q class="MOUT" style="cursor:hand;">
<font color="blue"><%if(showall&&sub>3){%><input type=radio name=menuradio onclick="selectmenu('<%=strmenu%>','<%=sub%>','<%=menuname%>');" ><%}else{%> <%}%><b><%=outPrint%></b></font>
</q>
</td>
</tr></table>
<!-- ----------------------------------------------------------- -->
<% }
if ((currentNode.getChildCount()) == 0) {
if ((currentNode.getNextSibling() == null)) {
//当前节点即没有子节点又没有兄弟节点,则返回父节点
if(showall&&whichceng==sub)
showall = false;
currentNode =
(DefaultMutableTreeNode) currentNode.getParent();
sub--;
out.println(tEnd);
if (currentNode == null)
continue;
}
} else {
//当前节点有子节点
currentNode =
(DefaultMutableTreeNode) currentNode.getFirstChild();
sub++;
continue;
}
lastNode = currentNode.getNextSibling();
if (lastNode != null) {
currentNode = lastNode;
} else {
while ((currentNode.getNextSibling() == null)&&(currentNode!=root)) {
currentNode =
(DefaultMutableTreeNode) currentNode.getParent();
sub--;
out.println(tEnd);
}
currentNode = currentNode.getNextSibling();
} //end if else
}
}
out.println("</Table></div>");
%>
</q>
<script language=javascript>
function Expand(id)
{
var divTag = document.all.tags("div");
var div = null;
div = divTag.item(id);
if(div!=null)
{
if(div.style.display=="none")
{
div.style.display = "";
}
else
{
div.style.display = "none";
}
}
}
Expand(0);
function selectmenu(strmenu,sub,menuname)
{
window.opener.document.all.txt_id1.value = strmenu;//版面ID
window.opener.document.all.txt_menu.value = menuname;//版面名称
if(sub<=4)
window.opener.document.all.txt_table.value = "1";//第一个表
else
window.opener.document.all.txt_table.value = "0";//第二个表
window.opener.document.all.txt_topic.value = "请重新选择版面";
window.opener.document.all.topicid.value = "0";
var num = menuname.indexOf("\\");
if(num == -1)
window.opener.document.all.whichtopic.value = menuname;
else
window.opener.document.all.whichtopic.value = menuname.substring(0,num);
window.close();
window.opener.focus();
}
</script>
<%}
finally{
if(myBean!=null)myBean.closeConn();
if(parentBean!=null)parentBean.closeConn();
if(myArtBean!=null)myArtBean.closeConn();
}
%>
上一篇:
selectmenu_liumei.jsp
下一篇:
让我掉下眼泪的