Meaningless Drivel is fun!
The moose likes Struts and the fly likes Default selected value in optionsCollection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Default selected value in optionsCollection" Watch "Default selected value in optionsCollection" New topic

Default selected value in optionsCollection

M Flournoy

Joined: Dec 20, 2006
Posts: 1
I know similar questions have been asked before, and I apologize, but I wasn't able to figure my problem out based on those.

I need to modify existing JSP code to have an option from a selection box be selected by default. The code I am using looks like this:

This code successfully creates the selection box and populates it accordingly, but it does not set any option as selected. The option I want to set as selected is exactly the "selDate" variable (pulled down from "pref" in the URL).

What modifications do I need to make?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

As you are using Struts tags to implement the select element, I have moved this post to the Struts forum.

[Asking smart questions] [About Bear] [Books by Bear]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The answer to this question is found in the JavaRanch Struts FAQ. If after reading this, you still can't figure it out, let us know and we'll help you.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Default selected value in optionsCollection
It's not a secret anymore!