With a quick glance, are you trying to cast a CollectionModel object to a
NewsModel object?  Or does the CollectionModel object contain NewsModel
objects?

You could put in some trace messages before you get the error.  Go ahead and
get the object as an Object, then call getClass().getName() on it to see
what class it is that you've got before doing the cast.

Rick Herrick
[EMAIL PROTECTED]

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:displaytag-user-
> [EMAIL PROTECTED] On Behalf Of Patrick Gelin
> Sent: Wednesday, August 03, 2005 7:14 AM
> To: [email protected]
> Subject: [displaytag-user] Casting problem...
> 
> Hi,
> 
> I'm writing a decorator for my table but I'm getting into trouble with a
> casting problem....
> 
> My collection is defined like this:
> --------------------------------------
> public final class CollectionModel extends ArrayList {
> (...)
> }
> 
> My display table is defined like this:
> --------------------------------------
> <display:table id="cllt" name = "sessionScope.collection" export = "false"
> pagesize = "10" requestURI="<%=request.getContextPath() +
> "/CollectionCtrl/CollectionView"%>" decorator="osis.jahia1.Decorator">
>             <display:column property = "id" title = "N." sortable = "true"
> />
>             <%
>             if ("news".equalsIgnoreCase(collection.getType()))
>                 {
>             %>
>                 <display:column property = "link1" title = "Titre" sortabl
> e
> = "true"/>
>             <%
>                 }
>             else
>                 {
>             %>
>                 <display:column property = "title" title = "Titre" href =
> "<%=response.encodeURL(request.getContextPath()
> +"/ElmtCtrl/EventEditView")%>" paramId = "id"
>                                paramProperty="id" sortable = "true"/>
>             <%
>                 }
>             %>
>             <display:column property = "publishDates" title = "Du...au"/>
> 
>             <display:column property = "user" title = "Propos&eacute;
> par..." sortable = "true"/>
>         </display:table>
> 
> And my Decorator is:
> -------------------------------------------
> public class Decorator extends TableDecorator {
> 
>         public String getLink1(){
> 
>                 NewsModel news = (NewsModel)getCurrentRowObject();
> 
>                 HttpServletRequest request =
> (HttpServletRequest)getPageContext().getRequest();
>                 HttpServletResponse response =
> (HttpServletResponse)getPageContext().getResponse();
> 
>                 return "&lt;a href=\"" + response.encodeURL(request.getCon
> textPath()
> +"/ElmtCtrl/NewsEditView") + "?id=" + news.getId() + "\">" +
> news.getTitle() + "&lt;/a>";
>         }
> 
>         /**
> [EMAIL PROTECTED]
>          */
>         public static void main(String[] args) {
>                 // TODO Auto-generated method stub
> 
>         }
> }
> 
> The Exception error message is:
> --------------------------------
> e= JasperException  (id=4598)
>         cause= JasperException  (id=4598)
>         detailMessage= "osis.jahia1.CollectionModel"
>         rootCause= ClassCastException  (id=4628)
>         stackTrace= StackTraceElement[100]  (id=4629)
> 
> So what is the problem with decorator? (My table is working fine without
> decorator)
> 
> Any help is welcome.
> 
> Thanks.
> 
> --
> 
> 
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> displaytag-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/displaytag-user


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
displaytag-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to