You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Viet Kevin <vi...@activia.net> on 2001/07/22 14:26:33 UTC

questions about template

Hello all, 

I have little questions about template tags, i'm wondering about how to use it properly.

In fact i know that i have to create a template file (with get tags nested in template tag).
Once I have created this file I don't know how to use it well.
For the moment I'm thinking that after the action has done it's job, I forward to a jsp that  use the template file. The thing i don't understand is that I don't know where to put my real view code (the one that is not like table header or a table footer): the jsp-code that make the view of the MVC pattern

Thanx for help

RE: questions about template

Posted by eden <ed...@jamethial.ath.cx>.
Hi vietk!

I haven't seen anyone reply to this message yet, so on the chance that you
haven't gotten the answer, here's some help.

The template you set up should have an additional call to the actual page
that you've written.  This can be done by defiinig a call to a "content"
section of the template.  For example, your template definition page could
look like this:

<table>
	<tr valign='top'>
		<td><template:get name='sidebar'/></td>
      	<td>
			<table>
	            	<tr><td><template:get name='header'/></td></tr>
     				<tr><td><template:get name='main'/></td></tr>
            		<tr><td><template:get name='footer'/></td></tr>
   			</table>
      	</td>
	</tr>
</table>

Here, the call to the 'content' would be the actual jsp page that you've
written.  The problem that you might be having is that you may not realize
that this requires you to write 2 jsp pages, not one.  The first page (let's
call it 'content.jsp') would look like:

<%@ page language="java" %>

<template:put name='header' content='header.jsp'>
<template:put name='main' content='contentPage.jsp'> <-- This is where the
'good stuff' goes
<template:put name='footer' content='footer.jsp'>

All your view, code, and other fancy shenanigans, go in the contentPage.jsp,
where it will be nicely sandwiched between a header and a footer (if you
choose).

If you need more background (or even if you don't :) visit the Struts
template api at:
http://jakarta.apache.org/struts/api/org/apache/struts/taglib/template/packa
ge-summary.html#package_description

Hope this helps,
Melissa


-----Original Message-----
From: Viet Kevin [mailto:vietk@activia.net]
Sent: Sunday, July 22, 2001 8:27 AM
To: struts-user@jakarta.apache.org
Subject: questions about template


Hello all,

I have little questions about template tags, i'm wondering about how to use
it properly.

In fact i know that i have to create a template file (with get tags nested
in template tag).
Once I have created this file I don't know how to use it well.
For the moment I'm thinking that after the action has done it's job, I
forward to a jsp that  use the template file. The thing i don't understand
is that I don't know where to put my real view code (the one that is not
like table header or a table footer): the jsp-code that make the view of the
MVC pattern

Thanx for help