You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/10/23 18:17:34 UTC

Struts & XML

Currently I'm calling a database subroutine (in an Action) that returns a
list of keys, and then using a DAO in a loop to build up a List of Java
objects that contain the data I need to display.  That List gets put in
session scope and then it's off to the resolution.jsp to display it with a
<logic:iterate> tag.

*IF* I changed the database subroutine to return XML, what would I do with
it?  I'd have something like this coming back:

<content>
 <person>
  <name>John Smith</name>
  <birthdate>05/25/1965</birthdate>
  <status>PP</status>
  <address>
      123 State Street 
      City, ST, 12345
  </address>
  <source>ALUM</source>
  <reunion_class>ML1999</reunion_class>
  <reunion_class>ME2002</reunion_class>
 </person
</content>

(I'm unclear on how to format the address which has multiple lines.)

Anyway, would I put that String in session scope?  And then... I'm just
reading about XSLT now.  Can someone point me in the general direction of
which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 & a
recent Struts nightly build with the -el tags.

Thanks in advance,

-- 
Wendy Smoak
http://sourceforge.net/projects/unidbtags 

Re: Struts & XML

Posted by "V. Cekvenich" <vi...@users.sourceforge.net>.
JSTL (in jakarta tag libs) X:transform tag will take a XML and XSLT it.
.V

Wendy Smoak wrote:
> Currently I'm calling a database subroutine (in an Action) that returns a
> list of keys, and then using a DAO in a loop to build up a List of Java
> objects that contain the data I need to display.  That List gets put in
> session scope and then it's off to the resolution.jsp to display it with a
> <logic:iterate> tag.
> 
> *IF* I changed the database subroutine to return XML, what would I do with
> it?  I'd have something like this coming back:
> 
> <content>
>  <person>
>   <name>John Smith</name>
>   <birthdate>05/25/1965</birthdate>
>   <status>PP</status>
>   <address>
>       123 State Street 
>       City, ST, 12345
>   </address>
>   <source>ALUM</source>
>   <reunion_class>ML1999</reunion_class>
>   <reunion_class>ME2002</reunion_class>
>  </person
> </content>
> 
> (I'm unclear on how to format the address which has multiple lines.)
> 
> Anyway, would I put that String in session scope?  And then... I'm just
> reading about XSLT now.  Can someone point me in the general direction of
> which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 & a
> recent Struts nightly build with the -el tags.
> 
> Thanks in advance,
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Indexed form Properties

Posted by Ted Husted <hu...@apache.org>.
This is a question for the Struts USER 
list.

10/23/2002 11:12:00 PM, "Virgilio Lustre 
Jr." <co...@yellowasp.com> wrote:





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Indexed form Properties

Posted by "Virgilio Lustre Jr." <co...@yellowasp.com>.
Hello People,

I am quite new to struts. and right now i am using 1.1. I have questions
regarding creating indexed form elements...

I want to be able to have multiple updateable objects.

my jsp page...

<html:form action="/stockControlConfirm.do" method="POST">
<logic:iterate id="stock" name="stockSearch" scope="session"
                   offset="<%= pager.getOffset() %>" length="<%=
pager.getLength() %>" type="com.yellowasp.isolaconsign.Stock">
    <html:text property="batch" size="8" maxlength="20" indexed="true"/>
    <html:hidden property="id" size="8" maxlength="20" indexed="true"/>
</logic:iterate>
</html:form>

My questio0ns are:

1. How do I create the form beans with indexed type properties? Do I have to
create indexed field/getters/setters on my form bean?

2. How do i catch it with my action class?

Illustrations:

public ActionForward perform(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException  {}


    Is the Action form in this template enough? or is there another variation
with the perform method?


tnx.

Indexed form Properties

Posted by "Virgilio Lustre Jr." <co...@yellowasp.com>.
Hello People,

I am quite new to struts. and right now i am using 1.1. I have questions
regarding creating indexed form elements...

I want to be able to have multiple updateable objects.

my jsp page...

<html:form action="/stockControlConfirm.do" method="POST">
<logic:iterate id="stock" name="stockSearch" scope="session"
                   offset="<%= pager.getOffset() %>" length="<%=
pager.getLength() %>" type="com.yellowasp.isolaconsign.Stock">
    <html:text property="batch" size="8" maxlength="20" indexed="true"/>
    <html:hidden property="id" size="8" maxlength="20" indexed="true"/>
</logic:iterate>
</html:form>

My questio0ns are:

1. How do I create the form beans with indexed type properties? Do I have to
create indexed field/getters/setters on my form bean?

2. How do i catch it with my action class?

Illustrations:

public ActionForward perform(ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException  {}


    Is the Action form in this template enough? or is there another variation
with the perform method?


tnx.

Re: Struts & XML

Posted by Omar Tazi <ot...@orbeon.com>.
Along these lines (Struts and XML) check out:
http://www.javaworld.com/javaworld/jw-02-2002/jw-0201-strutsxslt.html

regards,


-Omar



Andrew Hill wrote:
> I made use of Digester the first time yesterday.
> I was amazed at how easy and convienient it is to use - only took an hour to
> learn enough to use it for what I wanted. (Reading some config data and
> creating objects from it)
> Very cool :-)
> I Like!
> 
> -----Original Message-----
> From: Joe Germuska [mailto:Joe@Germuska.com]
> Sent: Thursday, October 24, 2002 01:18
> To: Struts Users Mailing List
> Subject: Re: Struts & XML
> 
> 
> Of course, the suggestions to check out STXX or the JSTL to use XSLT
> to style your XML are perfectly good...  and maybe that's why you
> decided to change your subroutine to return XML...  but if you want
> to get things back into familiar object-land, you could pass the XML
> to some routine which could produce a java Object for you from the
> XML.  Then you could use the object in Struts in all the usual ways.
> 
> There are whole frameworks for this (Betwixt, Zeus, Castor, others)
> but if you only need to consume the XML and never need to write it
> out in the same fashion from the object, you might want to check out
> Jakarta Commons Digester (which is how Struts reads in all of its
> configuration files.)
> 
> Once I learned how to use Digester, I never again had a moment's
> pause over the question of whether it was "too much trouble" to use
> an XML file to externalize some data -- it's really easy to use,
> especially if you have the liberty of designing your own XML format,
> in which case you can make things even easier.  Basically, you can
> assign an element name to an object and use attributes of that
> element named exactly as the properties of that object, and you can
> get Digester to construct and populate a bean for you in about three
> lines of code.
> 
> See http://jakarta.apache.org/commons/digester/api/ for details;
> there isn't a lot more documentation, but the Javadoc is pretty
> complete.
> 
> One thing to note is that digesters aren't designed to be threadsafe;
> if you are using digester in a servlet environment, you should keep
> in mind the same considerations as when writing servlets.
> 
> Joe
> 
> 
> At 9:17 AM -0700 2002/10/23, Wendy Smoak wrote:
> 
>>Currently I'm calling a database subroutine (in an Action) that returns a
>>list of keys, and then using a DAO in a loop to build up a List of Java
>>objects that contain the data I need to display.  That List gets put in
>>session scope and then it's off to the resolution.jsp to display it with a
>><logic:iterate> tag.
>>
>>*IF* I changed the database subroutine to return XML, what would I do with
>>it?  I'd have something like this coming back:
>>
>><content>
>> <person>
>>  <name>John Smith</name>
>>  <birthdate>05/25/1965</birthdate>
>>  <status>PP</status>
>>  <address>
>>      123 State Street
>>      City, ST, 12345
>>  </address>
>>  <source>ALUM</source>
>>  <reunion_class>ML1999</reunion_class>
>>  <reunion_class>ME2002</reunion_class>
>> </person
>></content>
>>
>>(I'm unclear on how to format the address which has multiple lines.)
>>
>>Anyway, would I put that String in session scope?  And then... I'm just
>>reading about XSLT now.  Can someone point me in the general direction of
>>which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 & a
>>recent Struts nightly build with the -el tags.
>>
>>Thanks in advance,
>>
>>--
>>Wendy Smoak
>>http://sourceforge.net/projects/unidbtags
> 
> 
> 
> --
> --
> * Joe Germuska    { joe@germuska.com }
> "It's pitiful, sometimes, if they've got it bad. Their eyes get
> glazed, they go white, their hands tremble.... As I watch them I
> often feel that a dope peddler is a gentleman compared with the man
> who sells records."
> 	--Sam Goody, 1956
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Struts & XML

Posted by Andrew Hill <an...@gridnode.com>.
I made use of Digester the first time yesterday.
I was amazed at how easy and convienient it is to use - only took an hour to
learn enough to use it for what I wanted. (Reading some config data and
creating objects from it)
Very cool :-)
I Like!

-----Original Message-----
From: Joe Germuska [mailto:Joe@Germuska.com]
Sent: Thursday, October 24, 2002 01:18
To: Struts Users Mailing List
Subject: Re: Struts & XML


Of course, the suggestions to check out STXX or the JSTL to use XSLT
to style your XML are perfectly good...  and maybe that's why you
decided to change your subroutine to return XML...  but if you want
to get things back into familiar object-land, you could pass the XML
to some routine which could produce a java Object for you from the
XML.  Then you could use the object in Struts in all the usual ways.

There are whole frameworks for this (Betwixt, Zeus, Castor, others)
but if you only need to consume the XML and never need to write it
out in the same fashion from the object, you might want to check out
Jakarta Commons Digester (which is how Struts reads in all of its
configuration files.)

Once I learned how to use Digester, I never again had a moment's
pause over the question of whether it was "too much trouble" to use
an XML file to externalize some data -- it's really easy to use,
especially if you have the liberty of designing your own XML format,
in which case you can make things even easier.  Basically, you can
assign an element name to an object and use attributes of that
element named exactly as the properties of that object, and you can
get Digester to construct and populate a bean for you in about three
lines of code.

See http://jakarta.apache.org/commons/digester/api/ for details;
there isn't a lot more documentation, but the Javadoc is pretty
complete.

One thing to note is that digesters aren't designed to be threadsafe;
if you are using digester in a servlet environment, you should keep
in mind the same considerations as when writing servlets.

Joe


At 9:17 AM -0700 2002/10/23, Wendy Smoak wrote:
>Currently I'm calling a database subroutine (in an Action) that returns a
>list of keys, and then using a DAO in a loop to build up a List of Java
>objects that contain the data I need to display.  That List gets put in
>session scope and then it's off to the resolution.jsp to display it with a
><logic:iterate> tag.
>
>*IF* I changed the database subroutine to return XML, what would I do with
>it?  I'd have something like this coming back:
>
><content>
>  <person>
>   <name>John Smith</name>
>   <birthdate>05/25/1965</birthdate>
>   <status>PP</status>
>   <address>
>       123 State Street
>       City, ST, 12345
>   </address>
>   <source>ALUM</source>
>   <reunion_class>ML1999</reunion_class>
>   <reunion_class>ME2002</reunion_class>
>  </person
></content>
>
>(I'm unclear on how to format the address which has multiple lines.)
>
>Anyway, would I put that String in session scope?  And then... I'm just
>reading about XSLT now.  Can someone point me in the general direction of
>which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 & a
>recent Struts nightly build with the -el tags.
>
>Thanks in advance,
>
>--
>Wendy Smoak
>http://sourceforge.net/projects/unidbtags


--
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get
glazed, they go white, their hands tremble.... As I watch them I
often feel that a dope peddler is a gentleman compared with the man
who sells records."
	--Sam Goody, 1956

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Struts & XML

Posted by Joe Germuska <Jo...@Germuska.com>.
Of course, the suggestions to check out STXX or the JSTL to use XSLT 
to style your XML are perfectly good...  and maybe that's why you 
decided to change your subroutine to return XML...  but if you want 
to get things back into familiar object-land, you could pass the XML 
to some routine which could produce a java Object for you from the 
XML.  Then you could use the object in Struts in all the usual ways.

There are whole frameworks for this (Betwixt, Zeus, Castor, others) 
but if you only need to consume the XML and never need to write it 
out in the same fashion from the object, you might want to check out 
Jakarta Commons Digester (which is how Struts reads in all of its 
configuration files.)

Once I learned how to use Digester, I never again had a moment's 
pause over the question of whether it was "too much trouble" to use 
an XML file to externalize some data -- it's really easy to use, 
especially if you have the liberty of designing your own XML format, 
in which case you can make things even easier.  Basically, you can 
assign an element name to an object and use attributes of that 
element named exactly as the properties of that object, and you can 
get Digester to construct and populate a bean for you in about three 
lines of code.

See http://jakarta.apache.org/commons/digester/api/ for details; 
there isn't a lot more documentation, but the Javadoc is pretty 
complete.

One thing to note is that digesters aren't designed to be threadsafe; 
if you are using digester in a servlet environment, you should keep 
in mind the same considerations as when writing servlets.

Joe


At 9:17 AM -0700 2002/10/23, Wendy Smoak wrote:
>Currently I'm calling a database subroutine (in an Action) that returns a
>list of keys, and then using a DAO in a loop to build up a List of Java
>objects that contain the data I need to display.  That List gets put in
>session scope and then it's off to the resolution.jsp to display it with a
><logic:iterate> tag.
>
>*IF* I changed the database subroutine to return XML, what would I do with
>it?  I'd have something like this coming back:
>
><content>
>  <person>
>   <name>John Smith</name>
>   <birthdate>05/25/1965</birthdate>
>   <status>PP</status>
>   <address>
>       123 State Street
>       City, ST, 12345
>   </address>
>   <source>ALUM</source>
>   <reunion_class>ML1999</reunion_class>
>   <reunion_class>ME2002</reunion_class>
>  </person
></content>
>
>(I'm unclear on how to format the address which has multiple lines.)
>
>Anyway, would I put that String in session scope?  And then... I'm just
>reading about XSLT now.  Can someone point me in the general direction of
>which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 & a
>recent Struts nightly build with the -el tags.
>
>Thanks in advance,
>
>--
>Wendy Smoak
>http://sourceforge.net/projects/unidbtags


-- 
--
* Joe Germuska    { joe@germuska.com }
"It's pitiful, sometimes, if they've got it bad. Their eyes get 
glazed, they go white, their hands tremble.... As I watch them I 
often feel that a dope peddler is a gentleman compared with the man 
who sells records."
	--Sam Goody, 1956

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Struts & XML

Posted by Jacob Hookom <ho...@uwec.edu>.
Check out Stxx - http://www.oroad.com/opencode/stxx/

| -----Original Message-----
| From: Wendy Smoak [mailto:Wendy.Smoak@asu.edu]
| Sent: Wednesday, October 23, 2002 11:18 AM
| To: 'Struts Users Mailing List'
| Subject: Struts & XML
| 
| 
| Currently I'm calling a database subroutine (in an Action) that
returns a
| list of keys, and then using a DAO in a loop to build up a List of
Java
| objects that contain the data I need to display.  That List gets put
in
| session scope and then it's off to the resolution.jsp to display it
with a
| <logic:iterate> tag.
| 
| *IF* I changed the database subroutine to return XML, what would I do
with
| it?  I'd have something like this coming back:
| 
| <content>
|  <person>
|   <name>John Smith</name>
|   <birthdate>05/25/1965</birthdate>
|   <status>PP</status>
|   <address>
|       123 State Street
|       City, ST, 12345
|   </address>
|   <source>ALUM</source>
|   <reunion_class>ML1999</reunion_class>
|   <reunion_class>ME2002</reunion_class>
|  </person
| </content>
| 
| (I'm unclear on how to format the address which has multiple lines.)
| 
| Anyway, would I put that String in session scope?  And then... I'm
just
| reading about XSLT now.  Can someone point me in the general direction
of
| which Struts (or other) taglibs I might need?  I'm on Tomcat 4.1.12 &
a
| recent Struts nightly build with the -el tags.
| 
| Thanks in advance,
| 
| --
| Wendy Smoak
| http://sourceforge.net/projects/unidbtags


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>