Did you try returning Object from the implemented decorate method instead?
public Object decorate(Object aValue, PageContext aContext,
MediaTypeEnum aMediaType) throws DecoratorException
RB
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of SourceForge.net
Sent: Thursday, August 03, 2006 6:32 AM
To: [EMAIL PROTECTED]
Subject: [displaytag-user] [displaytag - Help] Migrating from
toDisplayTagColumnDecorator
Read and respond to this message at:
https://sourceforge.net/forum/message.php?msg_id=3850815
By: eclipsz
I got ClassCastException when trying to upgrade from ColumnDecorator to
DisplayTagColumnDecorator Interface. I made the proper changes in my Decorator
implementations, but it just keeps throwing a ClassCastException.
Here is the code of my decorator :
===========================================
import java.util.Date;
import javax.servlet.jsp.PageContext;
import org.apache.log4j.Logger;
import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;
import fr.acoss.tech.format.Utiles;
public class DateWrapper implements DisplaytagColumnDecorator {
private static final Logger LOGGER = Logger.getLogger(DateWrapper.class);
public String decorate(Object aValue, PageContext aContext, MediaTypeEnum
aMediaType)
throws DecoratorException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("decorate() - [Début]");
}
if (aValue == null) {
return "";
}
try {
if (aValue instanceof Date) {
return Utiles.formatDateFrancais((Date) aValue);
} else if (aValue instanceof String) {
return Utiles.formatDate(((String) aValue));
} else {
return "";
}
} catch (Exception e) {
LOGGER.error(
"decorate(Object value) - Erreur lors de la transformation
dans un format date de '"
+ aValue + "' - Exception:", e);
return "#err";
}
}
}
==========================================
Utiles.formatDateFrancais returns a String
Here is the tag statement in the JSP :
==================================
<display:table name="RECU_CB" pagesize="10" requestURI="/servlet/cotisant"
class="main" id="bean_recu" sort="list">
<display:caption>MESSAGES REÇUS</display:caption>
<display:column class="center" property="date" title="Date"
sortable="true"
sortProperty="date" headerClass="sortable"
decorator="fr.acoss.dcl.gui.displaytag.decorator.DateWrapper" />
<!-- ... -->
</display:table>
===============================================
Exception: [.DecoratorFactory] Unable to load
fr.acoss.dcl.gui.displaytag.decorator.DateWrapper due to
a java.lang.ClassCastException exception Cause:
fr.acoss.dcl.gui.displaytag.decorator.DateWrapper
at
org.displaytag.decorator.DecoratorFactory.loadColumnDecorator(DecoratorFacto
ry.java:108)
at org.displaytag.tags.ColumnTag.addHeaderToTable(ColumnTag.java:621)
at org.displaytag.tags.ColumnTag.doEndTag(ColumnTag.java:547)
#########################################
If I remove the decorator attribute in the displaytag, the array is well
displayed
______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit:
https://sourceforge.net/forum/unmonitor.php?forum_id=249318
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user