> hi all.  I am somewhat new to struts and have a question 
> regarding the 
> <html:options> tag.

hi. :)

> 
> If I wanted to specify the collection to come from an array or list 
> contained in a bean, how would that be accomplished?
> 
> can I just import the bean class into the jsp and then use 
> <html:options 
> collection=[name of property]>?

If my collection is in my form bean, this is how I would do it in the JSP:

<bean:define id="myCollection" name="myFormBean" property="myCollectionField" />

<html:options collection="myCollection" property="myValueField" 
labelProperty="myLabelField" />

> 
> also...if say I wanted to put this information in a utility 
> class to make it 
> available to a number of different jsp's, how would I tell 
> the tag to use 
> bean X instead of the FormBean associated with the page in 
> the config file?

If bean X is already instantiated and in the request/session, then all you would have 
to do is change your <bean:define> tag to reference the attribute name of bean X:

// do this in your action somewhere
request.setAttribute("beanX", new BeanX() );

// and this in your JSP
<bean:define id="myCollection" name="beanX" property="myGlobalCollection" />


Note that if this utility bean is global to the web app., then you probably want to 
put the bean into the ServletContext, so that it's only created once.  Then you would 
fetch it from the ServletContext in your action and stuff it into the request so it 
can be accessed from your JSPs.

> 
> I'm sorry if this is a dumb question, but I have searched the 
> archives and 
> found nothing.

Not a dumb question.  The docs for <html:options> are difficult to understand, and the 
semantics for the tag's attributes are completely non-intuitive.

> 
> Thanks in advance for your assistance.  It is much appreciated.
> 
> Regards,
> 
> Chris
> 
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


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

Reply via email to