wood burning stoves 2.0*
The moose likes Struts and the fly likes html:select - very confusing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:select - very confusing" Watch "html:select - very confusing" New topic
Author

html:select - very confusing

A Patel
Greenhorn

Joined: Aug 19, 2005
Posts: 14
I am having a lot of difficulty understanding how the html:select works - especially if you're working with different ypes of containers e.g. hashmaps, lists, collections. When using HashMaps, everything works fine but I'm having a lot of trouble with lists. Here's what I have (I'm building a struts application):

Action Class

List bdates = dbconfig.getBusinessDates();
httpServletRequest.getSession().setAttribute("BusinessDates", busDates );



JSP Page

<%@ page import "import java.util.List" %>

<%
List getBusDates = (List) session.getAttribute("BusinessDates");
request.setAttribute("busDate", getBusDates);
%>

<html:select property="businessdate">
<html ptions collection="busDate" property="bdate"/>
</html:select>



I get an error saying no get property found for bdate in bean. So then I go to my ActionForm for this JSP page and add bdate as a string variable and its getter and setter functions. But it still doesnt work.

Can someone please explain to me how I can use a List with an Html:select and html ption tags in JSP? What am I missing?

Any assistance much appreciated.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
remove the getter/setter from your ActionForm. your List contains a list of BusinessDate objects. what are the fields in this object? if you want to use property = 'bdate' for your html ptions this object must have a String bdate field with the setBdate() and getBdate() methods.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Fallen Angel
Greenhorn

Joined: Sep 07, 2005
Posts: 5
i think that inside the html:select you need a logic:iterate - you then output the values using a bean:write nested inside a html ption tag.
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
html ptions is specifically created to eliminate the use of logic:iterate to generate downdown options.
Artemesia Lakener
Ranch Hand

Joined: Jun 21, 2005
Posts: 162
Originally posted by Fallen Angel:
i think that inside the html:select you need a logic:iterate - you then output the values using a bean:write nested inside a html ption tag.


then what's <html ption> for ??
Fallen Angel
Greenhorn

Joined: Sep 07, 2005
Posts: 5
to hold the options.
 
wood burning stoves
 
subject: html:select - very confusing
 
Similar Threads
update html:options
LabelValueBean html:select
BeanUtils.populate error
Problem in getting selected values from multiselect list
How to transfer elements between two list boxex ?