<% /* * AddRec.jsp 23/03/05 * * Copyright 2002 by George Ruthart, * 1955 Roy Ivor Crescent, Mississauga, Ontario, Canada L5L 3N7 * All rights reserved. * * This source code is the confidential and proprietary information * of George Ruthart ("Confidential Information"). You shall * not disclose this Confidential Information to any third parties * and shall not modify this code without the written permission * from George Ruthart as well as shall use the software only in * accordanc with the terms of the license agreement that * you entered into with George Ruthart. */ %> <%@ page import="java.util.*" %> <%@ page import="net.ruthart.rdbms.*" %> <%@ page import="org.apache.ecs.*" %> <%@ page import="org.apache.ecs.html.*" %> <%! String [] names; %> <% HashMap params = new HashMap(); String tableName = "prop", view = ""; String html = "", message = ""; LoginInfo li = new LoginInfo(); AuthInfo ai = li.getAuthInfo(request); String ft = null; if ((ft = request.getParameter("ft")) != null) { Vector tempVect = StringUtils.splitString(ft , " "); tableName = (String)tempVect.get(0); if (tempVect.size() > 1) view = (String)tempVect.get(1); else view = tableName; } String[] personCheckField = null; for (Enumeration e=request.getParameterNames(); e.hasMoreElements();) { String key = (String)e.nextElement(); String value[] = (String[])request.getParameterValues(key); if (key.equals(tableName + ".personcheck")) personCheckField = value; else if (key.startsWith(tableName) && value[0] != null && !value[0].equals("")) { params.put(key.toLowerCase(),value); } } if (ai.authed) { String[] midArr = {ai.memberId}; if (tableName.equals("memb") || tableName.equals("prop")) params.put(tableName + ".memberid" , midArr); } TableInfo tblInfo = new TableInfo(tableName); Table t1 = new Table(0); Add2db ad = new Add2db(); Db2rec d2r = new Db2rec(); try { if (li.checkSec(request, response, tblInfo, null, 0, ai, "add")) { Object autoKey; if ((autoKey = DbUtils.isUnique(tableName, params.keySet().toArray(), params.values().toArray())) == null) { message += new H3("Your information has been added to the ICIWorld data base as follows:").toString(); message += new H3(DbUtils.getMessage(tableName + "add")).toString(); // since personcheck was taken out, it has to be put back into params if (personCheckField != null) { params.put(tableName + ".personcheck", personCheckField); if (session.getAttribute("Answer") != null) { ad.setBotFlag(session.getAttribute("Answer").toString()); } } autoKey = ad.addRec(tableName, params, ai, null); } else { message += new H3(DbUtils.getMessage("notUnique")).toString(); } Vector rows = d2r.getRecordHtml(view, autoKey, ai); for (Enumeration e = rows.elements(); e.hasMoreElements(); ) { t1.addElement( (TR) e.nextElement()); t1.addElement("\n"); } } } catch (AuthenticationException ae) { ae.handleAuthError(getServletContext(), request, response); } html += t1.toString(); %> Add Record

Message

<% out.println(message); %> <% out.println(html); %>