The template example defines a content JSP for each page in your
application. Each of  these may also have a companion HTML file with
the unique content for each page. 

page1.jsp <- page1.html 
page2.jsp < page2.html

This means you can keep your page content out of the JSP environment
all together. 

In practice, the only difference between page1.jsp and page2.jsp may be
where they get their unique content. 

All of these page files could also use other common elements, like 

header.html
menu.html
footer.html

which would be defined once for all the pages, and reference by each of
the page?.jsp above. These could also be JSP files, if needed.

The final element is the actual template file. In the example, this is
chapterTemplate.jsp. This defines the actual layout of the elements. 

Each of the page?.jsp's mentioned above, just say "what" to include,
not where to put it on the page.

You can do things like change the position of the menu bar without
editing all the page?.jsp files. You would just have to edit the
chapterTemplate.jsp file. Depending on how closely things were layed
out, it's also possible that you may need to edit the other common
elements (header.html, menu.html, footer.html - three files total), but
you would not need to edit the many page?.jsp's.

So in the end, your directly may look like this

header.html
menu.html
footer.html
template.jsp
page1.jsp
page1.html
page2.jsp
page2.html
< ... />
page999.jsp
page999.html

I'm not saying this is better or worse than Cedric's components, but I
think the Struts library will do what you mentioned.

*********** REPLY SEPARATOR  ***********

On 1/10/2001 at 4:01 PM Warren Strange wrote:

Hi,

I am just get started with struts, and have a question on templates.

>From the example given (templates-example) , it appears that you need
a
template file
for each content JSP that you want to lay out using the template. For
example:

introduction.html  (the content), and introduction.jsp (the template
reference)

optional.html (the content)  and optional.jsp (the template reference)

and so on....

This approach seems rather cumbersome to me. If you want to change the
template
you might have go back and edit all the template reference files (e.g.
say
you add
'rightSideBar'  content, or something like that).

I want to define one common template (which includes standard headers,
footer,
etc. - possibly changing their behavior dynamically) and have it
applied
automatically
 to all my content.


How is done?

Thanks

Warren



Reply via email to