Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-1035

Allow common stylesheets/favicon/geoinfo/doctype settings across pages/requests

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 4.1.1
    • 4.1.2
    • Framework
    • None
    • Any

    Description

      I have been using my own custom Shell component for a while now, and have come up with an improvement along the lines of the AjaxDelegate.

      On most sites you would want a common setup for :

      doctype
      stylesheet
      stylesheets

      You might even want to implement a skinnable concept and vary the stylesheets depending on the user.

      How about new parameter IShellDefaults getShellDefaults().

      <parameter
      name="shellDefaults">
      <description>
      If specified, the defaults can provide a common layout and encoding for the site overall or by user preference.
      </description>
      </parameter>

      public abstract IShellDefaults getShellDefaults();

      interface IShellDefault {
      String getDoctype(IRequestCycle cycle);
      boolean getRenderContentType(IRequestCycle cycle);
      Object getBaseStylesheets(IRequestCycle cycle); // Always used before getStylesheet() or those specified in Shell tag
      Object getStylesheets(IRequestCycle cycle); // Used if none are specified in the Shell tag
      IAsset getFavicon(IRequestCycle cycle);
      IDelegate getDelegate(); // Can be used for additional meta tags/links
      }

      I expect the changes to be something like this(favicon excluded)
      ---------
      IShellDefaults defs = getShellDefaults();

      boolean renderCT = getRenderContentType();
      if (defs != null)
      renderCT &= defs.getRenderContentType(cycle);
      if (renderCT)
      writeMetaTag(writer, "http-equiv", "Content-Type", writer.getContentType());

      if (defs != null) {
      IRender delegate = defs.getDelegate(cycle);
      if (delegate != null)
      delegate.render(writer, cycle);
      }

      if (defs != null) {
      Iterator i = (Iterator) getValueConverter().coerceValue(defs.getBaseStylesheets(cycle),Iterator.class);
      while (i.hasNext())

      { stylesheet = (IAsset) i.next(); writeStylesheetLink(writer, cycle, stylesheet); }
      }
      if (defs != null && getStylesheet()==null && getStylesheets()==null) {
      Iterator i = (Iterator) getValueConverter().coerceValue(defs.getStylesheets(cycle),Iterator.class);
      while (i.hasNext())
      { stylesheet = (IAsset) i.next(); writeStylesheetLink(writer, cycle, stylesheet); }

      }

      IAsset stylesheet = getStylesheet();

      if (stylesheet != null)
      writeStylesheetLink(writer, cycle, stylesheet);

      Iterator i = (Iterator) getValueConverter().coerceValue(getStylesheets(), Iterator.class);

      while (i.hasNext())
      {
      stylesheet = (IAsset) i.next();
      writeStylesheetLink(writer, cycle, stylesheet);
      }

      ....

      private void writeDocType(IMarkupWriter writer, IRequestCycle cycle)
      {
      String doctype = getDoctype();
      if (! HiveMind.isNonBlank(doctype) && getShellDefaults() != null)
      doctype = getShellDefaults().getDoctype(cycle);

      if (HiveMind.isNonBlank(doctype))

      Attachments

        Activity

          People

            andyhot Andreas Andreou
            hvendelbo Henrik Vendelbo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: