Java Reference
In-Depth Information
Browser page
request
new Ajax.Updater('result', ...)
Server
response
<div id="result"></div>
Figure 15.2: Updating a page portion with the server's response
The
'result'
ID is passed to the
Ajax.Updater
call:
new Ajax.Updater('result', form.action,
{ method: 'post',
parameters: form.serialize()
}
);
To respond to the request in the action bean, we can use a regular
ForwardResolution
to a JSP:
package
stripesbook.action;
public class
UpdaterActionBean
extends
BaseActionBean {
private static final
String RESULT = "/WEB-INF/jsp/result.jsp";
public int
youGiveMe;
private
Money money;
public
Money getMoney() {
return
money;
}
public
Resolution doubleMoney() {
money =
new
Money(youGiveMe, youGiveMe
*
2);
return new
ForwardResolution(RESULT);
}
}
In
result.jsp
, we'll render the fragment that is put back in the
'result'
ele-
ment. All the regular goodies are available, such as
${actionBean}
to
access the action bean's properties:
You gave me $ ${actionBean.money.youGaveMe},
and I give you $ ${actionBean.money.andIGiveYou} back!
Search WWH ::
Custom Search