I've got a page in my Struts web app that displays a date. It uses
<fmt:formatDate...> to read a date from the form bean and format it for
display. I also want to put that date into a <html:hidden...> field so that
it can be reloaded when the page is submitted and redisplayed.

The getter returns a Date. The <fmt:formatDate tag gets this and converts it
to the "default" format (Sep 9, 2005). No problem there. The
<html:hidden...> tag retrieves also retrieves it and converts it to this:
2005-09-09. 

The getter returns a Date, the setter takes a String and converts it to a
Date. Or it tries to. I've put debug print into the setter, and it
apparently is not getting called at all! What's going on?

The app is running in Jboss 3.2.5

Here are my getter and setter pair:

    /** setter for expirationDate
     @param String new value for expirationDate
    */
    public void setExpirationDate(String expirationDate)
    {        
        System.out.println("New date: " + expirationDate);
        try
        {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            this.expirationDate = sdf.parse(expirationDate);
        }
        catch (ParseException ex)
        {
            System.out.println("format failed: " + ex.getMessage());
            this.expirationDate = null;
        }
    }

    /** getter for expirationDate
     @return Date value of expirationDate
    */
    public Date getExpirationDate()
    {
        return expirationDate;
    }

Here are the tags from the jsp page:

 <strong>Expiration Date: </strong><fmt:formatDate 
                dateStyle="default"
value="${UpdPending.expirationDate}"/><BR>
<html-el:hidden property="expirationDate"/>


--
Tim Slattery
[EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to