import java.util.*;
import javax.servlet.http.*;
public class DatePulldown
{
// ... Other class code omitted to save space
protected String Name;
public DatePulldown()
{
Name = "";
}
public DatePulldown(String name)
{
Name = new String(name);
}
int StrToInt(String str)
{
... // implementation omitted
}
public void setDate(HttpServletRequest request)
{
// We're pulling 3 fields out here:
int month = 0;
int day = 0;
int year = 0;
// If this pulldown has been assigned a name, expect that
// the name will be prepended to the form variable names.
// Otherwise just use the variable names directly.
if(Name != null && Name.length() > 0)
{
month = StrToInt(request.getParameter(Name + ".month"));
day = StrToInt(request.getParameter(Name + ".day"));
year = StrToInt(request.getParameter(Name + ".year"));
}
else
{
month = StrToInt(request.getParameter("month"));
day = StrToInt(request.getParameter("day"));
year = StrToInt(request.getParameter("year"));
}
// Remember that the month needs to be zero-based.
Cal.set(year, month - 1, day);
}
}
End of Listing