AJAX MVC Documentation HomeCopyright © 2006 Dan MascenikCurrent Version: 0.6 Status: Development |
Available at: |
execute()
- to the front-end developer. Within that method, all data retrieval and
transformation must take place before being passed to the view (usually
a JSP page). Since data services provide data as XML, and, in the case
of an AJAX application, the view is just an HTML page, shouldn't there
be a simple way to map data to a view component?samples/README
file, deploy the simple AJAX application to your web server. mvc-config.xml
file, too. There
you will see that the sample application has been configured to alert
all incoming and outgoing XML messages in popup windows. This is useful
for debugging, but you can turn it off if you like.execute(actionName)
JavaScript functionactionName
's are registered in the mvc-config.xml
file with <action>
tagsexecute(actionName)
function, the following sequence of events takes place:
actionName
is looked up in the mvc-config.xml
file (actually the file contents are cached as a JavaScript Array
,
so the file is only downloaded once)callBefore
function specified, it is
invoked. This could be anything, but I've used it to change the cursor
appearance, hide changing components, and move form data aroundview
, it is retrieved and inserted into
the named component
. You don't have to have a view; for
example, if you call a web service method that does not return data.form
is specified, data is retrieved from it and
translated into a document/literal style SOAP message (see "Mapping
Data").model
(the action might just load some
static HTML), retrieve it. If an operation
is specified,
the model
is treated as a web service endpoint location,
and the form
SOAP message (if any) is sent as a SOAP
request to the operation
. If there is no operation
,
the model
is treated as a static XML file.view
. (See "Mapping Data")callAfter
function specified, this is
now called. Again, this could be anything, but I've used this to change
the cursor appearance back to normal or to invoke a transition effect
that shows the now populated page component. id
attribute set to the tag name of the XML element,
like this: <Test> <name>Fred</name> <age>30</age> </Test>Maps to:
<tr id="Test"> ... </tr>Elements that contain text must map to an HTML
<div>
tag that has a name
attribute set to the tag name of the
XML element, like this: <name>Fred</name>Maps to:
<div name="name"></div>Elements should never contain both child elements and text.
id
value "Test." If the <name>
tag were not wrapped in a
<Test>
tag, then all the instances of <div
name="name"></div>
would be filled with the value
"Fred." <Test>
element in the first example, the AJAX MVC would duplicate the HTML
element with the id
value "Test" for each incoming <Test>
element. This duplication can be nested to any arbitrary depth, and is
illustrated in the sample application.id
of an HTML element that will be used as the
"form" (the form
attribute in the mvc-config.xml
file), the same process used for incoming data is applied in reverse to
produce a document/literal SOAP request message. Notice that any
HTML element can be the "form" as long as its id
is unique
in the HTML document. Of course, you can use a true HTML <form>
as your form, and the process works the same way. The only difference is
that <input>
tags get their values from their value
attributes rather than their contents. LICENSE
file). If you did not receive a copy
of the license, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA