• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

optionsCollection empty

 
Sybyll Jones
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64717
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to post Struts questions in the Struts forum. I have moved this there for you.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic