• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

optionsCollection empty

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, i use Struts 1.1, Eclipse 3.1 and JRE/JDK 1.6. I have this code in my JSP:
<html:select name="initForm" property="idman" >
<optionsCollection name="initForm" property="manList" />
</html:select>

But i get only the empty dropdownlist without any errormessages...
initForm is my ActionForm and idman is defined there as an int, manList as an List with Getter/Setter. to set the list i have this line in my InitAction:
form.setManList(getMan());
and getMan() returns a list. I made a breakpoint there, but when the jsp loads, he doesn't jump to getMan()??

Anyone an idea?
<bean:write name="initForm" property="idman"/> alone works...

Thanks
Sybyll
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to post Struts questions in the Struts forum. I have moved this there for you.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does your real code have an "html:" at the front of your optionsCollection tag? I have done similar things (usually when I forgot to add the taglib directive) and usually the tag will be ignored.

If that is not the case then look at your action that is populating the form. Make sure you are populating the form that gets passed into the execute method and not instantiating your own form (or if you are, be sure you are saving it to the request correctly).

BTW, a feature of the html tags is that if you leave off the name attribute it will use the form of the surrounding html:form tag.

- Brent
 
Sybyll Jones
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

>Does your real code have an "html:" at the front of your optionsCollection >tag?

my Init.jsp starts so:

<html:html locale="true">
<head>
<title></title>
<html:base/>
</head>
<body bgcolor="white">
<p>
<p>
<html:form action = "start">
...
<html:select name="initForm" property="idman" >
<optionsCollection name="initForm" property="manList" />
</html:select>
...

>Make sure you are populating the form that gets passed into the execute >method and not instantiating your own form (or if you are, be sure you are >saving it to the request correctly).

Here the InitAction-snippet:
public class InitAction extends DispatchAction {
public ActionForward show(ActionMapping mapping,
ActionForm aForm,
HttpServletRequest request,
HttpServletResponse response){
InitForm form = (InitForm)aForm;
try {
form.setManList(getMan());
...

My workflow:

- struts.config.xml => globalforwards: <forward name="welcome" path="/init.do?method=show"/> (that calls InitAction)
- InitAction sets the list (see code above) and has the line: "return new ActionForward("initTD");" where initTD is defined as "/pages/init.jsp"
- init.jsp should now give out the optionscollection.

Is there an error??

Sybyll
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic