aspose file tools*
The moose likes Struts and the fly likes optionsCollection empty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "optionsCollection empty" Watch "optionsCollection empty" New topic
Author

optionsCollection empty

Sybyll Jones
Greenhorn

Joined: Dec 20, 2007
Posts: 14
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

Joined: Jan 10, 2002
Posts: 61661
    
  67

Please be sure to post Struts questions in the Struts forum. I have moved this there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
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

Joined: Dec 20, 2007
Posts: 14
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: optionsCollection empty