dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.Form");
|
Loads the JavaScript source files required
by the Dojo widgets that make up the Details pane.
|
dojo.connect(grid, "onCellClick", showDetails);
|
Adds the event handler. The call to dojo.connect invokes
a Dojo API that adds an event handler to specific user interface events.
When a cell is clicked in the grid, Dojo calls showDetails.
|
function showDetails(e) {
var grid = dijit.byId("grid.DataGrid");
var title = grid.store.getValue(grid.getItem(e.rowIndex), "title");
var serviceURL = "/web2Project/RPCAdapter/httprpc/MovieService/getMovie?title=" + title;
dojo.xhrGet({
url: serviceURL,
load: fillDetailsForm,
error: handleError,
handleAs: 'json'
});
}
|
Makes the asynchronous call to getMovie(String
title). The showDetails() function
determines the title of the movie selected, by using the data model getDatum API. rowIndex and 0 represent
the cell that contains the title of the movie. serviceURL is
the URL required to query the getMovie(String title) RPC
Adapter service. This URL is used to issue an asynchronous request
via the dojo.xhrGet API. Just as in the Master
grid, a handler is specified by the url: in
the dojo.xhrGet. In this case the handler is
called fillDetailsForm.
|
function fillDetailsForm(data, ioArgs) {
dijit.byId("detailsForm").setValues(data.result);
}
|
Fills the details pane. dijit.form.Form provides
the API setValues which will match the values
in a JSON string with the value specified in the name attribute
of the form contents. The values in the form input tags are determined
by the call to setValues(data.result);.
|
<form dojoType="dijit.form.Form" id="detailsForm">
<table border=2>
<tbody>
<tr>
<td>Name</td>
<td><input
dojoType="dijit.form.TextBox"
type="text"
name="title"
size="60"></td>
</tr>
<tr>
<td>Starring</td>
<td><input
dojoType="dijit.form.TextBox"
type="text"
name="actor"
size="60"></td>
</tr>
<tr>
<td>Director</td>
<td><input
dojoType="dijit.form.TextBox"
type="text"
name="director"
size="60"></td>
</tr>
<tr>
<td>Rating</td>
<td><input
dojoType="dijit.form.TextBox"
type="text"
name="rating"
size="60"></td>
</tr>
</tbody>
</table>
</form>
|
Creates the details pane. The details pane
is a simple HTML form that has been enhanced by specifying dijit.form.Form as
the dojoType for the <form> tag
and by specifying dijit.form.TextBox as the dojoType for
the HTML <input> tags.
The name attribute
in the <input> tags match the names of the
fields in your Movie Java class,
therefore matching the names of the fields that are returned as JSON
by the RPC Adapter invocation.
|