struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cedric Dumoulin <cedric.dumou...@lifl.fr>
Subject Re: content map population
Date Tue, 13 Mar 2001 08:57:36 GMT

  Not yet, but in a few days I will provide such facilities for
Templates. If you want to know how it will work, I have put an extract
of a previous mail at the end of this mail.

    Cedric

Joe Mathews wrote:

> I am using template tag library for my project. All
> the template files in my project are dynamic.
>   Is is possible to populate the content map in my
> java code and use it along with insert template
> Thanks
> Joe
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - Buy the things you want at great prices.
> http://auctions.yahoo.com/

Extract from "Re: PROPOSAL: Template Screens"
...
  I think that we can reuse actual Templates syntax, rather than
introducing too
much new tags or using scriptlet. This will simplify learning and
comprehension of
Templates.

  Following is an example of how we could define a screen inside a jsp :

--------------
<template:screenDefinition id='introductionScreen' scope='request'
template='/chapterTemplate.jsp' >
  <template:put name='title' content='Templates' direct='true'/>
  <template:put name='header' content='/header.html' />
  <template:put name='sidebar' content='/sidebar.jsp' />
  <template:put name='content' content='/introduction.html'/>
  <template:put name='footer' content='/footer.html' />
</template:screenDefinition>
---------------

To use it :
  <template:insert definition='introductionScreen' />

---------------
Or, if you want to overload one attribute :
  <template:insert template='/anotherchapterTemplate.jsp'
definition='introductionScreen' />

---------------
Or,  if you want to overload or add others attributes :
  <template:insert  definition='introductionScreen' >
    <put name='title' content='Another Title' />
    <put name='leftSidebar' content='/leftsidebar.jsp' />
  </template:insert>'

---------------
 Some comments :

   * In the "screenDefinition", you can define all or only some of the
attributes.
     So, you can drop "template='/chapterTemplate.jsp' "
   * If you specify some attributes in 'insert' tag, they overload
previously
     defined attributes, or add new one.
   * This syntax is implementation independent : object produced by tag
handler
     'template:screenDefinition' could be a Map, or a complex structure.

   * There is no 'role' attribute in the example, but we can use it.
   * Advantage of this syntax is that it is the same than 'insert'. This
syntax can
     also be used in a xml description file, without introducing new
concepts.
   * Another advantage, is that there is no scriplet inside JSP page.

Now, we need to find a way to define 'screenDefinition' outside a JSP
page (ex: in
action).
A Map could be a candidate. But putting 'content', 'content-type'
(direct) and
'role' inside Map's value is not so easy to use.
We could thing of a class ScreenDefinition, having some method
reflecting the tag
syntax :
  setTemplate( String templateName )
  put( String name, Object content );
  put( String name, Object content, boolean direct );
  put( String name, Object content, boolean direct, String role );
     ...
  Such class could be easiest to use in code. Once an instance is
created, it is
put in servlet context (request, session, ...).
Then, object is used in the same way as if it is define in the JSP page
:
  <template:insert definition='screenDefinitionName' />

However, it is possible to implement <insert definition="aDefinition" />
in order
to accept a Map as well as a ScreenDefinition, if we want to keep both
possibilities.

   Last, I thing that tag name 'template:screenDefinition' is too
restrictive : we
could effectively define a screen , but we can do much more with it,
like defining
a 'Component' ;-) . So maybe we need to propose something else for this
tag name
(first ideas : 'template:definition', or 'template:instance' ).

    Cedric
...




Mime
View raw message