On Mon, 27 Jan 2003, Michael Oliver wrote:

> Date: Mon, 27 Jan 2003 22:04:48 -0700
> From: Michael Oliver <[EMAIL PROTECTED]>
> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [AXIS4STRUTS]Generating XML from Struts JSP
>
> Has anyone used JSP with Struts to generate XML?
> http://java.sun.com/products/jsp/html/JSPXML.html
>
> Would anyone be interested in a struts-xml.tld and the associated custom
> tag classes?
>
> If so what kinds of tags would you want? bean name and value?
>
> Can we just add a few XML oriented tags to the struts-html.tld and
> html/custom tag classes?
>
> DynaBean Tags?
>
> Build an xml document from the contents of a DynaBean?
>
> Just some of the things we might want for Axis4Struts and others may
> want too.
>

I use JSP to render XML with the standard Struts tag libraries and it
works quite well.  The <bean:write> tag already supports DynaBeans,
<logic:iterate> works great for looping through data structures, and so
on.

A trivial example similar to the XML document listed in the page you
referenced (assuming a collection of "books" that is either JavaBeans or
DynaBeans):

  <%@ page contentType="text/xml" %>
  <%@ taglib prefix="bean" uri="http://jakarta.apache.org/struts/bean"; %>
  <%@ taglib prefix="logic" uri="http://jakarta.apache.org/struts/logic"; %>
  <books>
    <logic:iterate id="book" name="books">
      <book isbn='<bean:write name="book" property="isbn"/>'>
        <title><bean:write name="book" property="title"/></title>
        <quantity><bean:write name="book" property="quantity"/></quantity>
        <price><bean:write name="book" property="price"/></price>
      </book>
    </logic:iterate>
  </books>

Of course, you can do the same thing with JSTL tags if you've got standard
JavaBeans as the backing data.

> Ollie

Craig


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to