You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mikael Cluseau <nw...@nwrk.dyndns.org> on 2004/07/10 16:21:34 UTC
Tapestry skin functionnality
Hello,
I would like to build a skin system for Tapestry. If I understand
everything right, its a matter of building the right TemplateSource, but
I would like to contribute it to the Tapestry project, so I think people
on this list may be interested in flaming me :)
First, it should be consistent with the default Tapestry mode, so it
must use the DefaultTemplateSource's getTemplate() method as a fallback
if no theme specific template is found. The theme-specific templates
will then be stored in a user-defined subdirectory of WEB-INF,
defaulting to "skins" so that the skin "A" will have its templates in
"WEB-INF/skins/A" by default, and the template for "dir/X.page" will be
in "WEB-INF/skins/A/dir/X.html".
Second, it should be easy to tune : providing the current theme should
be done by a IThemeProvider like
public interface IThemeProvider {
/**
* Provide the active skin's name
* @return The active skin's name, or null if none.
*/
public String getCurrentSkinName();
}
A default implementation must :
public class DefaultThemeProvider implements IThemeProvider {
public String getCurrentSkinName() {
return null;
}
}
It seems to be simple (very few changes), consistent (falls back to the
default behaviour) and efficient (negligible overload).
If (at least) Howard agrees, I can start working on the TemplateSource.
Does someone know if it exists in WebObjects ?
Feedback please ;-)
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry skin functionnality
Posted by Mikael Cluseau <nw...@nwrk.dyndns.org>.
Le sam 10/07/2004 à 17:07, Howard Lewis Ship a écrit :
> This is a complex discussion, probably more suitable to the Wiki.
>
> Think of Tapestry pages as existing on a two dimensional matrix.
>
> The first dimension is the name of the page.
>
> The second dimension is the locale for the page.
>
> This affects not just finding templates, but also pooling. Tapestry
> uses a multi-key to find a page in the pool, a key that combines the
> page name with the page locale.
>
> Its pretty important that when a subseqent request for a page arrives,
> that the right page from the pool be found. All page- and
> component-oriented services (page, external, direct, action)
> incorporate the name of the page. The servlet API and/or an HTTP
> cookie provides the locale.
>
> Theme / skin or what have you adds a THIRD dimension.
>
Yes, I looked in DefaultTemplateSource code before writing, and seen the
MultiKey. But I still don't understand what the problem is, so I expose
my vision.
If everything is right and I have a full understanding of the Tapestry
universe (a bit true in fuzzy logic ;)), it shouldn't be more that
adding this "third dimension" to the cache map, changing the MultiKey
object to have a skinName property.
I suppose that, by definition, a skin doesn't change the logic behind
the page. It's writing a template to give another look, so it's like
adding a locale (say, translating for English to Chinese), it's the
dynamic selection of a set of compatible templates, using a fall back
template. This is my base assumption, if its wrong, I'm completely
wrong.
Consequently, the page name is the same, the page specification is the
same. What a programmer wants, intuitively, is to say "I want to render
the pages using this skin (set of templates)". If the requested template
isn't the given set, the failsafe action is to fall back to the default
behaviour, eventually logging this failure (maybe at warning or
user-defined log level).
> It's more complicated too; does this theme selector exist as a cookie,
> an extra query parameter (applied to all links and forms), or is it
> determined from application-specific data concerening a user (i.e., a
> property within the Visit)?
>
> I think it is reasonable to put together a somewhat
> application-specific library, template or pattern for use with
> Tapestry 3.0. In Tapestry 3.1 or 3.2, with the power of HiveMind, it
> will be reasonable to build a proper, general, flexible apprroach
> directly into Tapestry. HiveMind's pluggablility will allow us to
> handle that most difficult question: where does the theme come from?
Using a user-provider skin select, I think it's flexible and general. It
will be its role to look for the current skin whatever it is, using any
enterprise-specific policy, including using HiveMind.
Anyway, isn't it better than nothing ? As I said, I'm completely OK to
give any work I do on that to the Tapestry project. After that, you do
what you want with it. Anyway, I will do that for my work, and I'm ready
to work a bit more following your instructions if it can help Tapestry.
Sincerely,
Mikael Cluseau.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Tapestry skin functionnality
Posted by Howard Lewis Ship <hl...@gmail.com>.
This is a complex discussion, probably more suitable to the Wiki.
Think of Tapestry pages as existing on a two dimensional matrix.
The first dimension is the name of the page.
The second dimension is the locale for the page.
This affects not just finding templates, but also pooling. Tapestry
uses a multi-key to find a page in the pool, a key that combines the
page name with the page locale.
Its pretty important that when a subseqent request for a page arrives,
that the right page from the pool be found. All page- and
component-oriented services (page, external, direct, action)
incorporate the name of the page. The servlet API and/or an HTTP
cookie provides the locale.
Theme / skin or what have you adds a THIRD dimension.
It's more complicated too; does this theme selector exist as a cookie,
an extra query parameter (applied to all links and forms), or is it
determined from application-specific data concerening a user (i.e., a
property within the Visit)?
I think it is reasonable to put together a somewhat
application-specific library, template or pattern for use with
Tapestry 3.0. In Tapestry 3.1 or 3.2, with the power of HiveMind, it
will be reasonable to build a proper, general, flexible apprroach
directly into Tapestry. HiveMind's pluggablility will allow us to
handle that most difficult question: where does the theme come from?
On Sat, 10 Jul 2004 16:21:34 +0200, Mikael Cluseau <nw...@nwrk.dyndns.org> wrote:
> Hello,
>
> I would like to build a skin system for Tapestry. If I understand
> everything right, its a matter of building the right TemplateSource, but
> I would like to contribute it to the Tapestry project, so I think people
> on this list may be interested in flaming me :)
>
> First, it should be consistent with the default Tapestry mode, so it
> must use the DefaultTemplateSource's getTemplate() method as a fallback
> if no theme specific template is found. The theme-specific templates
> will then be stored in a user-defined subdirectory of WEB-INF,
> defaulting to "skins" so that the skin "A" will have its templates in
> "WEB-INF/skins/A" by default, and the template for "dir/X.page" will be
> in "WEB-INF/skins/A/dir/X.html".
>
> Second, it should be easy to tune : providing the current theme should
> be done by a IThemeProvider like
>
> public interface IThemeProvider {
> /**
> * Provide the active skin's name
> * @return The active skin's name, or null if none.
> */
> public String getCurrentSkinName();
>
> }
>
> A default implementation must :
>
> public class DefaultThemeProvider implements IThemeProvider {
> public String getCurrentSkinName() {
> return null;
> }
> }
>
> It seems to be simple (very few changes), consistent (falls back to the
> default behaviour) and efficient (negligible overload).
>
> If (at least) Howard agrees, I can start working on the TemplateSource.
> Does someone know if it exists in WebObjects ?
>
> Feedback please ;-)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Jakarta Tapestry
Creator, Jakarta HiveMind
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org