Setting default value to html:select in JSP ??
From: Azmie (amiez_at_yahoo.com)
Date: 03/30/04
- Next message: Mike: "Loop through DataInputStream"
- Previous message: V. Natarajan: "Struts 1.1 and JDK 1.2 ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Mar 2004 21:50:07 -0800
have someone experience on how to set default value in <html:select> ?
What will be the best way to do this..?
pls help
this is my code but it won't work. I'm not sure this is the right way.
Code in Action
Date today = new Date();
DateFormat yearFormat=new SimpleDateFormat("yyyy");
String theYear = yearFormat.format(today);
form.setSubscriptionYear(theYear); // try set value in jsp but
won't work
System.out.println("YEAR DEFAULT : "+form.getSubscriptionYear());
Vector yearList = getYearList();
session.setAttribute ("YEARLIST", yearList);
return forwardInitialize(mapping);
_______________________________________________________________
getYearList
public static Vector getYearOTList()
{
Vector selectYearList = new Vector();
for (int i=2003;i<2010;i++)
{
String sLabel = Integer.toString(i);
String iValue = Integer.toString(i);
String sValue = "" + iValue;
selectYearList.add(new LabelValueBean(sLabel,sValue));
}
return selectYearList;
}
_______________________________________________________________
Code in JSP
<tr>
<td WIDTH="29%" BGCOLOR="C9B7DF"><FONT SIZE=2 COLOR="black"
FACE="Verdana">
Subscription Year</FONT></td>
<td WIDTH="71%" bgcolor="C9B7DF"><FONT SIZE=2 COLOR="black"
FACE="Verdana">
<html:select property="subscriptionYear"><html:options
collection="YEARLIST" property="value" labelProperty="label"/>
</html:select> </FONT></td>
</tr>
- Next message: Mike: "Loop through DataInputStream"
- Previous message: V. Natarajan: "Struts 1.1 and JDK 1.2 ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]