Java Reference
In-Depth Information
Figure 15.1: A simple Ajax example
15.1
Using JavaScriptResolution
We'll start with a simple reusable layout that loads the Prototype library
and has components to put content in the
<head>
and
<body>
sec-
tions of the page:
<s:layout-definition>
<!
DOCTYPE
HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>
${title}
</title>
<script src="${contextPath}/js/prototype.js"
type="text/javascript">
</script>
<s:layout-component name="head"/>
</head>
<body>
<h3>
${title}
</h3>
<s:layout-component name="body"/>
</body>
</html>
</s:layout-definition>
We'll put JavaScript code in the
head
component and the page content
in the
body
component.
We're ready to try a simple Ajax example. A page with a text field is
refreshes to display double the amount. This happens after each key-
stroke, without having to click the
Submit Query
button.
Search WWH ::
Custom Search