Corrected path to templates in FreeMarkerComponentGenerator. Contact form gets form action passed in by controller. Updated some comments.

This commit is contained in:
rjy7 2010-05-27 19:43:56 +00:00
parent ee2697f23f
commit 99a080ad3f
5 changed files with 48 additions and 11 deletions

View file

@ -72,10 +72,6 @@ public class BrowseController extends FreeMarkerHttpServlet {
String bodyTemplate = "classGroups.ftl";
String message = null;
// Set main page template attributes specific to this page
// But the template should control this! Try putting in a div inside the content.
//root.put("contentClass", "siteMap");
if( vreq.getParameter("clearcache") != null ) //mainly for debugging
clearGroupCache();

View file

@ -72,8 +72,8 @@ public class ContactFormController extends FreeMarkerHttpServlet {
body.put("portalType", portalType);
body.put("portalId", portalId);
body.put("formAction", "submitFeedback");
// Not used in template. Is it used in processing the form?
if (vreq.getHeader("Referer") == null) {
vreq.getSession().setAttribute("contactFormReferer","none");
} else {

View file

@ -20,7 +20,7 @@ public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(FreeMarkerHttpServlet.class.getName());
public FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
doSetup(request, response);
}
@ -41,7 +41,7 @@ public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
}
private String get(String templateName) {
String template = "components/" + templateName + ".ftl";
String template = "page/partials/" + templateName + ".ftl";
return mergeToTemplate(template, root).toString();
}

View file

@ -56,6 +56,9 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
protected int portalId;
protected String appName;
protected UrlBuilder urlBuilder;
// RY Change to private. Only used now by FreeMarkerComponentGenerator, which
// can be moved here as a nested class. Subclasses should not use root.
protected Map<String, Object> root = new HashMap<String, Object>();
public void doGet( HttpServletRequest request, HttpServletResponse response )
@ -85,10 +88,10 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
try {
super.doGet(request,response);
} catch (ServletException e) {
log.error("Servlet exception calling VitroHttpRequest.doGet()");
log.error("ServletException calling VitroHttpRequest.doGet()");
e.printStackTrace();
} catch (IOException e) {
log.error("IO exception calling VitroHttpRequest.doGet()");
log.error("IOException calling VitroHttpRequest.doGet()");
e.printStackTrace();
}
}
@ -331,7 +334,7 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
}
}
// Can be overridden by individual controllers
// Can be overridden by individual controllers to use a different basic page layout.
protected String getPageTemplateName() {
return "default.ftl";
}
@ -354,4 +357,42 @@ public class FreeMarkerHttpServlet extends VitroHttpServlet {
request.setAttribute("ftl_footer", fcg.getFooter());
}
/**
* TEMPORARY for transition from JSP to FreeMarker. Once transition
* is complete and no more pages are generated in JSP, this can be removed.
*
* @author rjy7
*
*/
// public class FreeMarkerComponentGenerator extends FreeMarkerHttpServlet {
//
// private static final long serialVersionUID = 1L;
//
// FreeMarkerComponentGenerator(HttpServletRequest request, HttpServletResponse response) {
// doSetup(request, response);
// }
//
// public String getIdentity() {
// return get("identity");
// }
//
// public String getMenu() {
// return get("menu");
// }
//
// public String getSearch() {
// return get("search");
// }
//
// public String getFooter() {
// return get("footer");
// }
//
// private String get(String templateName) {
// String template = "partials/" + templateName + ".ftl";
// return mergeToTemplate(template, root).toString();
// }
//
// }
}

View file

@ -27,7 +27,7 @@
</p>
</#if>
<form name="contact_form" id="contact_form" action="submitFeedback" method="post" onsubmit="return ValidateForm('contact_form');">
<form name="contact_form" id="contact_form" action="${formAction}" method="post" onsubmit="return ValidateForm('contact_form');">
<input type="hidden" name="home" value="${portalId}"/>
<input type="hidden" name="RequiredFields" value="webusername,webuseremail,s34gfd88p9x1"/>
<input type="hidden" name="RequiredFieldsNames" value="Name,Email address,Comments"/>