Author: bobharner
Date: Sun Sep 15 19:17:47 2013
New Revision: 878528
Log:
Manual updates to {code} section of doc pages as a temporary fix (until we can
cleanly incorporate Dan Kulp's fixes into our copy of SiteExporter)
Modified:
websites/production/tapestry/content/javascript.html
Modified: websites/production/tapestry/content/javascript.html
==============================================================================
--- websites/production/tapestry/content/javascript.html (original)
+++ websites/production/tapestry/content/javascript.html Sun Sep 15 19:17:47
2013
@@ -19,6 +19,7 @@
-->
<html>
<head>
+ <base href="http://tapestry.apache.org/javascript.html" />
<meta http-equiv="x-ua-compatible" content="IE=9">
<title>
JavaScript -- Apache Tapestry
@@ -108,24 +109,24 @@
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Import(library={"context:js/jquery.js",
"context:js/myeffects.js"})
public class MyComponent
{
. . .
}
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.0 and
5.1</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@IncludeJavaScriptLibrary(value={"context:js/jquery.js",
"context:js/myeffects.js"})
public class MyComponent
{
. . .
}
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>@Import may also be applied to individual methods, in which case the import
operation only occurs when the method is invoked.</p>
@@ -144,7 +145,7 @@ public class MyComponent
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject @Path("context:/js/myeffects.js")
private Asset myEffects;
@@ -155,10 +156,10 @@ public class MyComponent
{
javaScriptSupport.importJavaScriptLibrary(myEffects);
}
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>Tapestry 5.1 and
earlier</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject @Path("context:/js/myeffects.js")
private Asset myEffects;
@@ -169,7 +170,7 @@ public class MyComponent
{
renderSupport.addScriptLink(myEffects);
}
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>Tapestry will ensure that the necessary <link> elements are added to
the <em>top</em> of the document (in the <head> element). With Tapestry
5.3 and later the new elements are inserted at the bottom of the <head>
element; in versions before 5.3 they appear at the top of the <head>
element).</p>
@@ -187,24 +188,24 @@ public class MyComponent
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
void afterRender()
{
javaScriptSupport.addScript(
"$('%s').observe('click', hideMe());",
container.getClientId());
}
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>Tapestry 5.1 and
earlier</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
void afterRender()
{
javaScriptSupport.addScript(String.format(
"$('%s').observe('click', hideMe());",
container.getClientId()));
}
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>When calling the method, the format string can include standard
substitutions (such as '%s') for arguments. This saves you the trouble of
calling String.format() yourself. (For Tapestry 5.1 and earlier, you must call
String.format() yourself.) In any case, the formatted JavaScript is added to
the script block in the rendered output.</p>
@@ -215,52 +216,52 @@ void afterRender()
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Environmental
private JavaScriptSupport javaScriptSupport;
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.0 and
5.1</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Environmental
private RenderSupport renderSupport;
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>The @Environmental annotation only works inside components, but
occasionally you may want to inject JavaScriptSupport (or RenderSupport) into a
service. Fortunately, a proxy has been set up to allow the use of @Inject
instead:</p>
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject
private JavaScriptSupport javaScriptSupport;
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.0 and
5.1</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject
private RenderSupport renderSupport;
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>... or, in a service implementation constructor:</p>
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.2 and
later</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
public MyServiceImpl(JavaScriptSupport support)
{
. . .
}
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>For Tapestry 5.0 and
5.1</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
public MyServiceImpl(RenderSupport support)
{
. . .
}
-]]></script>
+</pre>
</div></div></td></tr></tbody></table>
<p>Inside a component, you should use @Environmental, to highlight the fact
that RenderSupport (like most environmental objects) is only available during
rendering, not during action requests.</p>
@@ -292,13 +293,13 @@ void afterRender()
<p>IMPORTANT NOTE: The tapestry-core module only provides the empty
infrastructure for supporting minification; the actual logic is supplied in the
tapestry-yuicompressor module. To use it, you'll need to update your
dependencies to include this module.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>Maven pom.xml
(partial)</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: xml; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-xml">
<dependency>
<groupId>org.apache.tapestry</groupId>
<artifactId>tapestry-yuicompressor</artifactId>
<version>${tapestry-release-version}</version>
</dependency>
-]]></script>
+</pre>
</div></div>
<p>Gradle would be similar, of course. If you aren't using something like
Maven or Gradle, you'll have to download the jar and its dependency
(com.yahoo.platform.yui: yuicompressor) yourself.</p>
@@ -323,12 +324,12 @@ void afterRender()
<p>Example usage:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
Tapestry.debug("Field id is #{id}, value is #{value}", field);
Tapestry.error("Server is not available.");
-]]></script>
+</pre>
</div></div>
<p>With Tapestry 5.3 and later the Blackbird console has been removed; just
use the standard console logging features (e.g. <tt>console.log()</tt>) built
into modern browsers.</p>
@@ -342,9 +343,9 @@ void afterRender()
<p>The correct usage is:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
<a href="..." onclick="javascript:Tapestry.waitForPage(event);"> ...
</a>
-]]></script>
+</pre>
</div></div>
<p>The constant <a shape="rect" class="external-link"
href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/MarkupConstants.html">MarkupConstants.WAIT_FOR_PAGE</a>
contains the part of this snippet inside the quotes.</p>
@@ -375,17 +376,17 @@ void afterRender()
<p>For example, you might store a value for an element in one place:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
$T(myid).fadeDuration = .5;
-]]></script>
+</pre>
</div></div>
<p>Then use it somewhere else:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
new Effect.Fade($(myId), { duration: $T(myid).fadeDuration });
-]]></script>
+</pre>
</div></div>
@@ -414,7 +415,7 @@ Tapestry also works well with other Java
<p>If you need access to other Scriptaculous libraries, you can provide them
as follows:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent
panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject @Path("${tapestry.scriptaculous}/dragdrop.js")
private Asset dragDropLibrary;
@@ -426,7 +427,7 @@ Tapestry also works well with other Java
javaScriptSupport.addScriptLink(dragDropLibrary);
}
-]]></script>
+</pre>
</div></div>
<p>The Asset is injected, using the ${tapestry.scriptaculous} <a shape="rect"
href="symbols.html" title="Symbols">symbol</a> to reference the location of the
Scriptaculous library.</p>
@@ -461,7 +462,7 @@ Tapestry also works well with other Java
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>myStack.java</b></div><div
class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
public class myStack implements JavaScriptStack {
private final AssetSource assetSource;
@@ -504,33 +505,33 @@ public class myStack implements JavaScri
}
}
-]]></script>
+</pre>
</div></div>
<p>When your new Stack is created, you have to define it in your AppModule.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>AppModule.java</b></div><div
class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Contribute(JavaScriptStackSource.class)
public static void addMyStack (MappedConfiguration<String,
JavaScriptStack> configuration)
{
configuration.addInstance("MyNewStack", myStack.class);
}
-]]></script>
+</pre>
</div></div>
<p>You can now use it in your pages and components, by using the @Import
annotation or the JavaScriptSupport service :</p>
<table class="sectionMacro" border="0" cellpadding="5" cellspacing="0"
width="100%"><tbody><tr><td colspan="1" rowspan="1" valign="top"
class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>With @Import</b></div><div
class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Import(stack="MyNewStack")
public class myPage {
}
-]]></script>
+</pre>
</div></div></td><td colspan="1" rowspan="1" valign="top" class="confluenceTd">
<div class="code panel" style="border-width: 1px;"><div class="codeHeader
panelHeader" style="border-bottom-width: 1px;"><b>With
JavaScriptSupport</b></div><div class="codeContent panelContent">
-<script class="theme: Default; brush: java; gutter: false"
type="syntaxhighlighter"><![CDATA[
+<pre class="code-java">
@Inject
private JavaScriptSupport js;
@@ -538,7 +539,7 @@ private JavaScriptSupport js;
public void importStack(){
js.importStack("MyNewStack");
}
-]]></script>
+</pre>
</div></div></td></tr></tbody></table></div>
</div>