wood burning stoves 2.0*
The moose likes Struts and the fly likes Problem with html:options collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with html:options collection" Watch "Problem with html:options collection" New topic
Author

Problem with html:options collection

Java Coder
Greenhorn

Joined: Dec 13, 2004
Posts: 3
Hello Community,

I am trying to populate a drag down list the select the option. It is giving me an JspException:"Cannot find bean under name aDOrder". If possible please, take a look at the code and let me know what am I doing wrong and how the problem can be fixed???
Please, provide the elaborate answer, as I am newbie to the Struts.
Thanks, in advance for taking out time for me. I really appreciate for the effort.

Show_Form.jsp
*************************
<html:select name="searchForm" property="order_in">
<html ptions collection="aDOrder"/>
</html:select>

struts-config.xml
******************************
<action path="/searchForm"
type="example.WebApp.SearchFormAction"
name = "searchForm"
scope = "request"
validate = "false"
input="/Search_Form.jsp"
>
<forward
name="success"
path="/Album-List.jsp"/>
</action>
SearchFormAction.java
******************************
public final class SearchFormAction extends Action {

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {


SearchFormService sf_service = new SearchFormService();
Collection aDOrder = sf_service.getADOrder();
Collection dTOrder = sf_service.getDTOrder();
//HttpSession session = request.getSession();
request.setAttribute("aDOrder", aDOrder);
//session.setAttribute("DT_order", dTOrder);
SearchForm searchForm = (SearchForm)form;
searchForm.setOrder_in("1");
return (mapping.findForward("success"));
}
}
SearchFormService.java
*****************************************
public class SearchFormService
{

public Collection getADOrder()
{
ArrayList alist = new ArrayList(2);
alist.add(new OrderADBean(1, "Ascending"));
alist.add (new OrderADBean(2, "Descending"));
return alist;
}

public Collection getDTOrder()
{
ArrayList alist = new ArrayList(2);
alist.add(new OrderADBean(1, "Date"));
alist.add (new OrderADBean(2, "Title"));
return alist;
}

}
SearchForm.java
***********************************
public class SearchForm extends ActionForm
{
String asc;
String dsc;
String date;
String title;
String orderin;
String orderby;

public String getAsc()
{
return asc;
}
public void setAsc(String asc)
{
this.asc=asc;
}
public String getDsc()
{
return dsc;
}
public void setDsc(String dsc)
{
this.dsc=dsc;
}
public String getDate()
{
return date;
}
public void setDate(String date)
{
this.date=date;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title=title;
}
public String getOrder_in()
{
return orderin;
}
public void setOrder_in(String orderin)
{
this.orderin=orderin;
}




}
John Smith
Ranch Hand

Joined: Sep 02, 2004
Posts: 61
Try doing a bean efine on that bean or a tiles:useAttribute before you use it in your options tag
[ December 13, 2004: Message edited by: John Smith ]
Java Coder
Greenhorn

Joined: Dec 13, 2004
Posts: 3
Originally posted by John Smith:
Try doing a bean efine on that bean or a tiles:useAttribute before you use it in your options tag

[ December 13, 2004: Message edited by: John Smith ]


Please, be more specific. The suggestion went above my head.

Thanks,
Nimchi Yung
Ranch Hand

Joined: Jan 27, 2004
Posts: 71


You probably also need to specify the labelProperty
and property attributes.

--Nimchi
Java Coder
Greenhorn

Joined: Dec 13, 2004
Posts: 3
Originally posted by Nimchi Yung:


You probably also need to specify the labelProperty
and property attributes.

--Nimchi


Hi,

I had removed those tags, to simplify the problem. It is throwing an JspException for collection="aDOrder". :"Cannot find bean under name aDOrder".
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4442
    
    5

"Java Coder"

Welcome to JavaRanch. Please update your profile so that your publicly displayed name complies with the JavaRanch Naming Policy. Thanks for your cooperation.

What URL are using? Are you accessing the JSP directly or are you going through searchForm.do?


Junilu - [How to Ask Questions] [How to Answer Questions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with html:options collection
 
Similar Threads
Struts ArrayList Display in JSP
problem with action mapping
Cannot find bean: "EMPLOYEELIST" in any scope
How to use html:options
Generics