source: trunk/www/common/export/index.jsp @ 6192

Last change on this file since 6192 was 6192, checked in by Nicklas Nordborg, 10 years ago

References #1729 and #1730.

Refactored the code for displaying a popup message when loading a page. The message should now be stored as a session setting instead: sc.setSessionSetting("alert-message", message). The added benefit is that the message is only displayed once and is not re-displayed if the page is reloaded.

Removed onunload, onkeypress and attributes from the <base:body> tag. Added support for dynamic attributes instead.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 3.9 KB
Line 
1<%-- $Id: index.jsp 6192 2012-10-31 12:34:19Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
4
5  This file is part of BASE - BioArray Software Environment.
6  Available at http://base.thep.lu.se/
7
8  BASE is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License
10  as published by the Free Software Foundation; either version 3
11  of the License, or (at your option) any later version.
12
13  BASE is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21
22  @author Nicklas
23  @version 2.0
24--%>
25<%@ page pageEncoding="UTF-8" session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.Item"
29  import="net.sf.basedb.core.File"
30  import="net.sf.basedb.core.Job"
31  import="net.sf.basedb.core.Path"
32  import="net.sf.basedb.core.BaseException"
33  import="net.sf.basedb.core.PluginDefinition"
34  import="net.sf.basedb.core.PluginConfiguration"
35  import="net.sf.basedb.core.PluginConfigurationRequest"
36  import="net.sf.basedb.core.PluginExecutionRequest"
37  import="net.sf.basedb.core.PluginResponse"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.core.query.Expressions"
43  import="net.sf.basedb.core.query.Restrictions"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.plugin.Response"
46  import="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.core.plugin.InteractivePlugin"
49  import="net.sf.basedb.util.AutoDetectFileFormat"
50  import="net.sf.basedb.clients.web.Base"
51  import="net.sf.basedb.clients.web.WebException"
52  import="net.sf.basedb.util.Values"
53  import="net.sf.basedb.clients.web.util.HTML"
54  import="java.util.List"
55  import="java.util.LinkedList"
56  import="java.util.Map"
57  import="java.util.HashMap"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
61
62<%
63final String root = request.getContextPath()+"/";
64final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
65final String ID = sc.getId();
66final String cmd = request.getParameter("cmd");
67final Item itemType = Item.valueOf(request.getParameter("item_type"));
68final String subContext = Values.getString(request.getParameter("subcontext"), ""); 
69final GuiContext.Type contextType = GuiContext.Type.valueOf(request.getParameter("context_type"));
70final GuiContext context = new GuiContext(itemType, contextType, subContext);
71
72DbControl dc = sc.newDbControl();
73String forward = null;
74String message = null;
75String redirect = null;
76try
77{
78  if ("SelectPlugin".equals(cmd))
79  {
80    redirect = "../plugin/index.jsp?ID="+ID+
81      "&cmd=SelectPlugin&main_type=EXPORT"+
82      "&item_type="+itemType.name()+
83      "&subcontext="+subContext+
84      "&context_type="+contextType.name()+
85      "&title="+HTML.urlEncode(request.getParameter("title"));
86  }
87  else
88  {
89    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
90  }
91
92}
93finally
94{
95  if (dc != null) dc.close();
96}
97
98if (forward != null)
99{
100  sc.setSessionSetting("alert-message", message);
101  pageContext.forward(forward);
102}
103else if (redirect != null)
104{
105  sc.setSessionSetting("alert-message", message);
106  response.sendRedirect(redirect);
107}
108else if (message == null)
109{
110  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&wait=0");
111}
112else
113{
114  response.sendRedirect(root + "common/close_popup.jsp?refresh_opener=1&message="+HTML.urlEncode(message));
115}
116%>
117
Note: See TracBrowser for help on using the repository browser.