,ch14.9433 Page 487 Monday, February 14, 2005 12:55 PM
Example 14 36. Action that retrieves XML data from an action form (continued)
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.oroad.stxx.action.Action;
import com.oroad.stxx.xform.JDOMForm;
public class SaveUserAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
List usersList = (List) getServlet().getServletContext( ).getAttribute("users");
JDOMForm jdomForm = (JDOMForm) form;
String firstName = jdomForm.getValue("/user/name/firstname");
String lastName = jdomForm.getValue("/user/name/lastname");
String email = jdomForm.getValue("/user/email");
usersList.add(new User(firstName, lastName, email));
return mapping.findForward("success");
}
}
The sample application shown in this recipe represents a fraction of the capabilities
of STXX. STXX supports validation, XForms, SOAP, FOP, and Velocity just to name
a few. If you have a site that relies heavily on XML based data, and needs to render
that data in a number of formats, STXX may be what you need.
See Also
The STXX project web site (http://stxx.sourceforge.net) has complete details on the
full functionality of STXX.
The StrutsCX project (http://it.cappuccinonet.com/strutscx) is another popular Struts
XSL integration framework.
Integrating Struts and XSLT | 487
This is the Title of the Book, eMatter Edition
Copyright 2005 O'Reilly & Associates, Inc. All rights reserved.
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved