<%@ page language="java" import="historyPlaces.*,java.util.*" %>
<%@ include file="header.inc" %>
<%-- Initialize DB --%>
<%
engine db = new engine();
String parentParam = "";
String nameParam = "";
String commentParam = "";
String submitParam = "";
parentParam = request.getParameter("parent");
nameParam = request.getParameter("name");
commentParam = request.getParameter("comment");
submitParam = request.getParameter("submit");
int parentInt = -1;
if(parentParam != null){
Integer parentInteger = new Integer(parentParam);
parentInt = parentInteger.intValue();
}
if(submitParam == null){
submitParam = "NOT CREATE";
}
if(submitParam.compareTo("Create") != 0){
if(parentParam != null){ /* Paramater is passed */
%>
<h2>Create a Place!</h2>
<form name="createPlace" action="./create.jsp?action=post">
Name of Place: <input name="name" type="text" id="name" size="35" maxlength="100" /><br />
Your Parent: <%
place yourPlace = db.getPlace(parentInt);
String name = yourPlace.getPlaceName();
out.print(name);
%>
<br />
Comment about Place:<br/><textarea name="comment" id="comment" cols="20" rows="10"></textarea><br />
<input name="parent" type="hidden" value="<% out.print(parentInt); %>" />
<input name="submit" type="submit" value="Create" />
<input type="reset" name="_reload" value="Reset Form" />
</form>
<%
}else{ /* For when a paramater is not passed */
%>
<h2>You must select a parent place to continue</h2>
Please pick one from the <a href="./list.jsp">directory listing</a>.
<p>The focus on this part of History Places is to provide the user with an interface to create a place. Depending on where the user is coming from (hierarchy or elsewhere) they will have the option to also select their parent place. If a parent place is not provided a directory style listing will be displayed to the user to have them pick a place. To see the alphabetical directory listing of all places do not pass a parent ID to the JSP file.</p>
<%
}
}else{
out.print("<strong>Place Added!</strong><br/>\nGo back <a href=\"./index.jsp\">Home</a>");
db.addPlace(parentInt, nameParam, commentParam);
}
%>
<%@ include file="footer.inc" %>