A general design for this sort of thing would be to load your collection
of teams at application start up and put them into the ServletContext.

Define an action for displaying the teams page and an action for
processing the user input after they have selected a team. Define your
actions to forward to these pages and not redirect. The display action
can simply be a forward defined in your struts-config.xml since the
teams already exist in the ServletContext. You will have to subclass
one the many XXXXAction classes in order to process the user input subsequent
to their team selection.

The teams page can enlist the help of the <html:optionsCollection .../>
to render the drop down list.
http://jakarta.apache.org/struts/userGuide/struts-html.html#optionsCollection


As Brian already mentioned, you can utilize some third party tools like
the displayTag library found here http://displaytag.sourceforge.net/ to
render the riders in tabular format.

"Hide" your pages behind WEB-INF. Something like WEB-INF/pages/teams.jsp.
Note that most (but not all) web containers disallow direct access to 
resources which are in the WEB-INF directory. This helps enforce the 
MVC aspect of your web application.

There are several ways to tackle this problem and the above is just some
high level advice.


I would review (actually install and do a code trace) the Struts example
web apps.


hth,

robert





> -----Original Message-----
> From: Jamison Roberts [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 25, 2004 2:46 PM
> To: Struts Mailing List
> Subject: Trying to learn Struts, need help understanding design process
> 
> 
> I've been a C#/.Net developer for two years.  Recently my company has
> decided to move towards Java/Struts, so i've spent the last three
> weeks familiarizing myself with Java, JDBC, Type 4 drivers, Tomcat,
> Ant, and Struts.
> 
> Struts is the last thing i've tried to tackle, and I thought I had a
> handle on it, however I don't.  I'm not sure of the best (or
> correct/standard) way of doing simple things.  I've read that if I
> ever have a *.jsp showing in the address bar outside of the entry
> page, i've done something wrong.
> 
> I'd like to give an example, and hear suggestions on the correct way
> to implement such an idea.  Simple example to follow...
> 
> Let's say I have a database that contains a two tables:  one called
> teams, and one called riders.  There is a one-to-many relationship
> between teams and riders based on a "teamid."
> 
> In the teams table, we have the following data (Primary Key in parens):
> (1) USPS
> (2) T-Mobile
> (3) Cofidis
> (4) Phonak
> ...
> 
> In the riders table, we have this data (relationship in parens):
> Lance Armstrong (teamid = 1)
> George Hincapie (teamid = 1)
> Jan Ullrich (teamid = 2)
> Alexandre Vinokourov (teamid = 2)
> David Millar (teamid = 3)
> Tyler Hamilton (teamid = 4)
> ...
> 
> >From the Index.jsp, there should be a link to another page that will
> have a single select box, and a submit button.  The select box needs
> to be populated with a list of teams/teamids from the database.
> 
> Upon submission of the form, all riders will be displayed in a table.
> 
> Pretty simple stuff, except I can't seem to figure out how to do it
> with Struts.  The closest i've gotten is to have a "static" Teams.jsp
> with an input-text box, which calls an Action to display the users. 
> In otherwords my Index.jsp links to Teams.jsp, instead of something
> like Teams.do (and I can't figure out how to populate a select box
> from a Vector or other sort of list).
> 
> I apologize for asking simple questions, but i'm at the end of my rope
> trying to figure out all these "new" technologies (new to my Microsoft
> dominated world).
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to