• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

checkbox iterate

 
Armstrong Dor
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic