This code fragment creates a read-only "date" property.
If you now define on your form a month, date and year properties then
the "date" is automatically set.
private String month;
public String getMonth () { return this.month; }
public void setMonth (String month) { this.month= month; }
private String day;
public String getDay () { return this.day; }
public void setDay (String day) { this.day= day; }
private String year;
public String getYear () { return this.year; }
public void setYear (String year) { this.year= year; }
public String getDate () {
// new "date" property returns "dd/mm/yyyy"
return this.day + "/" + this.month + "/" + this.year ;
}
---------------------------------------
To accomplish things the other way around - set only the date and later retrieve
month, day and year - do this:
This code fragment creates a read-only "month" , "day" and "year" properties
// Note: assumes date is correctly set as 10 characters "dd/mm/yyyy"
public String getMonth () { return date.substring(3, 5) ; }
public String getDay () { return date.substring(0, 2); }
public String getYear () { return date.substring(6); }
private String date;
public void setYear (String date) { this.date= date; }
public String getDate () { return this.date; }
FWIW -
Kevin
"Michael Marrotte" <[EMAIL PROTECTED]> on 05/14/2002 11:20:02 AM
Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
cc: (bcc: Kevin Bedell/Systems/USHO/SunLife)
Subject: One setter for multiple input fields?
I have 3 properties (month, day, year) in the JSP. Is there a shortcut-way
to get my form bean to set a date property based on these three fields
without explicitly?
Michael Marrotte
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use
of the individual or entity to which it is addressed and may contain
information that is privileged, proprietary , confidential and exempt from
disclosure. If you are not the intended recipient, you are notified that
any dissemination, distribution or copying of this communication is
strictly prohibited. If you have received this communication in error,
please notify the sender and erase this e-mail message immediately.
---------------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>