File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes checkbox iterate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "checkbox iterate" Watch "checkbox iterate" New topic
Author

checkbox iterate

Armstrong Dor
Greenhorn

Joined: Jul 23, 2002
Posts: 5
this is my code in the jsp
---------------------------------------------
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head></head>
<body>
<html:form action="/test">
<logic:iterate id="item" property="items">
<html:multibox property="selectedItems">
<bean:write name="item"/>
</html:multibox>
<bean:write name="item"/>
</logic:iterate>
</html:form>
</body>
</html>
---------------------------------------------
THIS IS MY FORM BEAN CODE
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class CheckForm extends ActionForm {
private String[] selectedItems = {};
private String[] items = {"UPS","FedEx","Airborne"};
public String[] getSelectedItems() {
return this.selectedItems;
}
public void setSelectedItems(String[] selectedItems) {
this.selectedItems = selectedItems;
}
}
------------------------------------------------
WHEN I RUN THIS IN TOMCAT SAYS
===============================
javax.servlet.ServletException: Cannot find bean CheckForm in scope null
CAN ANYONE OF YOU TELL ME WHAT IS WRONG HERE
Thanks in Advance
Armstrong.D


Armstrong D
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Do you get the exception when the page is trying to render, or do yo get the exception when you hit submit? Make sure the appropriate actions are using your form-bean. Go ahead and post yor action-mappings and your form-bean section from the struts-config and we can see if anything stands out.
[ January 20, 2003: Message edited by: Jason Menard ]
Steve Aschom
Greenhorn

Joined: Jan 20, 2003
Posts: 1
This is identical to the problem I'm having. He's getting the 'scope null' error on the way into the JSP. It's as if the logic:iterate tag does not recognize this combination of attributes as referencing the ActionForm.
So I'd rephrase the question like this. How do you pull a collection from the ActionForm in your JSP without explicitly naming the ActionForm in the 'name' attribute of the logic:iterate tag?
The reason I don't want to explicitly name the ActionForm as the bean (which works fine for display) is because, when you do, the collection does not get updated with changes to the array on the way out of the JSP.
Can anyone shed some light?
Thanks
shawn kennedy
Ranch Hand

Joined: Oct 31, 2002
Posts: 67
try to specify the name of your form in <html:form> tag and in its sub elements.Also have u defined the form in the struts config.xml under <form-bean> and then given the name=formname in the <action> in struts-config.If not first enter this and then try giving the form name in the <html:form>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: checkbox iterate
 
Similar Threads
Using html:multibox
html:multibox
Urgent Help Required with Checkboxes!
html:multibox
Problem using html:radio