Thanks, I'll try this.
Richard

On 3/9/07, Brett Knights <[EMAIL PROTECTED]> wrote:
I use this:

package appfuse.webapp.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.jsp.PageContext;

import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

public class ListUtil {
    public static final SimpleDateFormat detailDateFormat = new
SimpleDateFormat("yyyy-MM-dd hh:mm:ss a z");


    public static DisplaytagColumnDecorator  getListDateDecorator(){
        return getListDateDecorator(detailDateFormat);
    }

    public static DisplaytagColumnDecorator getListDateDecorator(final
DateFormat fmt){
        return new DisplaytagColumnDecorator(){

            public Object decorate(Object obj, PageContext ctx,
MediaTypeEnum media) throws DecoratorException {
                if(obj == null) return null;
                return fmt.format((Date)obj);
            }
        };
    }

}

// and then one instance of using it is like:

package appfuse.webapp.action;

import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import appfuse.Constants;

import appfuse.service.IncidentManager;
import appfuse.webapp.util.ListUtil;

public class SupportIncidentController implements Controller {

    private IncidentManager incidentManager;

    public void setIncidentManager(IncidentManager mgr){
        this.incidentManager = mgr;
    }

    public ModelAndView handleRequest(HttpServletRequest req,
HttpServletResponse res) throws Exception {

        String months = req.getParameter("monthsOld");

        if(StringUtils.isEmpty(months)) months = "6";

        Calendar cal = new GregorianCalendar();
        cal.add(Calendar.MONTH, -1 * Integer.parseInt(months));
        java.util.List incidents =
incidentManager.getIncidentsSince(cal.getTime());
        req.setAttribute("listDateDecorator",
ListUtil.getListDateDecorator(DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM,req.getLocale())));
        req.setAttribute("refData",
incidentManager.getSupportReferenceData());
        return new ModelAndView("caseList", Constants.INCIDENT_LIST,
incidents);
    }

}

// then a jsp would have a display:column definition like:

    <display:column property="shipmentDate" escapeXml="true"
sortable="true" titleKey="order.shipmentDate"
decorator="listDateDecorator"/>


HTH
Brett Knights

Richard G. Reyes wrote:
> MySQL column datatype is DATETIME, then I changed my pojo's datatype
> from java.util.Date to java.sql.Timestamp.
>
> Still results to the same error.
>
> Richard
>
> On 3/9/07, Richard G. Reyes <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>
>> I have modified my DateDecorator from extending TableDecorator to
>> implementing DisplaytagColumnDecorator. Displaytag managed to load the
>> decorator. Now I am encountering this exception...
>>
>> javax.servlet.jsp.JspException: java.sql.Timestamp
>>         at
>> 
org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate.java:161)
>>
>>         at
>> org.displaytag.render.HtmlTableWriter.writeTable(HtmlTableWriter.java:643)
>>
>>         at
>> org.displaytag.tags.TableTag.writeHTMLData(TableTag.java:1549)
>>         at org.displaytag.tags.TableTag.doEndTag(TableTag.java:1218)
>>         at
>> 
org.apache.jsp.WEB_002dINF.pages.referralList_jsp._jspService(referralList_jsp.java:179)
>>
>>         at
>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>         at
>> 
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
>>
>>         at
>> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
>>         at
>> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>>
>>
>> Again any help is appreciated.
>> Thanks
>> Richard
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>

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



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

Reply via email to