tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Clark <a...@cyberneko.net>
Subject Re: Bending Jasper to My Will
Date Mon, 21 Apr 2008 18:43:42 GMT
Pid wrote:
> Andy Clark wrote:
>> I want Jasper to look for JSP and Tag files in a 
 >> specific location (e.g. based on a request param);
 >> and then fall back to a default location if the
 >> file is not found. This would be extremely useful
>> for skinning a webapp.
> 
> Cascading Style Sheets are an even more useful, 
 > practical and easier to implement solution for
 > skinning a webapp.
 >
 > Failing that, programmatically customising the HTML
 > output of a common set of tag files would be easier.

CSS and DHTML only applies to the client-side and
does not allow server-side customizations. We need
to go beyond simple color changes or even changing
the HTML layout; we need to be able to override any
or all tags and JSP files in parallel. In other
words, multiple versions of the code is deployed and
we want to control which application code to use
based on the user's settings.

Our application allows users to host multiple domains
and different user levels, each of which can have a
different skin. And we currently allow simple changes
to color, etc via CSS. But if the skin author wants to
change the functionality or layout, they must modify
the base JSP files/tags. Which means that *all* of
the skins see the changes. Not what we want.

For our customers, it is important to be able to
brand each skin independently and even control which
features are exposed via the interface. And we have
no way of knowing all the different ways in which the
customer wants to modify the application. And... they
should be able to do all of this without modifying
the web.xml file.

So what I would like to be able to do (transparently
from the user) is to, on a request-by-request basis,
determine which tags/JSP files to use based on that
user's skin preference. For example, if the user's
skin is set to "Foo", then I want to look for tag and
JSP file overrides in the skins/Foo/ directory and
use those; if I don't find them there, I want to
fallback and use the tags/JSP files in the default
directory.

I'll use a more precise example. Say that I have the
following files in my webapp:

   WEB-INF/tags/view.tag
   WEB-INF/tags/button.tag
   skins/Foo/tags/view.tag
   skins/Bar/tags/button.tag

with these contents:

   <%-- file: WEB-INF/tags/view.tag --%>
   <h1>Hello World</h1>
   <my:button text='Click Me' />

   <%-- file: WEB-INF/tags/button.tag --%>
   <%@ attribute name='text' required='true' %>
   <button>${text}</button>

   <%-- file: skins/Foo/tags/view.tag --%>
   <h1>Welcome to Clicky McClicker's Clicktastic Emporium</h1>
   <my:button text='Clickity Click' />

   <%-- file: skins/Bar/tags/button.tag --%>
   <%@ attribute name='text' required='true' %>
   <a href='#'>${text}</a>

If there are three users whose skin preference is
set to <undefined>, Foo, and Bar, respectively, then
the interface they see is completely different when
the JSP they hit uses <my:view /> in the page.

User 1 sees:

   <h1>Hello World</h1>
   <button>Click Me</button>

User 2 sees:

   <h1>Welcome to Clicky McClicker's Clicktastic Emporium</h1>
   <button>Clickity Click</button>

User 3 sees:

   <h1>Hello World</h1>
   <a href='#'>Click Me</a>

In essence, I need to control Jasper internally to
do two things:

1) resolve all requests for tag/JSP files at the
    requested location to look for the same file in
    the user's skin directory; and

2) failing to find the file in the first location,
    try again at the default location.

I hope this sheds some more light on what I need to
do. And I really hope there are some Jasper experts
on the list that can point me in the right direction
(even if it means patching the Jasper source).

> Customising a web app by implementing different sets 
 > of tag files seems like the hardest possible route.

True, but it's what I need to do. Unless there's some
other JSP trick that I'm missing...

-AndyC

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message