This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:option selected

 
A Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 JSP pages each with a dates drop down combo box whose contents are the same. However, on the first page the user can set a default date that s/he can use throughout the application.

So on the second JSP page in the drop down combo box, I'd like to set the selected default date (from the first page) as the first/selected value in the drop down but at the same time the user should be able to select a different date from the list.

Is this possible in struts?

Here's my code:

<html:select property="dates">
<% for(int i=0; i < listsize; i++)
{%>
<html ption value="<%bdatesList.get(i)%>"><%=bdatesList.get(i)%></html ption>
<%}
%>
</html:select>
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place this default date into the ActionForm before entering the jsp. You probably need to use a SetupAction for this. The other option would be to set the default value into the date field within the ActionForm's reset method.

When this value is in the ActionForm Struts will automatically select the corresponding value(s) in the jsp.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic