Important

JSP files generated by MD4J have various dependencies you have to take care of in your project. Most of these dependencies are located in the WAR/md4j-dep directory during runtime. This page documents the whole thing with examples where applicable.

Includes

MD4J-generated JSP files have Page Include Directives (i.e. compile time includes). You need to create those yourself based on your requirements. Sample files for use with Struts 1.x are provided below for your convinience, starting with header.inc:

<!-- /md4j-dep/header.inc for Struts 1.x -->
<html  xmlns="http://www.w3.org/1999/xhtml" xml:lang="${sessionScope['org.apache.struts.action.LOCALE']}" 
       lang="${sessionScope['org.apache.struts.action.LOCALE']}">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
		<c:if test="${not empty pageScope.windowTitle}">
			<title>
				<c:out value="extradrive.gr - ${pageScope.windowTitle}" />
			</title>
		</c:if>
		<style type="text/css" media="screen">
		    @import "<jsp:expression>request.getContextPath()</jsp:expression>/css/main.css";
		</style>
	</head>
	<body>
		<div id="container">
			<!-- header begin-->
			<div id="header">
				<!-- header markup here -->
			</div>
			<!-- header ends -->
			<!-- menu begins -->
			<div id="menu">
				<!-- menu markup here -->
			</div>
			<!-- menu ends -->
			<!-- contet begins -->
			<div id="content">
      

for search pages, you need a paging.inc:

<!-- /md4j-dep/paging.inc for Struts 1.x -->
<c:if test="${requestScope.results.totalPageCount gt 1}">
    <p class="paging">
        <c:if test="${not empty requestScope.results.totalResultCount}">
            <c:out value="${requestScope.results.totalResultCount}" />
            <span><jsp:text> </jsp:text></span>
            <bean:message key="seach.results.matched.your.criteria"/>
            <span><jsp:text>: </jsp:text></span>
        </c:if>
        <c:if test="${requestScope.results.pageNumber gt 1}">
            <jsp:text> </jsp:text>
            <a href="${pageScope.searchUrl}&amp;resultsPageNumber=1
                &amp;org.apache.struts.taglib.html.TOKEN=${sessionScope['org.apache.struts.action.TOKEN']}">
                <bean:message key="first"/>
            </a>
            <span><jsp:text> - </jsp:text></span>
        </c:if>
        <c:if test="${requestScope.results.pageNumber gt 2}">
            <jsp:text> </jsp:text>
            <a href="${pageScope.searchUrl}&amp;resultsPageNumber=${requestScope.results.pageNumber-1}
                &amp;org.apache.struts.taglib.html.TOKEN=${sessionScope['org.apache.struts.action.TOKEN']}">
                <bean:message key="previous"/>
            </a>
            <span><jsp:text> - </jsp:text></span>
        </c:if>
        <c:if test="${requestScope.results.pageNumber lt (requestScope.results.totalPageCount - 1)}">
            <jsp:text> </jsp:text>
            <a href="${pageScope.searchUrl}&amp;resultsPageNumber=${requestScope.results.pageNumber+1}
                &amp;org.apache.struts.taglib.html.TOKEN=${sessionScope['org.apache.struts.action.TOKEN']}">
                <bean:message key="next"/>
            </a>
            <span><jsp:text> - </jsp:text></span>
        </c:if>
        <c:if test="${requestScope.results.pageNumber lt requestScope.results.totalPageCount}">
            <jsp:text> </jsp:text>
            <a href="${pageScope.searchUrl}&amp;resultsPageNumber=${requestScope.results.totalPageCount}
                &amp;org.apache.struts.taglib.html.TOKEN=${sessionScope['org.apache.struts.action.TOKEN']}">
                <bean:message key="last"/>
            </a>
        </c:if>
    </p>
</c:if>
      

and the last include is footer.inc:

            <!-- /md4j-dep/footer.inc for Struts 1.x -->
			</div>
			<!-- contet ends -->
			<!-- footer begins -->
			<div id="footer">
				<!-- footer markup here -->
			</div>
			<!-- footer ends -->
		</div>
	    <!-- container ends -->
	</body>
</html>
      

Validator

JSP files for use with Struts 1.x need the following as validator-static-js.jsp:

<?xml version="1.0" encoding="UTF-8"?>
<!-- /md4j-dep/validator-static-js.jsp for Struts 1.x -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" 
    xmlns:html="http://struts.apache.org/tags-html-el" 
    version="2.0">
    <jsp:directive.page language="java" contentType="text/javascript; charset=utf-8"/>
    <jsp:directive.page session="false" />
	<html:javascript dynamicJavascript="false" staticJavascript="true"/>
</jsp:root>
      

Date Controls

By default MD4J JSPs use The DHTML Calendar by Mihai Bazon, licensed under the LGPL. Neat. This is used for date input in forms so you need to set it up:

  1. Download the thing
  2. Unarchive and, if needed, rename the distribution directory to "jscalendar"
  3. Drop the directory in /md4j-dep