Let me ammend my comment. The formbean will only be available in the jsp if
the action that forwards to that jsp specifies the form when it is defined
in struts-config.xml. Otherwise the formbean isn't created until the jsp
submits to the action that is defined as having the form. 

> -----Original Message-----
> From: Deadman, Hal 
> Sent: Thursday, April 05, 2001 3:11 PM
> To: [EMAIL PROTECTED]
> Subject: RE: how to access related ActionForm from within .jsp?
> 
> 
> The form bean is associated with an action, not a jsp. The 
> jsp may contain
> an html:form which references an action, thereby gaining 
> access to the form
> associated with that action. A jsp could have multiple html:forms. 
> 
> The form bean associated with the action is available in 
> request scope for
> the jsp but I don't know how you would get access to it 
> without using the
> name of the form. Is there a struts tag that will get 
> actionmapping values
> when given the name of the action? That would allow you to 
> get the form bean
> name using the same action used by the html:form. 
> 
> Maybe you could use the bean:struts tag to get the action 
> mapping and then
> get the form from that. 
> 
> Hal
> 
> > -----Original Message-----
> > From: Daniel Toms [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, April 05, 2001 2:50 PM
> > To: Struts-User
> > Subject: how to access related ActionForm from within .jsp?
> > 
> > 
> > I am having a common problem all over the place.
> > Struts allows you to associate a bean(the ActionForm)
> > with a given .jsp.  It then magically gets and sets
> > input fields for you.  Great.
> > 
> > But all of the other struts tags require a reference
> > to a bean by name, using the name="foo" argument
> > to the tag.
> > 
> > My problem is, I want to reference the bean associated
> > with my jsp, so that when I want to iterated over a collection
> > it contains, I can do so without having to know the bean's name.
> > 
> > example:
> > 
> > 
> > public final class FooForm extends ActionForm
> > {
> >     public Collection bar;
> > 
> >     public Collection getBar()
> >     {
> >             return bar;
> >     }
> > 
> >     public void setBar(Collection b
> >     {
> >             this.bar = b;
> >     }
> > }
> > 
> > then in my jsp:
> > 
> >   <logic:iterate name="???" id="criterion">
> >     <TR>
> > 
> >       <TD><bean:write name="criterion" 
> property="propertyName"/></TD>
> >       <TD><bean:write name="criterion" property="operator"/></TD>
> >       <TD><bean:write name="criterion" 
> property="propertyValue"/></TD>
> >    </TR>
> >     </logic:iterate>
> > 
> > So the iterate tag doesn't work because it wants a bean by 
> > name, but is
> > there something I haven't gotten that will make struts use the bean 
> > associated with the jsp and not one specified by name?  
> > 
> > thanks,
> > 
> > dan
> > 
> 

Reply via email to