These notes illustrate an interesting way of developing and using capture tags in jsp to accomodate masterpages or tiles. This specific example talks about how this is done in AspireWeb but the ideas can be easily extended to any java based server side framework.

The notes will explore a) how to define a jsp page in response to an incoming url in an MVC fashion b) it then goes into identifying a tiles or masterpage pertaining to that URL c) an example of the master page d) an example of the jsp page with capture tags e) the resulting out put combining the master page and the url specific jsp page. f) what the incoming url will look like

satya - Friday, November 30, 2007 4:34:59 PM

Define your primary content page


captestJSPURL=/testdir/capture/capture-test1.jsp
captestJSPURL.transformType=JSP
request.captestJSPURL.transform.className=com.ai.jsp.JSPTransform
captestJSPURL.dataRequestName=mydata

request.mydata.className=com.ai.htmlgen.DBHashTableFormHandler1

satya - Friday, November 30, 2007 4:35:17 PM

Define your master page


#############################################
# Your master jsp page
#############################################
captestURL=aspire:\\testdir\\capture\\captest.html

satya - Friday, November 30, 2007 4:38:58 PM

The master page looks like: captest.html


<html>
  <head>
    <title>A custom tag: body content</title>
  </head>
<body>
<hr>
{{cap1}}
<hr>
<p>After
</body>
</html>

satya - Friday, November 30, 2007 4:39:43 PM

the content jsp looks like:capture-test1.jsp


<%@ taglib uri="/aic" prefix="aic" %>

<%@ page import="com.ai.htmlgen.*" %>
<%@ page import="com.ai.application.utils.*" %>
<%@ page import="com.ai.common.*" %>
<%@ page import="com.ai.aspire.utils.*" %>

<%!
String hello()
{
	return "helloworld. in deed";
}
%>

<%
	ihds pageData = (ihds)request.getAttribute("Aspire.formHandler");
	if (pageData == null)
	{
	   out.println("Some html segment about empty data set if needed");
	   return;      
	}    
%>	

<aic:CaptureTag captureAsName="cap1">
  	<p>Hello world</p>
  	<p>
  	<%="My name is super"%> <%=hello()%>
  	</p>
</aic:CaptureTag>

<!--
***********************************************
* End game. Going for a master page.
***********************************************
-->
<%
String cap1Value = (String)request.getAttribute("cap1");
java.util.HashMap map = new java.util.HashMap();
map.put("cap1",cap1Value);
java.io.PrintWriter myout = new java.io.PrintWriter(out);
TransformUtils.transformHds("captestUrl",myout,(IFormHandler)pageData,map);
%>

satya - Friday, November 30, 2007 4:40:27 PM

The generated output looks like


<!--
***********************************************
* End game. Going for a master page.
***********************************************
-->
<html>
  <head>
    <title>A custom tag: body content</title>
  </head>
<body>
<hr>

  	<p>Hello world</p>
  	<p>
  	My name is super helloworld. in deed
  	</p>

<hr>
<p>After
<hr>

</body>
</html>

satya - Friday, November 30, 2007 4:40:49 PM

The url will be


http://localhost:8181/akc/display?url=captestJSPURL

satya - Tuesday, April 15, 2008 9:00:16 AM

updated property file section


###################################
# ShowFiledReportsViewIMPJSPURL
###################################
ShowFiledReportsViewIMPJSPURL=/reports/report-filing/reports-summary-view-imp.jsp
ShowFiledReportsViewIMPJSPURL.transformType=JSP
request.ShowFiledReportsViewIMPJSPURL.transform.className=com.ai.jsp.MPJSPIncludeTransform
ShowFiledReportsViewIMPJSPURL.dataRequestName=ShowFiledReportsViewURLFormHandler
ShowFiledReportsViewIMPJSPURL.masterPageRequestName=GetMasterPage
ShowFiledReportsViewIMPJSPURL.masterPageURL=captestURL2