Hi Sven,

If I understand correctly you want to check for the existence of a
template on the servlet path (war) first,
and if not found try and load it from the classpath (standard-package).

Here is some code that returns the template name depending on the
above criteria:

  public String getTemplateToRender() {
    // Derive template name from page name
    String templateName = getClass().getSimpleName();

    String templatePath = "/click/" + templateName + ".htm";

    try {
      Context context = getContext();

      // First check for template on the servlet context path
      hasTemplate =
context.getServletContext().getResource(templatePath) != null;
      if (hasTemplate) {

        return templatePath;
      } else {

        // Otherwise return the class path as the template e.g.
com.myapp.control.MyPanel.htm
        templatePath = getClass().getName();
        templatePath = '/' + templatePath.replace('.', '/') + ".htm";
        return templatePath;
      }

Click can render templates from both servlet path and classpath, so
the above should be all you need.

Do you need to cater for Page templates or Control templates or both?

kind regards

bob

On Sat, Aug 15, 2009 at 12:35 AM, Sven Pfeiffer<[email protected]> wrote:
> Hi List,
>
> to be able to offer my customers customizations of my webapp I would
> like to provide a "standard-package" (e.g. bundled in a jar) and the
> customized versions of my classes/templates in the custom war.
>
> If possible I would like to build it similar to the way click does when
> choosing which template to use to render e.g. a TabbedForm.
> If there is afile click/TabbedForm.htm, it uses this file, otherwise it
> uses the default from the jar.
>
> I started to look at the frameworks-classes, especially ClickServlet and
> the XmlConfigService, but I am not quite sure where to start.
>
> Any help is very much appreciated.
>
> Thanks in advance
> SVen
>



-- 
http://incubator.apache.org/click/

Reply via email to