I solved my problem. I wanted to use an optionsCollection to display the results of a search. However, I'm working on a single page form
jsp and the dropdown needed to display empty first and then the search would be clicked and a populated dropdown would appear. So the initial page wouldn't load because it couldn't see the bean needed, yet. So, a combination of using the bean:define and having to initialize my form property made it display. here is the code below:
JSP:
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html>
<body>
<html:form action="/select">
<html:select property="neList">
<bean:define id="neName" name="selectForm" property="neName" type="java.util.ArrayList"/>
<html:optionsCollection name="neName"/>
</html:select>
<html:submit/><html:cancel/>
</html:form>
<body>
</html>
STRUTS-CONFIG.XML:
<!-- ========== Form Bean Definitions ================================== -->
<form-beans>
<form-bean name="selectForm" type="com.youcompany.struts.form.SelectForm">
<form-property name="neList" type="java.lang.String" />
<form-property name="neName" type="java.util.ArrayList" />
</form-bean>
</form-beans>
ACTION:
// Created by Xslt generator for Eclipse.
// XSL : not found (java.io.FileNotFoundException: (Bad file descriptor))
// Default XSL used : easystruts.jar$org.easystruts.xslgen.JavaClass.xsl
package com.youcompany.struts.action;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Iterator;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import com.youcompany.struts.form.SelectForm;
/**
* SelectAction.java created by EasyStruts - XsltGen.
*
http://easystruts.sf.net * created on 12-03-2003
*
* XDoclet definition:
* @struts:action path="/select" name="selectForm" input="/form/select.jsp"
* @struts:action-forward name="\form\select.jsp" path="\form\select.jsp" redirect="true"
*/
public class SelectAction extends Action {
// --------------------------------------------------------- Instance Variables
// --------------------------------------------------------- Methods
/**
* Method execute
* @param ActionMapping mapping
* @param ActionForm form
* @param HttpServletRequest request
* @param HttpServletResponse response
* @return ActionForward
* @throws Exception
*/
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
SelectForm selectForm = (SelectForm) form;
return mapping.findForward("success");
}
}
FORM:
// Created by Xslt generator for Eclipse.
// XSL : not found (java.io.FileNotFoundException: (Bad file descriptor))
// Default XSL used : easystruts.jar$org.easystruts.xslgen.JavaClass.xsl
package com.youcompany.struts.form;
import java.util.ArrayList;
import org.apache.struts.action.ActionForm;
/**
* SelectForm.java created by EasyStruts - XsltGen.
*
http://easystruts.sf.net * created on 12-03-2003
*
* XDoclet definition:
* @struts:form name="selectForm"
*/
public class SelectForm extends ActionForm {
// --------------------------------------------------------- Instance Variables
/** neList property */
private String neList;
/** neName property */
private ArrayList neName = new ArrayList();
// --------------------------------------------------------- Methods
/**
* Returns the neList.
* @return String
*/
public String getNeList() {
return neList;
}
/**
* Set the neList.
* @param neList The neList to set
*/
public void setNeList(String neList) {
this.neList = neList;
}
/**
* Returns the neName.
* @return ArrayList
*/
public ArrayList getNeName() {
return neName;
}
/**
* Set the neName.
* @param neName The neName to set
*/
public void setNeName(ArrayList neName) {
this.neName = neName;
}
}