Frank, I think that what you're running into are the limitations of assigning properties from a string value. From what I understand, JSP is effectively doing a setProperty() on the request parameters that match properties in your bean, but remember that these parameters are passed as Strings.

I believe that the relevant part of the JSP spec (I'm quoting from the 1.1 version), Section 2.13.2, paragraph 3, page 65:

Properties in a Bean can be set from one or more parameters in the request object, from a String constant, or from a compted request-time expression. Simple and indexed properties can be set using setProperties. The only types of properties that can be assigned to/from String constants and request parameter values are those listed in table 2-4; the conversion applied is shown in that table.


The table lists only the primitive types -- boolean, byte, char, double, int, float and long.

I think that what you would want to do in this case is to have add an extra date property to your bean that gets/sets the date as either a long (internal format) or as a string that you can parse. For example:

public long getUserDateInternal() {
returns getUserDate().getTime();
}
public void setUserDateInternal(long value) {
setUserDate(new Date(value));
}


Hope this helps.

Yours, JonTom

    John Thomas Kittredge
    ITA Software, Inc
    Cambridge, Massachusetts

Frank Starsinic wrote:

i noticed that when using beans, they automatically get populated from a
webpage Form when the form field names are the same as the bean properties,
and hence, good for your heart.

this works for both Integer and String types in my test example.

for some reason, a Date type is not working. does anyone know why this
would not happen. my bean name is "foo" and my bean has a test() method
that dumps out the bean properties so i can check it in my JSP page
like this  <%=foo.test()%>

when i do that i get this

Host: localhost
Port: 3453
Date: null

the setDate() method seems to be occuring but not populating the date property in
the bean
as i expect it might.    Also, in the web form, for the date i'm just putting in
4/5/1999  or something like that.

thanks,frank

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to