Menu

Migrating from to DisplayTagColumnDecorator

Help
eclipsz
2006-08-03
2012-10-09
  • eclipsz

    eclipsz - 2006-08-03

    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&Ccedil;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(DecoratorFactory.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

     
    • veepra

      veepra - 2006-09-14

      I am having the same issue.
      I am trying to migrate from Display Tag v1.0 to v1.1.

      Has this been resolved, Any solutions ?

      Thanks

       
      • fahad

        fahad - 2006-09-15

        Yes, i placed the newest version of common.lang in the lib directory and it works fine.

        Try it out.

         
        • fahad

          fahad - 2006-09-15

          Also, u need jsp 2.0 container and 1.2 tlds.
          I suppose u must have changed these.

          I had also changed up to struts 1.2.9 if ur using 1.1, i would suggest to try changing the struts version as well after trying the above mentioned.

           

Log in to post a comment.