[opencms-dev] templateone email form errors

Mike Rollberg, Jr. mike at purplemonkey.com
Wed Oct 19 22:33:14 CEST 2005


I am trying to modify the fields available in emailform type. I have
made a copy of the module templateone.form and I can now edit my version
called form_builder, which means my XSD file is correct. I cannot view
the file in a browser by clicking on it. I get the following errors:
 
When I click on the file I get:
Unable to compile class for JSP
An error occurred at line: 6 in the jsp file
/WEB-INF/jsp/offline.system/m,odules/com.purplemonkey.harvest.form/pages
/form.html.jsp
Generated servlet error:
CmsFormHandler cannot be resolved or is not a type
 
 
Here is the contents of form.html in the pages folder:
<%@page buffer="none" session="false" %>
<%@page import="org.opencms.i18n.*" %>
<%@page import="com.purplemonkey.harvest.form.*" %>
<%@page import="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/com.purplemonkey.harvest/templates/popup");
 
// include the template head
cms.include(template, "head");
out.println("<div class=\"element\">");
 
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 {
  // 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 %>
   <h2><%= messages.key("form.error.mail.headline") %></h2>
   <p><%= messages.key("form.error.mail.text") %></p>
 
   <!--
   Error description: <%= (String)cms.getErrors().get("sendmail") %>
   //-->
<%
  }
 }
 
} 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("<p>");
  out.print(messages.key("form.html.label.error.start"));
  out.print(messages.key("form.error.message"));
  out.print(messages.key("form.html.label.error.start"));
  out.println("</p>");
 }
 
 // create the form head 
 %> <form name="emailform" action="<%=
cms.link(cms.getRequestContext().getUri()) %>" method="post"
style="margin-top: 14px; margin-bottom: 0; padding: 0;">
 <input type="hidden" name="<%= CmsFormHandler.PARAM_FORMACTION %>"
value="<%= CmsFormHandler.ACTION_SUBMIT %>">
 <%= messages.key("form.html.start") %><%=
formConfiguration.getFormAttributes() %>>
 

  <%
// 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") %>
  <%
 }
 // create the html output to display the form fields
 Iterator i = fields.iterator(); 
 while (i.hasNext()) {
  
  // loop through all form input fields 
  CmsField field = (CmsField)i.next();
  String fieldType = field.getType(); 
  String fieldLabel = field.getLabel(); 
  // get the error message and mandatory marker for the current field
  String errorMessage = (String)cms.getErrors().get(field.getName());
  String mandatory = "";
  if (errorMessage != null) {
   // create the error message for the field
   if (CmsFormHandler.ERROR_MANDATORY.equals(errorMessage)) {
    errorMessage = messages.key("form.error.mandatory");
   } else {
    errorMessage = messages.key("form.error.validation");
   }
   errorMessage = messages.key("form.html.error.start") + errorMessage +
messages.key("form.html.error.end");
   fieldLabel = messages.key("form.html.label.error.start") + fieldLabel
+ messages.key("form.html.label.error.end");
  } else {
   errorMessage = "";
  }
  if (field.isMandatory()) {
   mandatory = messages.key("form.html.mandatory");
  }
  
  // generate the input field
  %><%@ include file="../jsptemplates/inputfields.txt" %><%
 }
 
 
  %><%= messages.key("form.html.row.start") %>
   <td class="buttons" colspan="2"><input type="submit" value="<%=
messages.key("form.button.submit") %>"
class="formbutton">    <input type="reset"
value="<%= messages.key("form.button.reset") %>"
class="formbutton"></td>
  <%= messages.key("form.html.row.end") %>
 <%= messages.key("form.html.end") %>
 </form><%
 
}
 
out.println("</div>");
// include the template foot
cms.include(template, "foot");
 
%>

 
 

-- 
Michael Rollberg, Jr. 
Senior Programmer 
Purple Monkey Studios, Inc. 
T: 708 386 3086 
F: 708 386 7589 
mike at purplemonkey.com 
www.purplemonkey.com 

Interactive media. We get creative; you get results. 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20051019/ea3eb320/attachment.htm>


More information about the opencms-dev mailing list