您好,登錄后才能下訂單哦!
最近在做一個(gè)頁(yè)面是要在父頁(yè)面中顯示出一個(gè)彈出頁(yè)面顯示子頁(yè)面的內(nèi)容,搞了半天終于成功了。一直在寫(xiě)server端代碼,前臺(tái)不怎么熟,一開(kāi)始搞得焦頭爛額 ,以后還是要多學(xué)習(xí)前臺(tái)的知識(shí),不多說(shuō)直接上代碼。
add.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加資源</title>
<link href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-all.css"
rel="stylesheet" type="text/css" />
<link href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-form.css"
rel="stylesheet" type="text/css" /><!--
<script src="<%=basePath%>lib/jquery/jquery-1.3.2.min.js" type="text/javascript"> </script>
<script src="<%=basePath%>lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerDialog.js"
type="text/javascript">
</script>
<script
src="<%=basePath%>lib/jquery-validation/jquery.validate.min.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/jquery-validation/jquery.metadata.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/jquery-validation/messages_cn.js"
type="text/javascript">
</script>
-->
<script src="<%=basePath%>lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
<link href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-form.css" rel="stylesheet" type="text/css" />
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerButton.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="<%=basePath%>lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
<link href="<%=basePath%>admins/css/validate.css" type="text/css" rel="stylesheet" />
<link href="<%=basePath%>css/validate.css" type="text/css"
rel="stylesheet" />
<link href="<%=basePath%>css/main.css" type="text/css"
rel="stylesheet" />
<script src="<%=basePath%>jslib/validate_template.js"
type="text/javascript">
</script>
<script type="text/javascript">
var result = null;
$(function() {
//$("#resName").ligerTextBox();
//$("#resName").ligerGetTextBoxManager().setDisabled();
$("#types").ligerComboBox();
});
//獲取父節(jié)點(diǎn)
function openFathherR() {
var parentId = $("#parentId").val();
var randomTemp = Math.random();
result = $.ligerDialog.open( {
type : 'post',
url : 'parentTree_menuTreeAction.action?parentId=' + parentId,
width : 500,
height : 400,
isResize : true,
title : '資源列表',
buttons : [ {
text : '確定',
onclick : f_importOK
}, {
text : '取消',
onclick : f_importCancel
} ]
});
}
function openFathherR1() {
$.ligerDialog.open( {
url : 'list1.jsp',
height : 500,
width : 1000,
isResize : true,
title : '資源列表',
buttons : [ {
text : '確定',
onclick : f_importOK
}, {
text : '取消',
onclick : f_importCancel
} ]
});
}
//確定引入
function f_importOK(item, dialog) {
//調(diào)用子頁(yè)面list。jap中的方法
var result = dialog.frame.f_select();
if (!rows)
{
alert('請(qǐng)選擇行!');
return;
}
for( var i=0;i<result.length;i++){
if (result[i] != undefined) {
$("#parentId").val(result[i].rid);
$("#parentName").val(result[i].url);
} else {
$("#parentId").val("");
$("#parentName").val("");
}
}
/*if (result != undefined) {
$("#parentId").val(result.rid);
$("#parentName").val(result.url);
} else {
$("#parentId").val("");
$("#parentName").val("");
}*/
dialog.close();
}
//取消引入
function f_importCancel(item, dialog) {
dialog.close();
}
function resetForm() {
window.location.href = "add.jsp";
}
</script>
</head>
<body >
<s:if test="${not empty message}">
<script>
var manager = $.ligerDialog.waitting("${message}");
setTimeout(function() {
manager.close();
}, 1000);
</script>
</s:if>
<form name="form1" method="post" id="form1"
action="add_resources.action" >
<table border="0" cellpadding="6" cellspacing="2" align="center"
id="customers">
<tr>
<td>
資源名稱(chēng):
</td>
<td align="left" class="l-table-edit-td">
<input name="resource.name" id="resName" type="text"
maxlength="30"
onkeyup="value=value.replace(/[\'\;\,\@\#\$\%\^\&\*\+\.\`]/g,'')"
class="inputline" />
<a >*</a>
</td>
<td align="left"></td>
</tr>
<tr>
<td align="left">
資源URL:
</td>
<td align="left" class="l-table-edit-td">
<input name="resource.url" type="text" id="url" class="inputline"
maxlength="100" />
<a >*</a>
</td>
<td align="left"></td>
</tr>
<tr>
<td>
資源父節(jié)點(diǎn):
</td>
<td>
<input name="resource.parentId" type="hidden" id="parentId"
readonly="readonly" class="inputline" />
<input name="parentName" type="text" id="parentName"
class="inputline" />
</td>
<td align="left"></td>
</tr>
<tr>
<td>
資源類(lèi)型:
</td>
<td align="left" class="l-table-edit-td">
<select name="resource.types" id="types">
<option value="menu">
菜單
</option>
<option value="opt">
操作
</option>
<option value="module">
模塊
</option>
</select>
</td>
<td align="left"></td>
</tr>
<tr>
<td>
資源描述:
</td>
<td>
<textarea id="desc" name="resource.description" rows="3"
class="textarea" class="textarea"
maxlength="140"></textarea>
</td>
<td align="left"></td>
</tr>
</table>
<br>
<p align="center">
<input type="submit" value="提交" class="input2" />
<button type="button" class="input2" onclick="resetForm()">
重置
</button>
</p>
</form>
</body>
</html>
list1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>資源列表</title>
<link href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-all.css"
rel="stylesheet" type="text/css" />
<link rel="stylesheet"
href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-grid.css"
type="text/css"></link>
<link rel="stylesheet"
href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-form.css"
type="text/css"></link>
<link rel="stylesheet"
href="<%=basePath%>lib/ligerUI/skins/Aqua/css/ligerui-common.css"
type="text/css"></link>
<link href="<%=basePath%>css/main.css" rel="stylesheet"
type="text/css" />
<script src="<%=basePath%>lib/jquery/jquery-1.3.2.min.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/core/base.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerGrid.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerDialog.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerComboBox.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerButton.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerResizable.js"
type="text/javascript">
</script>
<script src="<%=basePath%>lib/ligerUI/js/plugins/ligerDateEditor.js"
type="text/javascript">
</script>
<style type="text/css">
.showTit {
background: url(../../lib/ligerUI/skins/icons/communication.gif);
background-repeat: no-repeat;
line-height: 25px;
padding-left: 25px;
font-weight: bold;
border-bottom: 1px solid #ccc;
}
.showTab {
line-height: 25px;
text-align: left;
}
.inputline {
border: 1px solid;
border-color: #BFDBF1;
height: 18px;
width: 150px;
}
#show {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
<script type="text/javascript">
function confirm_delete(roleId, roleName) {
$.ligerDialog
.confirm(
'確認(rèn)是否刪除?',
function(type) {
if (type) {
window.location.href = 'delete_rolesAction.action?method=delete&roleId='
+ roleId + '&roleName=' + roleName;
}
});
}
var grid;
$( function() {
//角色數(shù)據(jù)
var CustomersData = {};
CustomersData.Rows = [<%=request.getAttribute("jsonData")%>];
grid = $("#maingrid").ligerGrid( {
checkbox: true,
columns : [ {
hide :'主鍵',
name :'rid',
type :'String',
width :'0%'
}, {
display :'資源名稱(chēng)',
name :'name',
width :'20%'
}, {
display :'資源類(lèi)型',
name :'type',
width :'15%',
align :'center',
render: function (row) {
var html;
if(row.type=='module'){
html='模塊';
}else if(row.type=='menu'){
html='菜單';
}else if(row.type=='opt'){
html='操作';
}else{
html="未知";
}
return html;
}
},
{
display :'URL',
name :'url',
width :'30%',
align :'center'
},
{
display :'描述',
name :'desc',
width :'15%',
align :'center'
},{
display :'操作',
isAllowHide: false,
isSort: false,
width: '16.5%',
render: function (row) {
//row.selected.
}
}],
dataAction :'server',
title:'角色列表',
sortName :'id',
width :'99.5%',
height :'99%',
usePager :true,
pageSize :20,
pageParmName :'pageNum',
pagesizeParmName :'pageSize',
url :'list_menuTreeAction.action',
rownumbers:true,
});
});
//獲取選中的
function f_select()
{
var rows = grid.getCheckedRows();
return rows;
}
</script>
</head>
<body >
<div id="maingrid" ></div>
</body>
</html>
向AI問(wèn)一下細(xì)節(jié)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。