Rename class to be more general about its responsibilities
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/758f8678 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/758f8678 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/758f8678 Branch: refs/heads/5.4-js-rewrite Commit: 758f86781dc1eb61931d6cfd29bd8886369a98c1 Parents: 4407ba9 Author: Howard M. Lewis Ship <hls...@apache.org> Authored: Fri Nov 2 16:50:24 2012 -0700 Committer: Howard M. Lewis Ship <hls...@apache.org> Committed: Fri Nov 2 16:50:24 2012 -0700 ---------------------------------------------------------------------- .../javascript/ConfigureHTMLElementFilter.java | 54 +++++++++++++++ .../services/javascript/LocaleEmitterFilter.java | 53 -------------- .../services/javascript/JavaScriptModule.java | 4 +- 3 files changed, 56 insertions(+), 55 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/758f8678/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ConfigureHTMLElementFilter.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ConfigureHTMLElementFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ConfigureHTMLElementFilter.java new file mode 100644 index 0000000..2ec3df7 --- /dev/null +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/ConfigureHTMLElementFilter.java @@ -0,0 +1,54 @@ +// Copyright 2012 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.tapestry5.internal.services.javascript; + +import org.apache.tapestry5.MarkupWriter; +import org.apache.tapestry5.dom.Element; +import org.apache.tapestry5.ioc.services.ThreadLocale; +import org.apache.tapestry5.services.MarkupRenderer; +import org.apache.tapestry5.services.MarkupRendererFilter; + +/** + * Responsible for writing attributes needed to configure the client, into the + * HTML element. + * + * @since 5.4 + */ +public class ConfigureHTMLElementFilter implements MarkupRendererFilter +{ + private final ThreadLocale threadLocale; + + public ConfigureHTMLElementFilter(ThreadLocale threadLocale) + { + this.threadLocale = threadLocale; + } + + @Override + public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) + { + renderer.renderMarkup(writer); + + // After that's done (i.e., pretty much all rendering), touch it up a little. + + Element html = writer.getDocument().find("html"); + + // If it is an HTML document, with a root HTML node, put data-locale + // attribute inplace for the client. + if (html != null) + { + html.attributes("data-locale", threadLocale.getLocale().toString()); + } + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/758f8678/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/LocaleEmitterFilter.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/LocaleEmitterFilter.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/LocaleEmitterFilter.java deleted file mode 100644 index eaefaec..0000000 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/LocaleEmitterFilter.java +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2012 The Apache Software Foundation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package org.apache.tapestry5.internal.services.javascript; - -import org.apache.tapestry5.MarkupWriter; -import org.apache.tapestry5.dom.Element; -import org.apache.tapestry5.ioc.services.ThreadLocale; -import org.apache.tapestry5.services.MarkupRenderer; -import org.apache.tapestry5.services.MarkupRendererFilter; - -/** - * Responsible for the {@code data-locale} attribute written into the HTML element. - * - * @since 5.4 - */ -public class LocaleEmitterFilter implements MarkupRendererFilter -{ - private final ThreadLocale threadLocale; - - public LocaleEmitterFilter(ThreadLocale threadLocale) - { - this.threadLocale = threadLocale; - } - - @Override - public void renderMarkup(MarkupWriter writer, MarkupRenderer renderer) - { - renderer.renderMarkup(writer); - - // After that's done (i.e., pretty much all rendering), touch it up a little. - - Element html = writer.getDocument().find("html"); - - // If it is an HTML document, with a root HTML node, put data-locale - // attribute inplace for the client. - if (html != null) - { - html.attributes("data-locale", threadLocale.getLocale().toString()); - } - } -} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/758f8678/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java index e80e26f..2b9dcab 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/services/javascript/JavaScriptModule.java @@ -250,12 +250,12 @@ public class JavaScriptModule } /** - * Contributes 'LocaleEmitter', which writes the {@code data-locale} attribute into the HTML tag. + * Contributes 'ConfigureHTMLElement', which writes the attributes into the HTML tag to describe locale, etc. */ @Contribute(MarkupRenderer.class) public static void renderLocaleAttributeIntoPages(OrderedConfiguration<MarkupRendererFilter> configuration) { - configuration.addInstance("LocaleEmitter", LocaleEmitterFilter.class); + configuration.addInstance("ConfigureHTMLElement", ConfigureHTMLElementFilter.class); } }