source: trunk/www/biomaterials/lists/edit_list.jsp @ 4681

Last change on this file since 4681 was 4681, checked in by Nicklas Nordborg, 14 years ago

References #1175: Biomaterial lists

Basic web interface is now in place.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 4.9 KB
Line 
1<%-- $Id: edit_list.jsp 4681 2008-12-03 13:04:58Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2008 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.10
24--%>
25<%@ page 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.ItemContext"
30  import="net.sf.basedb.core.Permission"
31  import="net.sf.basedb.core.BioMaterialList"
32  import="net.sf.basedb.core.PermissionDeniedException"
33  import="net.sf.basedb.clients.web.Base"
34  import="net.sf.basedb.clients.web.util.HTML"
35  import="net.sf.basedb.util.Values"
36%>
37<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
38<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
39<%
40final Item itemType = Item.BIOMATERIALLIST;
41final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
42final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
43final int itemId = cc.getId();
44final String ID = sc.getId();
45final float scale = Base.getScale(sc);
46final DbControl dc = sc.newDbControl();
47try
48{
49  String title = null;
50  BioMaterialList list = null;
51
52  if (itemId == 0)
53  {
54    title = "Create biomaterial list";
55    cc.removeObject("item");
56  }
57  else
58  {
59    list = BioMaterialList.getById(dc, itemId);
60    cc.setObject("item", list);
61    title = "Edit biomaterial list -- " + HTML.encodeTags(list.getName());
62    list.checkPermission(Permission.WRITE);
63  }
64 
65  final String clazz = "class=\"text\"";
66  final String requiredClazz = "class=\"text required\"";
67  %>
68
69  <base:page type="popup" title="<%=title%>">
70  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
71    <script language="JavaScript">
72    // Validate the "Biomaterial list" tab
73    function validateList()
74    {
75      var frm = document.forms['list'];
76      if (Main.trimString(frm.name.value) == '')
77      {
78        alert("You must enter a name");
79        frm.name.focus();
80        return false;
81      }
82      return true;
83    }
84
85    // Submit the form
86    function saveSettings()
87    {
88      var frm = document.forms['list'];
89      if (TabControl.validateActiveTab('settings'))
90      {
91        frm.submit();
92      }
93    }
94   
95    function init()
96    {
97      <%
98      if (list == null)
99      {
100        %>
101        var frm = document.forms['list'];
102        frm.name.focus();
103        frm.name.select();
104        <%
105      }
106      %>
107    }
108    </script>
109  </base:head>
110  <base:body onload="init()">
111    <p>
112    <form action="index.jsp?ID=<%=ID%>" method="post" name="list" onsubmit="return false;">
113    <input type="hidden" name="cmd" value="UpdateItem">
114
115    <h3 class="docked"><%=title%> <base:help tabcontrol="settings"/></h3>
116    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
117      position="bottom"  remember="<%=list != null%>">
118    <t:tab id="info" title="Biomaterial list" validate="validateList()" helpid="biomateriallist.edit">
119      <table class="form" cellspacing=0>
120      <tr>
121        <td class="prompt">Name</td>
122        <td><input <%=requiredClazz%> type="text" name="name" 
123          value="<%=HTML.encodeTags(list == null ? Values.getString(cc.getPropertyValue("name"), "New list") : list.getName())%>" 
124          size="40" maxlength="<%=BioMaterialList.MAX_NAME_LENGTH%>"></td>
125      </tr>
126      <tr>
127        <td class="prompt">External ID</td>
128        <td><input <%=clazz%> type="text" name="external_id" 
129          value="<%=HTML.encodeTags(list == null ? Values.getString(cc.getPropertyValue("externalId"), "") : list.getExternalId())%>" 
130          size="40" maxlength="<%=BioMaterialList.MAX_EXTERNAL_ID_LENGTH%>"></td>
131      </tr>
132      <tr valign=top>
133        <td class="prompt">Description</td>
134        <td nowrap>
135          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
136            ><%=HTML.encodeTags(list == null ? cc.getPropertyValue("description") : list.getDescription())%></textarea>
137          <a href="javascript:Main.zoom('Description', 'list', 'description')"
138            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
139        </td>
140      </tr>
141      </table>
142      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
143    </t:tab>
144    </t:tabcontrol>
145
146    <table align="center">
147    <tr>
148      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
149      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
150    </tr>
151    </table>
152    </form>
153  </base:body>
154  </base:page>
155  <%
156}
157finally
158{
159  if (dc != null) dc.close();
160}
161%>
Note: See TracBrowser for help on using the repository browser.