<%@page buffer="none" session="false" import="org.opencms.i18n.*,org.opencms.frontend.templateone.form.*, java.util.*" %><% // initialize the form handler CmsFormHandler cms = new CmsFormHandler(pageContext, request, response); // get the localized messages to create the form CmsMessages messages = cms.getMessages(); // get the template to display String template = cms.property("template", "search", "/system/modules/org.opencms.frontend.templateone/templates/main"); // include the template head cms.include(template, "head"); out.println("
"); boolean showForm = cms.showForm(); if (! showForm) { // form has been submitted with correct values, decide further actions if (cms.showCheck()) { // show optional check page request.setAttribute("formhandler", cms); cms.include("../elements/check.jsp"); } else if (cms.getFormConfiguration().hasTargetUri()) { response.sendRedirect(cms.link(cms.getFormConfiguration().getTargetUri())); } else { // try to send a notification email with the submitted form field values if (cms.sendMail()) { // successfully sent mail, show confirmation end page request.setAttribute("formhandler", cms); cms.include("../elements/confirmation.jsp"); } else { // failure sending mail, show error output %>

<%= messages.key("form.error.mail.headline") %>

<%= messages.key("form.error.mail.text") %>

<% } } } else { // get the configured form elements CmsForm formConfiguration = cms.getFormConfiguration(); List fields = formConfiguration.getFields(); // show form text out.print(formConfiguration.getFormText()); // show global error message if validation failed if (cms.hasValidationErrors()) { out.print("

"); out.print(messages.key("form.html.label.error.start")); out.print(messages.key("form.error.message")); out.print(messages.key("form.html.label.error.end")); out.println("

"); } // create the form head %>
<%= messages.key("form.html.start") %><%= formConfiguration.getFormAttributes() %>> <% // create the html output to display the form fields int pos=0; int place=0; for( int i = 0, n = fields.size(); i < n; i++) { // loop through all form input fields I_CmsField field = (I_CmsField)fields.get(i); if(i==n-1)place=1; //the last one must close the tr field.setPlaceholder(place); field.setPosition(pos); String errorMessage = (String)cms.getErrors().get(field.getName()); out.println(field.buildHtml(cms, messages, errorMessage)); pos=field.getPosition(); place=field.getPlaceholder(); } // create the form foot if (formConfiguration.hasMandatoryFields()) { %><%= messages.key("form.html.row.start") %> <%= messages.key("form.html.button.start") %><%= messages.key("form.message.mandatory") %><%= messages.key("form.html.button.end") %> <%= messages.key("form.html.row.end") %> <% } %><%= messages.key("form.html.row.start") %> <%= messages.key("form.html.button.start") %>" class="formbutton"/>" class="formbutton"/><%= messages.key("form.html.button.end") %> <%= messages.key("form.html.row.end") %> <%= messages.key("form.html.end") %>
<%//     } out.println("
"); // include the template foot cms.include(template, "foot"); %>