实现多页签功能

1.实现效果图


2.实现jsp和js

<%@page contentType="text/html;charset=UTF-8" %>
<%@page import="java.util.List"%>
<%@page import="com.costech.common.service.ICommonService"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="java.lang.RuntimeException" %>
<%@page import="com.costech.common.helper.ServiceHelper"%>
<%@page import="com.costech.common.util.StringUtility"%>
<%@page import="com.costech.common.bean.SystemPath"%>
<%@page import="com.costech.module.expenserequest.bean.ExpenseRequest"%>
<%@page import="com.costech.module.expenserequest.helper.ExpenseRequestHelper" %>
<%@page import="com.costech.module.expenserequest.service.IExpenseRequestService" %>



<%
	String sVersion = (String) session.getAttribute("sVersion");
	String fileID = StringUtility.toStringValue(request.getParameter("FILEID"), "");
	String isRead = StringUtility.toStringValue(request.getParameter("isRead"), "0");

	IExpenseRequestService iExpenseRequestService = (IExpenseRequestService) ServiceHelper.getService("expenseRequestService");
	ExpenseRequest oFile = iExpenseRequestService.getExpenseRequestByID(fileID);

	String pageTitle = "租出船合同";
	String[] titles = {"租出船合同视图","租出船合同表单","视图和表单"};//页签标题
	String[] tabUrls = {                        //对应页面URL
		SystemPath.SYSTEMPATH + "/scripts/common/view/File_View_Template.jsp?viewid=2c9986125a64f985015a650fae870002",
		SystemPath.SYSTEMPATH + "/scripts/common/file/File_Info_Template.jsp?FormID=2c9986125a69193f015a69193f9a0000&IDField=FileID&FileID=",
		SystemPath.SYSTEMPATH + "/scripts/common/view/OnClickViewModule_Template.jsp?viewid=2c9986125a64f985015a650fae870002&viewHeight=40%&formHeight=60%&condition=CP_TYP='VC-OUT'"
	};
	try {
%>
<html>
	<head>
		<title><%=pageTitle%></title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/style/blue/form.css">
		<script src="<%=request.getContextPath()%>/include/form.js"></script>
		<script src="<%=request.getContextPath()%>/include/function.js"></script>
		<script src='<%=request.getContextPath() %>/include/jquery-1.11.1.min.js'></script>
		<style type="text/css"></style>
	</head>
	
	<script language="JavaScript" type="text/JavaScript">
	var selectedTabIdx = 0;//默认显示的页签
	var titles = new Array();//页签标题
	var tabUrls = new Array();//对应页面URL
	<%
	for(int i=0;i<titles.length;i++)
	{
	%>
		titles.push("<%=titles[i]%>");
		tabUrls.push("<%=tabUrls[i]%>");
	<%
	}
	%>
	function displayTab(tabIndex)
	{
		$("#tabTargetFrame").attr("src",tabUrls[tabIndex]);
		var tabTitles = $("#tabBar").find("div");
		var i = 0;
		$(tabTitles).each(function(){
			if(i==tabIndex)
			{
				$(this).removeClass("Tab-UnSelected");
				$(this).addClass("Tab-Selected");
			}else
			{
				$(this).removeClass("Tab-Selected");
				$(this).addClass("Tab-UnSelected");
			}
			i++;
		});
		selectedTabIdx = tabIndex;
	}
	//文档加载完成函数
	$(document).ready(function(){
		for(var i=0;i<titles.length;i++)
		{
			var div = "";
			if(i==selectedTabIdx)
			{
				div = "<div id='tabIndex'"+i+" class='Tab-Selected' style='float:left' onClick='displayTab("+i+")'>"+titles[i]+"</div>";
			}else
			{
				div = "<div id='tabIndex'"+i+" class='Tab-UnSelected' style='float:left' onClick='displayTab("+i+")'>"+titles[i]+"</div>";
			}
			$("#tabBar").append(div);
		}
		$("#tabTargetFrame").attr("src",tabUrls[selectedTabIdx]);
	});
	</script>

	<body bgcolor="#FFFFFF" text="#000000">
		<table>
			<tr>
				<td>
					<div id="tabBar">
					</div>
				</td>
			</tr>
		</table>
		<table width="100%" height="100%" cellspacing="0" cellpadding="0" class="Tab-Area">
			<tr>
				<td>
					<div id="tabTarget">
						<iframe id="tabTargetFrame" width="100%" height="100%" frameborder="0" scrolling="no" src="" ></iframe>
					</div>
				</td>
			</tr>
		</table>
	</body>
</html>
<script>

</script>
<%
	}catch(Exception er){
	 er.printStackTrace();
	}
