You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Øystein Amundsen <oy...@bouvet.no> on 2006/11/13 13:22:57 UTC

Can a template use another template?

Hi.

We've been using Beehive for almost a month now. I have great experience in Java and writing servlets, but this is my first go at both jsp and beehive technologies. I should be considered a novice as such. 

Upon developing our proof of concept, we've discovered the use for placing netui-templates inside a master template. Consider the following:

The master template should consist of the applications main menu and other components building the skeleton of the application. This template should only include one large main section. All modules pertaining to the applications functional aspect, should each use their own template extending the master template. This way, we can completely separate all HTML code and functional business logic.

>From a technical point of view, we're trying;

--------------------------------------
 MainTemplate.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8"%>

<%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>

<netui:html>
<head>
  <title>MyTitle</title>
  <link rel="Stylesheet" href="<%=request.getContextPath()%>/templates/style.css" />
</head>

<netui:body>
 ...
<netui-template:includeSection name="docPath" />
 ...
<jsp:include page="menu.jsp" />
...
</netui:body>
</netui:html>


--------------------------------------
 ComponentTemplate.jsp
<%@ page language="java" contentType="text/html;charset=UTF-8"%>

<%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>

<netui-template:template templatePage="../../../../../templates/mainPage.jsp">
  <netui-template:section name="docPath">
...
  </netui-template:section>

  <netui-template:section name="docContent">
...
    <netui-template:includeSection name="detailContent" />
...
  </netui-template:section>
</netui-template:template>


--------------------------------------

The result is a page returning with an error message stating that the template does not contain any section with the name "detailContent".

Is this not possible? 
Does every module need to carry it's own html, however similar to other parts of the system, or, does every module's template page need to implement the same html as the MainTemplate.jsp?



--------------------------------------
Øystein Amundsen
Bouvet AS, System developer

mail    : oystein.amundsen@bouvet.no 	
mobile  : 480 19 009 	
address : Noreveien 4, 5542 Haugesund 	


Re: Can a template use another template?

Posted by Carlin Rogers <ca...@gmail.com>.
Hi Øystein,

Unfortunately, no, the NetUI template tag does not support templates
within templates. I took a look through the implementation of the tag
and did not see support for this.

Specifically, I noticed that the template tag creates a new template
context object and adds it to the request. It has a HashMap for
holding the body content of each section tag defined in a JSP. In your
example, the 'detailContent' section is defined in your initial JSP
and is put in the sections HashMap for the ComponentTemplate.jsp
template. Then when the ComponentTemplate.jsp is processed, there is
another template tag for MainTemplate.jsp, so a new template context
object is created. It replaces the original one on the request. It
does not have the 'detailContent' section in its HashMap of sections.
Then, when the the includeSection tag in ComponentTemplate.jsp is
processed, it cannot find the body content for that section.

Carlin

On 11/13/06, Øystein Amundsen <oy...@bouvet.no> wrote:
> Hi.
>
> We've been using Beehive for almost a month now. I have great experience in Java and writing servlets, but this is my first go at both jsp and beehive technologies. I should be considered a novice as such.
>
> Upon developing our proof of concept, we've discovered the use for placing netui-templates inside a master template. Consider the following:
>
> The master template should consist of the applications main menu and other components building the skeleton of the application. This template should only include one large main section. All modules pertaining to the applications functional aspect, should each use their own template extending the master template. This way, we can completely separate all HTML code and functional business logic.
>
> From a technical point of view, we're trying;
>
> --------------------------------------
>  MainTemplate.jsp
> <%@ page language="java" contentType="text/html;charset=UTF-8"%>
>
> <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
> <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
> <%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
>
> <netui:html>
> <head>
>   <title>MyTitle</title>
>   <link rel="Stylesheet" href="<%=request.getContextPath()%>/templates/style.css" />
> </head>
>
> <netui:body>
>  ...
> <netui-template:includeSection name="docPath" />
>  ...
> <jsp:include page="menu.jsp" />
> ...
> </netui:body>
> </netui:html>
>
>
> --------------------------------------
>  ComponentTemplate.jsp
> <%@ page language="java" contentType="text/html;charset=UTF-8"%>
>
> <%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
> <%@taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
> <%@taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
>
> <netui-template:template templatePage="../../../../../templates/mainPage.jsp">
>   <netui-template:section name="docPath">
> ...
>   </netui-template:section>
>
>   <netui-template:section name="docContent">
> ...
>     <netui-template:includeSection name="detailContent" />
> ...
>   </netui-template:section>
> </netui-template:template>
>
>
> --------------------------------------
>
> The result is a page returning with an error message stating that the template does not contain any section with the name "detailContent".
>
> Is this not possible?
> Does every module need to carry it's own html, however similar to other parts of the system, or, does every module's template page need to implement the same html as the MainTemplate.jsp?
>
>
>
> --------------------------------------
> Øystein Amundsen
> Bouvet AS, System developer
>
> mail    : oystein.amundsen@bouvet.no
> mobile  : 480 19 009
> address : Noreveien 4, 5542 Haugesund
>
>