Java Reference
In-Depth Information
The partial_form.jsp file contains the select box for the car models. Owing
to the fact that it is being put back into an already-existing form, it's
tempting to just return the select box:
Download ajax/web/WEB-INF/jsp/partial_form.jsp
<s:select name="models">
<s:option value="" label="..."/>
<s:options-collection collection="${actionBean.models}"/>
</s:select>
The problem is that Stripes doesn't know (or care) that we're working
with Ajax here. When rendering partial_form.jsp , Stripes will complain
that the <s:select> tag does not have a parent <s:form> tag. We can't
very well say, “Yes, it does; it's sitting over there on the client side!”
On the other hand, if we wrap the select box in an <s:form> tag, we're
going to end up with two form tags, one nested inside the other.
To create form input controls that are going back into an existing form
while still satisfying the requirement for a parent <s:form> tag, we just
have to use the partial="true" attribute:
Download ajax/web/WEB-INF/jsp/partial_form.jsp
<s:form partial="true"
beanclass="stripesbook.action.PartialFormActionBean">
<s:select name="models">
<s:option value="" label="..."/>
<s:options-collection collection="${actionBean.models}"/>
</s:select>
</s:form>
This tells Stripes not to render the HTML <form> tag or the special
hidden inputs that Stripes normally renders in a form so that we don't
end up with duplicate form tags. The example now works as expected.
15.3
Ajaxifying the Webmail Application
For the rest of this chapter, we'll use some Ajax in the webmail applica-
tion to spice up the Contact List page. Instead of having separate Con-
tact List, Contact Details, and Contact Form pages, we'll have every-
thing in a single page and use Ajax to show, hide, and refresh different
portions of the page.
 
 
 
Search WWH ::




Custom Search