%>

3.注意点

3.1 页签的实现

3.2 打开列表界面的url

SystemPath.SYSTEMPATH + "/scripts/common/view/File_View_Template.jsp?viewid=2c9986125a64f985015a650fae870002"

3.3 打开表单界面的url

SystemPath.SYSTEMPATH + "/scripts/common/file/File_Info_Template.jsp?FormID=2c9986125a69193f015a69193f9a0000&IDField=FileID&FileID="

3.4 打开列表和表单上下分屏界面url

SystemPath.SYSTEMPATH + "/scripts/common/view/OnClickViewModule_Template.jsp?viewid=2c9986125a64f985015a650fae870002&viewHeight=40%&formHeight=60%&condition=CP_TYP='VC-OUT'"


### 回答1: WpfCefSharp多页是指在使用WpfCefSharp开发桌面应用时,通过该技术可以实现多个网页在一个程序中以多个标页的形式进行展示和管理。 WpfCefSharp是基于Chromium的工具包,用于在WPF应用中嵌入Web浏览器功能。通过使用WpfCefSharp,我们可以实现类似Chrome浏览器的多页功能。 在实现多页功能时,我们可以使用TabControl作为容器,每个TabItem代表一个标页。通过动态添加和移除TabItem,我们可以在界面上添加和关闭不同的网页标。 在添加一个新的标页时,我们可以创建一个新的TabItem,并在其中嵌入一个WpfCefSharp的浏览器控件。通过设置浏览器控件的地址属性,可以加载特定的网页内容到标页中。 同时,我们还可以为每个标页添加一些常见的浏览器操作功能,如前进、后退、刷新和停止等按钮。这些按钮的操作可通过WpfCefSharp的API进行控制,与标页中浏览器控件的交互可以实现类似浏览器的行为。 当关闭一个标页时,我们需要清理相关资源,如销毁标页所在的TabItem以及其中的浏览器控件。 总之,通过使用WpfCefSharp和TabControl,我们可以很方便地实现WPF应用中的多页功能,并且可以通过WpfCefSharp的API实现与浏览器类似的交互体验。 ### 回答2: WpfCefSharp是一个基于WPF的浏览器控件,它可以在WPF应用程序中嵌入网页浏览功能多页是指在WpfCefSharp控件中同时加载和显示多个网页。 要实现多页,首先需要将WpfCefSharp控件添加到WPF窗口或页面中。然后,可以通过创建多个Browser对象,并将每个对象加载不同的网页链接来实现多页功能。可以使用WpfCefSharp的Load方法来加载指定网页链接。 在加载不同的网页链接时,可以通过创建多个Browser对象的实例,每个实例代表一个不同的网页标。可以根据需要在WpfCefSharp控件中显示或隐藏不同的Browser对象。 为了实现多页的切换功能,可以使用选项卡或其他控件来显示所有的网页标,并在用户选择不同的标时切换显示对应的Browser对象。 在处理多页的操作时,可以通过调用对应的Browser对象的方法,例如GoBack、GoForward等来实现返回前一页、前进至下一页等功能。 需要注意的是,使用多页时要注意控制每个Browser对象的资源消耗,避免同时加载大量网页时造成过多的内存和CPU资源占用。 总结来说,要实现WpfCefSharp多页功能,需要创建多个Browser对象并加载不同的网页链接,并通过选项卡等控件来切换显示不同的网页标。同时要注意资源消耗,避免过多的资源占用。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值