In can be used other ways, but Struts is designed to be a Model 2/MVC
framework. This means you should avoid linking to JSP's directly.
Generally, everything should go through a server-side Action first,
where you can collect whatever data you need for the JSP, and then
forward it through the request context for the JSP to display. The *.do
files are mapped to Struts controller, which calls the server-side
Action. The controller consults the Action Mappings, loaded from
struts-config.xml, to determine which Action to call.
A re-reading of the Users Guide might help you get the big picture.
DHarty wrote:
>
> Okay, I changed my page to look like this.
>
> <logic:iterate name="SearchForm" property="result" id="user">
> <tr>
> <td align="center"><bean:write name="user"
> property="username"/> </td>
> <td align="center">
> <html:link forward="modifyUser" paramName="user" paramId="UserForm" >
> Modify
> </html:link>
> </td>
> </tr>
> </logic:iterate>
>
> this produces a link like
> :http://.../user_mod.jsp?UserForm=edu.erau...form.UserForm%40ff5bdefc
>
> I have a global action "modifyUser" with a path to /<path>/user_mod.jsp.
> I am able to pick up the UserForm parameter in ModifyUser, but I am unable
> to use it as the UserForm bean. Am I passing a reference to the UserForm
> Bean, or just a name? how do I reconstruct the UserForm bean in ModifyUser?
> I experimented with <bean:(define,include and parameter)../> with no
> success.
>
> I'm sorry if these questions are simplistic, but I am new to jsp, and
> especially struts.
>
> Also, in the origional example, the global path is to a .do file. I was
> under the impression that the ".do" files were generated by the server. Do
> I need to have a generated page waiting to receive my request? How is this
> done?
>
> thnxs again,
> David
>
> -----Original Message-----
> From: Ted Husted [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 22, 2001 12:10 PM
> To: [EMAIL PROTECTED]
> Subject: Re: html action links
>
> If you just want to use html:link, you don't necessarily have to use an
> ActionForm class (though you can, if you want).
>
> Here's some code for generating a list with links. Result is a bean that
> exposes a collection named rows.
>
> <logic:iterate name="result" property="rows" id="row">
> <p>
> <html:link forward="donor" paramName="row" paramId="key"
> paramProperty="donor">
> <bean:write name="row" property="donor" filter="true"/>
> </html:link>
> </p>
> </logic:iterate>
>
> When the page renders, it generates links like this:
>
> <a
> href="http://localhost/struts-stub/donor/View.do?key=123456">123456</a>
>
> where there is a global forward "donor" with the path "/donor/View.do"
>
> and row.getDonor() returns 123456
>
> DHarty wrote:
> >
> > This is really a two part question.
> >
> > I have an iterative loop that displays a list users that are stored in
> > Action Forms. The idea is that when the button (or link) next to the item
> > is selected, the user will be allowed to make modifications to the
> selected
> > form:
> >
> > <logic:iterate id="user" name="SearchForm" property="result">
> > <tr>
> > <html:form action="/usermodify">
> > <td align="center">
> > <bean:write name="user" property="username"/>
> > </td>
> > <td align="center">
> > <html:submit property="username">Modify
> > </html:submit>
> > </td>
> > </html:form>
> > </tr>
> > </logic:iterate>
> >
> > Where "result" is a vector of ActionForms.
> >
> > Currently, when the "Modify" button is selected, the appropriate action
> > class is called, but the ActionForm is reset.
> >
> > I know I could add a field to the submit button, i.e:
> >
> > <html:submit property="username">Modify <bean:write
> > property="username"/></html:submit>
> >
> > and then have the action class look up the user in hte database again, but
> I
> > would rather not.
> >
> > I was considering using an html link instead of a button, but was unsure
> how
> > to proceed.
> > Ideally, I would like to use an html link, while retaining the existing
> form
> > (without having to look it up again).
> >
> > Any thoughts or comments would be appreciated.
> >
> > Thnxs
> >
> > David
-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel 716 737-3463.
-- http://www.husted.com/about/struts/