Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:select - very confusing

 
A Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Fallen Angel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
html ptions is specifically created to eliminate the use of logic:iterate to generate downdown options.
 
Artemesia Lakener
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to hold the options.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic