Improve output: distinguish between failed assertions (failures) and unexpected exceptions (errors), and print a filtered stack trace for any exception.
This commit is contained in:
commit
4f2e303079
1839 changed files with 235630 additions and 0 deletions
45
webapp/web/templates/tabs/tabAdmin.jsp
Normal file
45
webapp/web/templates/tabs/tabAdmin.jsp
Normal file
|
@ -0,0 +1,45 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<% /***********************************************
|
||||
Displays the little group of things at the bottom of the page
|
||||
for administrators and editors.
|
||||
|
||||
request.attributes:
|
||||
an Tab object with the name "leadingTab"
|
||||
|
||||
|
||||
request.parameters:
|
||||
None, should only work with requestScope attributes for security reasons.
|
||||
|
||||
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html output
|
||||
for debugging info.
|
||||
|
||||
bdc34 2006-01-22 created
|
||||
**********************************************/
|
||||
|
||||
Tab leadingTab = (Tab) request.getAttribute("leadingTab");
|
||||
if (leadingTab == null) {
|
||||
String e = "tabAdmin.jsp expects that request attribute 'leadingTab' be set to a TabBean object";
|
||||
throw new JspException(e);
|
||||
}
|
||||
%>
|
||||
|
||||
<c:if test="${sessionScope.loginHandler.loginStatus == 'authenticated' && sessionScope.loginHandler.loginRole > 3 }">
|
||||
<c:set var='tab' value='${requestScope.leadingTab}'/><%/* just moving this into page scope for easy use */ %>
|
||||
<c:set var='portal' value='${requestScope.portalBean.portalId}'/>
|
||||
<div class='admin bottom'>
|
||||
<c:url var="editHref" value="tabEdit">
|
||||
<c:param name="home" value="${currentPortalId}"/>
|
||||
<c:param name="controller" value="Tab"/>
|
||||
<c:param name="id" value="${tab.tabId}"/>
|
||||
</c:url>
|
||||
<c:set var="editHref">
|
||||
<c:out value="${editHref}" escapeXml="true"/>
|
||||
</c:set>
|
||||
<a href="${editHref}">edit tab: <em>${tab.title}</em></a>
|
||||
<% /* | <a href='<c:url value="cloneEntity?home=${portal}&tabId=${tab.tabId}"/>'> <i>clone tab</i> ${tab.title}</a> */ %>
|
||||
</div>
|
||||
</c:if>
|
139
webapp/web/templates/tabs/tabAtom.jsp
Normal file
139
webapp/web/templates/tabs/tabAtom.jsp
Normal file
|
@ -0,0 +1,139 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
||||
<%@ page import="java.util.Collection" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Link" %>
|
||||
<%@ page import="java.net.URLEncoder" %>
|
||||
<%@ page import="org.joda.time.format.DateTimeFormatter" %>
|
||||
<%@ page import="org.joda.time.format.ISODateTimeFormat" %>
|
||||
<%@ page import="org.joda.time.DateTime" %>
|
||||
<%
|
||||
/******************************
|
||||
Takes tab and populates Atom feed with:
|
||||
requested tab and its description
|
||||
entities associated with this tab
|
||||
immediate children of this tab and their descriptions
|
||||
******************************/
|
||||
response.setContentType("application/atom+xml");
|
||||
Tab leadingTab = (Tab) request.getAttribute("leadingTab");
|
||||
if (leadingTab == null) {
|
||||
String e = "tabprimary expects that request attribute 'leadingTab' be set to a TabBean object";
|
||||
throw new JspException(e);
|
||||
}
|
||||
Collection<Individual> individuals = leadingTab.getRelatedEntities();
|
||||
Collection<Tab> tabs = leadingTab.getChildTabs();
|
||||
Portal portal = (Portal)request.getAttribute("portalBean");
|
||||
int portalId = -1;
|
||||
if (portal==null) {
|
||||
portalId=1;
|
||||
} else {
|
||||
portalId=portal.getPortalId();
|
||||
}
|
||||
DateTime dt = new DateTime();
|
||||
DateTimeFormatter dtf = ISODateTimeFormat.basicDateTimeNoMillis();
|
||||
String time = dtf.print(dt.getMillis());
|
||||
time = time.substring(0,4)+"-"+time.substring(4,6)+"-"+time.substring(6,11)+":"+time.substring(11,13)+":"+time.substring(13,15)+"Z";
|
||||
%>
|
||||
<%!
|
||||
public String forURL(String frag)
|
||||
{
|
||||
String result = null;
|
||||
try
|
||||
{
|
||||
result = URLEncoder.encode(frag, "UTF-8");
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException("UTF-8 not supported", ex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String escapeEntity(String frag)
|
||||
{
|
||||
if(frag.contains("&")) frag = replaceAll(frag, "&", "&");
|
||||
if(frag.contains("'")) frag = replaceAll(frag, "'", "'");
|
||||
if(frag.contains("\"")) frag = replaceAll(frag, "\"", """);
|
||||
if(frag.contains(">")) frag = replaceAll(frag, ">", ">");
|
||||
if(frag.contains("<")) frag = replaceAll(frag, "<", "<");
|
||||
return frag;
|
||||
}
|
||||
|
||||
public String replaceAll(String original, String match, String replace)
|
||||
{
|
||||
int index1 = original.indexOf(match);
|
||||
int index2 = original.indexOf(replace);
|
||||
if(index1 == index2 && index1 != -1)
|
||||
{
|
||||
original = original.substring(0, index1+replace.length()+1)+replaceAll(original.substring(index1+replace.length()+1), match, replace);
|
||||
return original;
|
||||
}
|
||||
if(index1 == -1) return original;
|
||||
String before = original.substring(0, index1) + replace;
|
||||
return before + replaceAll(original.substring(index1+1), match, replace);
|
||||
}
|
||||
%>
|
||||
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en" xml:base="http://<%= request.getServerName()+":"+request.getLocalPort() %>">
|
||||
<title><%= escapeEntity(leadingTab.getTitle()) %></title>
|
||||
<subtitle><%= leadingTab.getDescription() %></subtitle>
|
||||
<link href="<%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()+"&view=atom") %>" rel="self" type="application/atom+xml" />
|
||||
<link href="<%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()) %>" rel="alternate" type="text/html" />
|
||||
<id><%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+leadingTab.getTabDepthName()+"="+leadingTab.getTabId()) %></id>
|
||||
<updated><%= time %></updated>
|
||||
<author>
|
||||
<name>Vivo</name>
|
||||
<email>vivo@cornell.edu</email>
|
||||
</author>
|
||||
<% for(Individual i:individuals) { %>
|
||||
<entry>
|
||||
<title><%= escapeEntity(i.getName()) %></title>
|
||||
<% if (i.getLinksList() == null) { %>
|
||||
<% for(Link l: i.getLinksList()) { %>
|
||||
<link href="<%= l.getUrl() %>" rel="alternate" type="text/html" />
|
||||
<% } %>
|
||||
<% } else { %>
|
||||
<link href="<%= escapeEntity(request.getContextPath().substring(1)+"/entity?home="+portalId+"&uri="+forURL(i.getURI())) %>" rel="alternate" type="text/html" />
|
||||
<% } %>
|
||||
<id><%= i.getURI() %></id>
|
||||
<updated><%= time %></updated>
|
||||
<% if (i.getBlurb() != null) { %>
|
||||
<% if (i.getBlurb().matches(".*<.*>.*")) { %>
|
||||
<summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= i.getBlurb() %></div></summary>
|
||||
<% } %>
|
||||
<% else { %>
|
||||
<summary type="text"><%= i.getBlurb() %></summary>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (i.getDescription() != null) { %>
|
||||
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= i.getDescription() %></div></content>
|
||||
<% } %>
|
||||
</entry>
|
||||
<% } %>
|
||||
<% if (tabs != null) { %>
|
||||
<% for(Tab t:tabs) { %>
|
||||
<entry>
|
||||
<title><%= escapeEntity(t.getTitle()) %></title>
|
||||
<link href="<%= escapeEntity(request.getContextPath().substring(1)+"/index.jsp?home="+portalId+"&"+t.getTabDepthName()+"="+t.getTabId()) %>" rel="alternate" type="text/html" />
|
||||
<id><%= "http://"+request.getServerName()+":"+request.getLocalPort()+request.getContextPath()+escapeEntity("/index.jsp?home="+portalId+"&"+t.getTabDepthName()+"="+t.getTabId()) %></id>
|
||||
<updated><%= time %></updated>
|
||||
<% if (t.getDescription() != null) { %>
|
||||
<% if (t.getDescription().matches(".*<.*>.*")) { %>
|
||||
<summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= t.getDescription() %></div></summary>
|
||||
<% } %>
|
||||
<% else { %>
|
||||
<summary type="text"><%= t.getDescription() %></summary>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (t.getBody() != null) { %>
|
||||
<content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><%= t.getBody() %></div></content>
|
||||
<% } %>
|
||||
</entry>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</feed>
|
145
webapp/web/templates/tabs/tabBasic.jsp
Executable file
145
webapp/web/templates/tabs/tabBasic.jsp
Executable file
|
@ -0,0 +1,145 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="org.apache.commons.logging.Log" %>
|
||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Portal" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<% /***********************************************
|
||||
Display a single tab or subtab in the most basic fashion.
|
||||
|
||||
Note: most of the depth based control is in tabSub.jsp
|
||||
tabSubAsList.jsp and tabEntities.jsp. The only depth based
|
||||
control of what gets displayed that is in this code is
|
||||
the tab.body, which is only displayed on depth 1.
|
||||
|
||||
request.attributes:
|
||||
a Tab object with the name "tab3223" where 3223 is
|
||||
the id of the tab to display. This can be added to the attribute
|
||||
list using TabWebUtil.stashTabsInRequest which gets called
|
||||
in tabprimary.jsp.
|
||||
|
||||
request.parameters:
|
||||
"tabDepth" String that is the depth of the tab in the display
|
||||
leadingTab = 1, child of leadingTab = 2, etc.
|
||||
if tabDepth is not set it defaults to 1
|
||||
"tabId" id of the tab to display, defaults to leadingTab.
|
||||
|
||||
"noDesc" if true then don't display the tab.description, default is false.
|
||||
"noEntities" if true then don't display the associated entities for this tab.
|
||||
"noContent" if true then don't display the primary content tabs.
|
||||
"noSubtabs" if true then don't display the subtabs associated with this tab.
|
||||
"subtabsAsList" if true then display just children (not grand children,etc) subtabs as a list.
|
||||
|
||||
Consider sticking < % = MiscWebUtils.getReqInfo(request) % > in the html
|
||||
output for debugging info.
|
||||
|
||||
bdc34 2006-01-03 created
|
||||
**********************************************/
|
||||
String INACTIVE = "";
|
||||
String DEFAULT_LABEL = null;
|
||||
|
||||
/***************************************************
|
||||
nac26 2008-05-08 following brian's lead from menu.jsp to get the portalId so it can be added to the tab links */
|
||||
final Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.web.tabBasic.jsp");
|
||||
|
||||
Portal portal = (Portal)request.getAttribute("portalBean");
|
||||
int portalId = -1;
|
||||
if (portal==null) {
|
||||
log.error("Attribute 'portalBean' missing or null; portalId defaulted to 1");
|
||||
portalId=1;
|
||||
} else {
|
||||
portalId=portal.getPortalId();
|
||||
}
|
||||
/**************************************************/
|
||||
|
||||
String tabId = request.getParameter("tabId");
|
||||
if (tabId == null) {
|
||||
String e = "tabBasic expects that request parameter 'tabId' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
Tab tab = TabWebUtil.findStashedTab(tabId, request);
|
||||
if (tab == null) {
|
||||
String e = "tabBasic expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String obj = request.getParameter("tabDepth");
|
||||
int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc.
|
||||
if (obj == null) {
|
||||
String e = "tabBasic expects that request parameter 'tabDepth' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
depth = Integer.parseInt((String) obj);
|
||||
|
||||
boolean entities = true;
|
||||
if ("true".equalsIgnoreCase(request.getParameter("noEntities")))
|
||||
entities = false;
|
||||
boolean content = true;
|
||||
if ("true".equalsIgnoreCase(request.getParameter("noContent")))
|
||||
content = false;
|
||||
boolean subtabs = true;
|
||||
if ("true".equalsIgnoreCase(request.getParameter("noSubtabs")))
|
||||
subtabs = false;
|
||||
boolean subtabsAsList = false;
|
||||
if ("true".equalsIgnoreCase(request.getParameter("subtabsAsList"))) {
|
||||
subtabsAsList = true;
|
||||
subtabs = false;
|
||||
}
|
||||
|
||||
boolean noDesc = false;
|
||||
if ("true".equalsIgnoreCase(request.getParameter("noDesc"))) {
|
||||
noDesc = true;
|
||||
}
|
||||
|
||||
String tabEntsController = Controllers.TAB_ENTITIES;
|
||||
|
||||
String titleLink = TabWebUtil.tab2TabAnchorElement(tab, request, depth, INACTIVE, DEFAULT_LABEL, portalId);
|
||||
if (depth == 1)//don't make a link for root dispaly tab
|
||||
titleLink = tab.getTitle();
|
||||
|
||||
Integer headingDepth = depth + 1;
|
||||
String headingOpen = "<h" + headingDepth + ">";
|
||||
String headingClose = "</h" + headingDepth + ">";
|
||||
|
||||
String tabDesc = "";
|
||||
if (!noDesc && tab.getDescription() != null && !tab.getDescription().equals(" "))
|
||||
tabDesc = "<div class='tabDesc' >" + tab.getDescription() + "</div>";
|
||||
String tabBody = "";
|
||||
|
||||
/* tab.body is only displayed for the depth 1 display tab */
|
||||
if (depth <= 2 && tab.getBody() != null && !tab.getBody().equals(" "))
|
||||
tabBody = "<div class='tabBody'>" + tab.getBody() + "</div><!-- END div class='tabBody' -->";
|
||||
%>
|
||||
<div class="tab depth<%=depth%>" id="tab<%=tabId%>">
|
||||
<%=headingOpen%><%=titleLink%><%=headingClose%>
|
||||
<%=tabDesc%>
|
||||
<%=tabBody%>
|
||||
<% if( entities ){ %>
|
||||
<jsp:include page="<%=tabEntsController%>" flush="true">
|
||||
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
|
||||
<jsp:param name="tabDepth" value="<%=depth%>"/>
|
||||
</jsp:include>
|
||||
<% } %>
|
||||
<% if( subtabs ) { %>
|
||||
<jsp:include page="tabSub.jsp" flush="true">
|
||||
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
|
||||
<jsp:param name="tabDepth" value="<%=depth%>"/>
|
||||
</jsp:include>
|
||||
<% }%>
|
||||
<% if( subtabsAsList ) { %>
|
||||
<jsp:include page="tabSubAsList.jsp" flush="true">
|
||||
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
|
||||
<jsp:param name="tabDepth" value="<%=depth%>"/>
|
||||
</jsp:include>
|
||||
<% }%>
|
||||
<% if(content) { %>
|
||||
<jsp:include page="tabContent.jsp" flush="true">
|
||||
<jsp:param name="tabId" value="<%=tab.getTabId()%>"/>
|
||||
<jsp:param name="tabDepth" value="1" />
|
||||
</jsp:include>
|
||||
<% } %>
|
||||
</div><!-- tab depth<%=depth%> -->
|
95
webapp/web/templates/tabs/tabContent.jsp
Executable file
95
webapp/web/templates/tabs/tabContent.jsp
Executable file
|
@ -0,0 +1,95 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page import="java.util.Collection,java.util.Iterator" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<%
|
||||
int CutOffDepth = 3;
|
||||
/***********************************************
|
||||
Tab Content is to display the sub tabs of type primaryTabContent
|
||||
|
||||
Primary Content Tabs will have:
|
||||
tab heading,
|
||||
tab description
|
||||
request.attributes
|
||||
"leadingTab" the tab that is at the top of the display hierarchy
|
||||
|
||||
"tabDepth" String that is the depth of the tab in the display
|
||||
leadingTab = 1, child of leadingTab = 2, etc.
|
||||
Here tabDepth does not default, it must be set
|
||||
|
||||
bdc34 2006-01-12 created
|
||||
**********************************************/
|
||||
|
||||
Tab leadingTab =(Tab) request.getAttribute("leadingTab");
|
||||
if(leadingTab== null ) {
|
||||
String e="tabContent expects that request attribute 'leadingTab' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String tabId = request.getParameter("tabId");
|
||||
if( tabId == null ){
|
||||
String e="tabContent expects that request parameter 'tabId' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
Tab tab = null;
|
||||
tab = TabWebUtil.findStashedTab(tabId,request);
|
||||
if( tab == null ){
|
||||
String e="tabContent expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String obj= request.getParameter("tabDepth");
|
||||
int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc.
|
||||
if( obj == null ){
|
||||
String e="tabContent expects that request parameter 'tabDepth' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
depth = Integer.parseInt((String)obj);
|
||||
int childDepth = depth + 1;
|
||||
|
||||
Collection children = tab.filterChildrenForContentTabs();
|
||||
if( depth < CutOffDepth && children!= null ){
|
||||
Iterator childIter=children.iterator();
|
||||
boolean hasChildren = childIter.hasNext();
|
||||
int columnSize = children.size();
|
||||
if( hasChildren ){ %>
|
||||
|
||||
<div id='tabContent'><!-- tabContent.jsp -->
|
||||
<table><tr>
|
||||
<% }
|
||||
while( childIter.hasNext() ) {
|
||||
Tab contentTab = (Tab)childIter.next();
|
||||
TabWebUtil.stashTabsInRequest(contentTab, request); %>
|
||||
|
||||
<% if (columnSize==2) {%>
|
||||
<td class="span-12">
|
||||
<% } %>
|
||||
|
||||
<% else if (columnSize==3) {%>
|
||||
<td class="span-8">
|
||||
<% } %>
|
||||
|
||||
<% else if (columnSize==4) {%>
|
||||
<td class="span-6">
|
||||
<% } %>
|
||||
|
||||
<% else {%>
|
||||
<td>
|
||||
<% } %>
|
||||
|
||||
<jsp:include page='tabBasic.jsp'>
|
||||
<jsp:param name='tabDepth' value='<%=childDepth%>' />
|
||||
<jsp:param name='tabId' value='<%=contentTab.getTabId()%>' />
|
||||
<jsp:param name='noContent' value='true'/>
|
||||
<jsp:param name='noSubtabs' value='true'/>
|
||||
</jsp:include>
|
||||
</td>
|
||||
<% }
|
||||
if( hasChildren ){ %>
|
||||
</tr></table>
|
||||
</div><!-- end tabContent div-->
|
||||
<%}%>
|
||||
<% } %>
|
128
webapp/web/templates/tabs/tabSub.jsp
Executable file
128
webapp/web/templates/tabs/tabSub.jsp
Executable file
|
@ -0,0 +1,128 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="java.util.Collection" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page import="java.util.Iterator" %>
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<%
|
||||
int CutOffDepth = 3; //tab depth at which subtabs stop being shown
|
||||
int HorzSubTabCutOff = 8; //subtab count at which we switch to tabSubAsList.jsp
|
||||
int EntsInDepth2TabsCutOff = 4; //subtab count at which entities stop being shown in depth 2 tabs.
|
||||
int TabDescCutoffDepth = 3;//depth at which descriptions of subtabs stop being shown
|
||||
|
||||
/***********************************************
|
||||
Display a set of subtabs for a tab
|
||||
|
||||
request.attributes
|
||||
"leadingTab" the tab that is at the top of the display hierarchy
|
||||
|
||||
request.parameters
|
||||
"tabId" id of the tab to do subtabs for
|
||||
|
||||
"noEntities" can be set to 'true' or 'false' and will control if
|
||||
subtabs have entities. defaults to false/having entites;
|
||||
|
||||
"tabDepth" String that is the depth of the tab in the display
|
||||
leadingTab = 1, child of leadingTab = 2, etc.
|
||||
Here tabDepth does not default, it must be set
|
||||
|
||||
bdc34 2006-01-12 created
|
||||
**********************************************/
|
||||
Tab leadingTab = (Tab) request.getAttribute("leadingTab");
|
||||
if (leadingTab == null) {
|
||||
String e = "tabSub expects that request attribute 'leadingTab' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String tabId = request.getParameter("tabId");
|
||||
if (tabId == null) {
|
||||
String e = "tabSub expects that request parameter 'tabId' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
Tab tab = null;
|
||||
tab = TabWebUtil.findStashedTab(tabId, request);
|
||||
if (tab == null) {
|
||||
String e = "tabSub expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String obj = request.getParameter("tabDepth");
|
||||
int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc.
|
||||
if (obj == null) {
|
||||
String e = "tabSub expects that request parameter 'tabDepth' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
depth = Integer.parseInt((String) obj);
|
||||
int childDepth = depth + 1;
|
||||
|
||||
Collection children = tab.filterChildrenForSubtabs();
|
||||
if (depth < CutOffDepth && children != null) {
|
||||
if (children.size() >= HorzSubTabCutOff) { /* too many children, do tabSubAsList instead */ %>
|
||||
<jsp:include page='tabSubAsList.jsp' >
|
||||
<jsp:param name='tabDepth' value='<%=depth%>' />
|
||||
<jsp:param name='tabId' value='<%=tabId%>' />
|
||||
</jsp:include>
|
||||
<% } else {
|
||||
|
||||
//here we figure out if these subtabs should have entities
|
||||
//if we were passed a parameter, then maybe no entities
|
||||
obj = request.getParameter("noEntities");
|
||||
String noEntities = "true".equalsIgnoreCase(obj) ? "true" : "false";
|
||||
//if we have more subtabs then the cutoff, no entities for the subtabs
|
||||
noEntities = (children.size() >= EntsInDepth2TabsCutOff ? "true" : noEntities);
|
||||
//if we are the first set of subtabs on a primary tab it seems there are no entities? sort of odd
|
||||
noEntities = ((tab.PRIMARY_TAB == tab.getTabtypeId() && childDepth == 2) ? "true" : noEntities);
|
||||
|
||||
String noDesc = (childDepth >= TabDescCutoffDepth) ? "true" : "false";
|
||||
|
||||
Iterator childIter = children.iterator();
|
||||
boolean hasChildren = childIter.hasNext();
|
||||
int columnSize = children.size();
|
||||
if (hasChildren) { %>
|
||||
|
||||
<div class='subtabs'><!-- tabSub.jsp -->
|
||||
<table><tr>
|
||||
<% }
|
||||
while( childIter.hasNext() ) {
|
||||
Tab subtab = (Tab)childIter.next();
|
||||
TabWebUtil.stashTabsInRequest(subtab, request); %>
|
||||
|
||||
<% if (columnSize==1) {%>
|
||||
<td class="span-24">
|
||||
<% } %>
|
||||
|
||||
<% else if (columnSize==2) {%>
|
||||
<td class="span-12">
|
||||
<% } %>
|
||||
|
||||
<% else if (columnSize==3) {%>
|
||||
<td class="span-8">
|
||||
<% } %>
|
||||
|
||||
<% else if (columnSize==4) {%>
|
||||
<td class="span-6">
|
||||
<% } %>
|
||||
|
||||
<% else {%>
|
||||
<td>
|
||||
<% } %>
|
||||
|
||||
<jsp:include page='tabBasic.jsp'>
|
||||
<jsp:param name='tabDepth' value='<%=childDepth%>' />
|
||||
<jsp:param name='tabId' value='<%=subtab.getTabId()%>' />
|
||||
<jsp:param name='noDesc' value='<%=noDesc%>'/>
|
||||
<jsp:param name='noEntities' value='<%=noEntities%>'/>
|
||||
<jsp:param name='noContent' value='true'/>
|
||||
<jsp:param name='noSubtabs' value='true'/>
|
||||
<jsp:param name='subtabsAsList' value='true'/>
|
||||
</jsp:include>
|
||||
</td>
|
||||
<% }
|
||||
if( hasChildren ){ %>
|
||||
</tr></table>
|
||||
</div><!-- end subtabs div-->
|
||||
<%}
|
||||
}
|
||||
} %>
|
87
webapp/web/templates/tabs/tabSubAsList.jsp
Normal file
87
webapp/web/templates/tabs/tabSubAsList.jsp
Normal file
|
@ -0,0 +1,87 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page import="java.lang.Integer" %>
|
||||
<%@ page import="java.util.Collection" %>
|
||||
<%@ page import="java.util.Iterator" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<%
|
||||
int CutOffDepth = 3; //tab depth at which subtabs stop being shown
|
||||
int TabDescCutoffDepth = 3;//depth at which descriptions of subtabs stop being shown
|
||||
/***********************************************
|
||||
Display a set of subtabs for a Tab as a <UL></UL>
|
||||
Based on tabSub.
|
||||
This does not attempt to display any subtabs, entities, etc.
|
||||
|
||||
request.attributes
|
||||
"leadingTab" the tab that is at the top of the display hierarchy
|
||||
|
||||
request.parameters
|
||||
"tabId" id of the tab to do subtabs for
|
||||
|
||||
"tabDepth" String that is the depth of the tab in the display
|
||||
leadingTab = 1, child of leadingTab = 2, etc.
|
||||
Here tabDepth does not default, it must be set
|
||||
|
||||
bdc34 2006-01-18 created
|
||||
**********************************************/
|
||||
Tab leadingTab = (Tab) request.getAttribute("leadingTab");
|
||||
if (leadingTab == null) {
|
||||
String e = "tabSub expects that request attribute 'leadingTab' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String tabId = request.getParameter("tabId");
|
||||
if (tabId == null) {
|
||||
String e = "tabSub expects that request parameter 'tabId' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
Tab tab = null;
|
||||
tab = TabWebUtil.findStashedTab(tabId, request);
|
||||
if (tab == null) {
|
||||
String e = "tabSub expects that request attribute 'leadingTab' will have the tab with tabId as a sub tab";
|
||||
throw new JspException(e);
|
||||
}
|
||||
|
||||
String obj = request.getParameter("tabDepth");
|
||||
int depth = 1; //depth 1 represents primary tab level, 2 is secondary, etc.
|
||||
if (obj == null) {
|
||||
String e = "tabSub expects that request parameter 'tabDepth' be set";
|
||||
throw new JspException(e);
|
||||
}
|
||||
depth = Integer.parseInt((String) obj);
|
||||
int childDepth = depth + 1;
|
||||
|
||||
String noDesc = (childDepth >= TabDescCutoffDepth) ? "true" : "false";
|
||||
//noDesc = "true";
|
||||
|
||||
Collection children = tab.filterChildrenForSubtabs();
|
||||
if (depth < CutOffDepth && children != null) {
|
||||
Iterator childIter = children.iterator();
|
||||
boolean hasChildren = childIter.hasNext();
|
||||
if (hasChildren) { %>
|
||||
<div class='subtabs'><!-- tabSub.jsp -->
|
||||
<ul class='tabSubAsList'>
|
||||
<% }
|
||||
while( childIter.hasNext() ) {
|
||||
Tab subtab = (Tab)childIter.next();
|
||||
TabWebUtil.stashTabsInRequest(subtab,request); %>
|
||||
<li>
|
||||
<jsp:include page='tabBasic.jsp'>
|
||||
<jsp:param name='tabDepth' value='<%=childDepth%>' />
|
||||
<jsp:param name='tabId' value='<%=subtab.getTabId()%>' />
|
||||
<jsp:param name='noDesc' value='<%=noDesc%>'/>
|
||||
<jsp:param name='yesBody' value='false'/>
|
||||
<jsp:param name='noEntities' value='true'/>
|
||||
<jsp:param name='noContent' value='true'/>
|
||||
<jsp:param name='noSubtabs' value='true'/>
|
||||
</jsp:include>
|
||||
</li>
|
||||
<% }
|
||||
if( hasChildren ){ %>
|
||||
</ul>
|
||||
</div><!-- end subtabs div-->
|
||||
<%}%>
|
||||
<% } %>
|
38
webapp/web/templates/tabs/tabprimary.jsp
Executable file
38
webapp/web/templates/tabs/tabprimary.jsp
Executable file
|
@ -0,0 +1,38 @@
|
|||
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||
|
||||
<%@ page errorPage="/error.jsp"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.TabWebUtil" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Tab" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
|
||||
|
||||
<% /***********************************************
|
||||
Display a primary tab.
|
||||
|
||||
A display of a primary tab will include:
|
||||
primary tab heading,
|
||||
the primary tab description,
|
||||
the primary tab body,
|
||||
the secondary tabs ,
|
||||
the primary content tabs.
|
||||
|
||||
expected request.attributes:
|
||||
'leadingTab' Tab to be desplayed as root of display hierarchy
|
||||
|
||||
bdc34 2006-01-03 created
|
||||
**********************************************/
|
||||
Tab leadingTab = (Tab) request.getAttribute("leadingTab");
|
||||
if (leadingTab == null) {
|
||||
String e = "tabprimary expects that request attribute 'leadingTab' be set to a TabBean object";
|
||||
throw new JspException(e);
|
||||
}
|
||||
TabWebUtil.stashTabsInRequest(leadingTab, request); %>
|
||||
<div id="content">
|
||||
<div id='contents'>
|
||||
<jsp:include page='/templates/tabs/tabBasic.jsp' flush='true'>
|
||||
<jsp:param name='tabId' value='<%= leadingTab.getTabId() %>' />
|
||||
<jsp:param name='tabDepth' value='1' />
|
||||
</jsp:include>
|
||||
<jsp:include page='/templates/tabs/tabAdmin.jsp' flush='true' />
|
||||
</div> <!-- contents -->
|
||||
</div><!-- content -->
|
Loading…
Add table
Add a link
Reference in a new issue