I don't know of something exists, but here is a reasonably simple solution:

Create a "meta" component that that collects the values and injects
them at the top of the head element at the end of the rendering
process.

The following code was compiled and briefly tested in 5.2.5. It
collects the values and injects them in the top of the head. You can
actually put this component anywhere in your template and the values
will go into the head.

Usage:

<t:meta content="IE=8" httpequiv="X-UA-Compatible"></t:meta>
<t:meta name="literal:keywords" content="literal:Hello Kitty"/>

Component:

public class Meta {

    @Parameter(defaultPrefix = "literal")
    private String content;

    @Parameter(defaultPrefix = "literal")
    private String httpEquiv;

    @Parameter(defaultPrefix = "literal")
    private String name;

    @Parameter(defaultPrefix = "literal")
    private String scheme;

    @Environmental
    private MetaSupport metaSupport;

    @SetupRender
    boolean storeMeta() {
        metaSupport.addMeta("content", content, "http-equiv",
httpEquiv, "name", name, "scheme", scheme);
        // don't render it now
        return false;
    }
}

Service Interface

public interface MetaSupport {
    public void updateDocument(Document document);

    void addMeta(String... fields);
}

Service Implementation

public class MetaSupportImpl implements MetaSupport {

    private List<String[]> tags = new ArrayList<String[]>();

    @Override
    public void updateDocument(Document document) {
        final Element head = document.find("html/head");
        if (head == null) throw new RuntimeException("Meta requires a
head element");

        int i = 0;
        for (String[] tag : tags) {
            head.elementAt(i++, "meta", tag);
        }
    }

    @Override
    public void addMeta(String... fields) {
        if (fields.length % 2 != 0) throw new RuntimeException("Invalid meta!");
        tags.add(fields);
    }
}

Code for AppModule

    @Contribute(MarkupRenderer.class)
    public static void addMetaRenderFilter(
            OrderedConfiguration<MarkupRendererFilter> configuration,
            final Environment environment
    ) {
        MarkupRendererFilter rendererFilter = new MarkupRendererFilter() {
            public void renderMarkup(MarkupWriter writer,
MarkupRenderer renderer) {
                MetaSupport metaSupport = new MetaSupportImpl();

                environment.push(MetaSupport.class, metaSupport);

                renderer.renderMarkup(writer);

                environment.pop(MetaSupport.class);

                metaSupport.updateDocument(writer.getDocument());
            }
        };
        configuration.add("meta", rendererFilter, "before:*");

    }

Josh

On Wed, May 18, 2011 at 8:28 AM, Rich M <rich...@moremagic.com> wrote:
> Hi,
>
> has anyone else had trouble with getting the X-UA-Compatible meta tag
> working in IE9 with Tapestry?
>
> I have verified that my rendered HTML page has the tag in the <head>
> element, but going into Developer Tools it says the Document Mode for the
> page is not the one I set it to.
>
> The reason I mention it on the list is the following from
> http://msdn.microsoft.com/library/cc288325%28VS.85%29.aspx#SetMode :
>
>
> The |X-UA-Compatible| header is not case sensitive; however, it must appear
> in the header of the webpage (the HEAD section
> <http://msdn.microsoft.com/en-us/library/ms535252%28v=VS.85%29.aspx>) before
> all other elements except for the title
> <http://msdn.microsoft.com/en-us/library/ms535910%28v=VS.85%29.aspx> element
> and other *meta* elements.
>
>
> In the rendered HTML, it seems Tapestry places all of the script and
> stylesheet link tags ahead of the meta and title tags I have defined in my
> Layout.tml file. Following the above excerpt, this seems to break the rule
> mentioned about X-UA-Compatible needing to be before all other elements
> except for the title and other meta elements.
>
> I'm trying to force IE8 Document Mode so the Scriptaculous Drag-Drop library
> will work (does not seem to in IE9).
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> <html  xmlns="http://www.w3.org/1999/xhtml";>
> <head>
> <script  src="/app/assets/1.0/stack/en/core.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/stack/en/core.js>"type="text/javascript"></script>
> <script  src="/app/assets/1.0/core/scriptaculous_1_8_2/dragdrop.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/core/scriptaculous_1_8_2/dragdrop.js>"type="text/javascript"></script>
> <script  src="/app/assets/1.0/ctx/scripts/droppableContent.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/ctx/scripts/droppableContent.js>"type="text/javascript"></script>
> <script
>  src="/app/assets/1.0/chenillekit/components/datetimefield/datepicker.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/chenillekit/components/datetimefield/datepicker.js>"type="text/javascript"></script>
> <script
>  src="/app/assets/1.0/chenillekit/components/datetimefield/datepicker_lang.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/chenillekit/components/datetimefield/datepicker_lang.js>"type="text/javascript"></script>
> <script  src="/app/assets/1.0/chenillekit/prototype-base-extensions.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/chenillekit/prototype-base-extensions.js>"type="text/javascript"></script>
> <script  src="/app/assets/1.0/chenillekit/prototype-date-extensions.js
>  <view-source:http://localhost:8080/mparking/assets/1.0/chenillekit/prototype-date-extensions.js>"type="text/javascript"></script>
> <link  type="text/css"rel="stylesheet"href="/app/assets/1.0/core/default.css
>  <view-source:http://localhost:8080/mparking/assets/1.0/core/default.css>"></link>
> <link
>  type="text/css"rel="stylesheet"href="/app/assets/1.0/core/tapestry-console.css
>  <view-source:http://localhost:8080/mparking/assets/1.0/core/tapestry-console.css>"></link>
> <link
>  type="text/css"rel="stylesheet"href="/app/assets/1.0/ctx/layout/main.css
>  <view-source:http://localhost:8080/mparking/assets/1.0/ctx/layout/main.css>"></link>
> <link
>  type="text/css"rel="stylesheet"href="/app/assets/1.0/chenillekit/components/datetimefield/datepicker.css
>  <view-source:http://localhost:8080/mparking/assets/1.0/chenillekit/components/datetimefield/datepicker.css>"></link>
> <meta  content="IE=8"http-equiv="X-UA-Compatible"></meta>
> <meta  content="text/html; charset=utf-8"http-equiv="content-type"></meta>
> <title>Application</title>
> <meta  content="Apache Tapestry Framework (version
> 5.2.4)"name="generator"></meta>
> </head>
>
>
>
> Thanks,
> Rich
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to