Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with html:options collection

 
Java Coder
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

--Nimchi
 
Java Coder
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic