• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

html:options tag

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm fairly new to Struts and I'm trying to use the html : options tag for the first time. The following worked when the collections attribute was assigned a List that I had set in the request scope: <html : options collection="listName" property="value" labelProperty="label" />. However, when I tried to use a List from my ActionForm, the following did not work: <html : options collection="myActionForm.listName" property="value" labelProperty="label" />. It gave me the following error message: Cannot find bean under name myActionForm.listName. Is what I am attempting even possible? Is there something else that I need to do?

Any help would be greatly appreciated.

Thanks in advance,
lugos
[ October 13, 2006: Message edited by: Samuel Lugo ]
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It is possible. However, when your jsp page loads, it does not have that List set. You have to set that list before your jsp loads. there are two ways:

In jsp page, at the top you can write following code or you can call other action to load List so this jsp page can use list of the form...

<%
if(request.getParameter() == null) {
ActionForm form = new ActionForm();
form.setList();
}
%>

Hope, you have got idea, if you have still query fill free to ask.

"Either do it with 100% commitment or do not do it, because almost is not enough"
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd suggest using the <html:optionsCollection> tag. It's a bit more intuitive than <html:options>

Here is the link to the documentation.

Your tag would look something like this:

<html:optionsCollection name="myActionForm" property="listName" value="value" label="label" />.
 
Arthur, where are your pants? Check under this tiny ad.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic