File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes html:option selected Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:option selected" Watch "html:option selected" New topic

html:option selected

A Patel

Joined: Aug 19, 2005
Posts: 14
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>
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

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.

A good workman is known by his tools.
I agree. Here's the link:
subject: html:option selected
It's not a secret anymore!