You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Fickes, Vic" <vi...@exchange.prb.net> on 2001/02/22 16:57:54 UTC

using XML and Struts

Hi,

Being new to the world of web applications and Struts, I'm still trying to
decide on an architecture to use for our application.
One of the things I had been hoping to do was to make use of some legacy
code that publishes XML from our database and then translates it to HTML
using XSL.  However, it seems you can't use XSL to translate to Struts html
tags (or any JSP custom tags).   So before I completely drop the idea of
using XML and XSL, does anybody know of any approach that would allow me to
use XML in the context of the Struts framework?  

I thought of using Digester, but since this is all new to me, my first
impression was that the implementation would get to be too complicated to
make it worthwhile.  I also ran into the Cocoon project in my wanderings,
which seems like a great solution if all you're going to do is builds
displays, but I've got to do some heavy duty editing and validating of input
data and I don't see how Coccon supports that.  If anybody could provide
some suggestions on using these or any other approachs, I'd appreciate it.

Thanks,
Vic

Re: using XML and Struts

Posted by Craig Tataryn <Cr...@msdw.com>.
Vic, IMHO you could fit XML into your solution as far as presentation goes by
simply making yourself a JSP page that reads a session var that a controller
servlet setup which contains the XML doc in it.

You would probably want to do something like this (this is just adhoc code,
syntax isn't correct):

In your controller:

xmlDoc.parse("appropriateXML.xml");
xmlDoc.transform("appropriateXSL.xsl");
request.setAttribute("xml", xmlDoc);
mappings.findForward("displayResults");

In displayResults.jsp:

<!--Any other nifty presentation stuff you may need -->
<%= request.getAttribute("xml").toString() %>

Hope that leads you in the right direction,

<tataryn:craig>

"Fickes, Vic" wrote:

> Hi,
>
> Being new to the world of web applications and Struts, I'm still trying to
> decide on an architecture to use for our application.
> One of the things I had been hoping to do was to make use of some legacy
> code that publishes XML from our database and then translates it to HTML
> using XSL.  However, it seems you can't use XSL to translate to Struts html
> tags (or any JSP custom tags).   So before I completely drop the idea of
> using XML and XSL, does anybody know of any approach that would allow me to
> use XML in the context of the Struts framework?
>
> I thought of using Digester, but since this is all new to me, my first
> impression was that the implementation would get to be too complicated to
> make it worthwhile.  I also ran into the Cocoon project in my wanderings,
> which seems like a great solution if all you're going to do is builds
> displays, but I've got to do some heavy duty editing and validating of input
> data and I don't see how Coccon supports that.  If anybody could provide
> some suggestions on using these or any other approachs, I'd appreciate it.
>
> Thanks,
> Vic

--
I've been trying to change the world for years, but they just won't give me the
source code....


JUNIT and Struts

Posted by Julia Reynolds <ju...@healthstream.com>.
Hello,

We are using the XP development process(http://www.extremeprogramming.org/) as
we develop our Struts web application.  We need to write some tests in
JUnit(http://www.junit.org) to incrementally test as we write code.  Has anyone
ever used JUnit with Struts?  Does anyone have any advice about how to proceed
in coding these tests?

TIA,

Julia


Re: using XML and Struts

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
"Fickes, Vic" wrote:

> Hi,
>
> Being new to the world of web applications and Struts, I'm still trying to
> decide on an architecture to use for our application.
> One of the things I had been hoping to do was to make use of some legacy
> code that publishes XML from our database and then translates it to HTML
> using XSL.  However, it seems you can't use XSL to translate to Struts html
> tags (or any JSP custom tags).   So before I completely drop the idea of
> using XML and XSL, does anybody know of any approach that would allow me to
> use XML in the context of the Struts framework?
>
> I thought of using Digester, but since this is all new to me, my first
> impression was that the implementation would get to be too complicated to
> make it worthwhile.  I also ran into the Cocoon project in my wanderings,
> which seems like a great solution if all you're going to do is builds
> displays, but I've got to do some heavy duty editing and validating of input
> data and I don't see how Coccon supports that.  If anybody could provide
> some suggestions on using these or any other approachs, I'd appreciate it.
>

One integration opportunity is the <xsl:apply/> custom tag, which is available
in the Jakarta Taglibs project <http://jakarta.apache.org/taglibs>.  This tag
lets you dynamically request XSLT transformations over XML data gathered from
any of a variety of places, and then render the transformed information
(presumably HTML in this case) to the resulting page.

In a similar vein, Struts itself uses offline XSLT transformations to create the
documentation pages you see in the Struts Documentation application.  The Ant
build tool <http://jakarta.apache.org/ant> has a <style> task that can apply
XSLT transformations in build scenarios.

>
> Thanks,
> Vic

Craig



RE: using XML and Struts

Posted by "Michael S. Kelly" <mi...@axian.com>.
I guess my first thought is that maybe you don't need the legacy code.
Think about what problem is being solved by the legacy code.  I think you
will find that Struts also solves those problems, or a significant subset of
them.  I'd suggest that you do a small proof of concept with Struts,
something that contains the main features of your target application (e.g.
authentication; authorization; the ability to add, edit, and delete data;
forms that change depending on authorization; etc.).  I think of this as
being a holographic proof of concept, it contains a reflection of the whole.
The point is to quickly get an indepth understanding of the what problems
Struts solves and how it solves them, and there's no substitute for actually
digging in and using something to get that understanding.

My 2 cents.

-=michael=-

-----Original Message-----
From: Fickes, Vic [mailto:vic_fickes@exchange.prb.net]
Sent: Thursday, February 22, 2001 7:58 AM
To: struts-user@jakarta.apache.org
Subject: using XML and Struts


Hi,

Being new to the world of web applications and Struts, I'm still trying to
decide on an architecture to use for our application.
One of the things I had been hoping to do was to make use of some legacy
code that publishes XML from our database and then translates it to HTML
using XSL.  However, it seems you can't use XSL to translate to Struts html
tags (or any JSP custom tags).   So before I completely drop the idea of
using XML and XSL, does anybody know of any approach that would allow me to
use XML in the context of the Struts framework?

I thought of using Digester, but since this is all new to me, my first
impression was that the implementation would get to be too complicated to
make it worthwhile.  I also ran into the Cocoon project in my wanderings,
which seems like a great solution if all you're going to do is builds
displays, but I've got to do some heavy duty editing and validating of input
data and I don't see how Coccon supports that.  If anybody could provide
some suggestions on using these or any other approachs, I'd appreciate it.

Thanks,
Vic