[ 
https://issues.apache.org/jira/browse/TOMAHAWK-1367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12644724#action_12644724
 ] 

Mike Kienenberger commented on TOMAHAWK-1367:
---------------------------------------------

The reason we won't fix it is because it's not a bug in EL, nor in the API for 
t:dataTable.   Thus it's a bug in your glue code between the two (the EL 
expression).

The EL spec requires that #{8} evaluates to a Long.

The t:dataTable API requires that NewsPaperColumns is an Integer.

Thus, passing a Long into an Integer method is a bug in your application.

What you have to do is pass an integer instead of a Long.

Some ways to do this are:

1) Create a constants bean.

int getEight() { return 8 };
int getSeven() { return 7};
newspaperColumns="#{MyController.showFoo? constants.seven : constants.eight}" 

2) create a Facelets function

newspaperColumns="#{MyController.showFoo? myFunctions:toInt(7) : 
myFunctions:toInt(8)}" 

3) move the logic into the controller bean:

newspaperColumns="#{MyController.fooNewspaperColumnSize}"

There are probably other ways as well, but I'm not actively using JSF these 
days.
What we cannot do is:

a) Change the t:DataTable API so that it no longer accepts an Integer value, at 
least not without some dev mailing list discussion on the impacts.

b) Automatically typecast a Long into an Integer without dev mailing list 
discussion.   There's a reason why Java doesn't do this automatically, and I'm 
not sure if t:dataTable should either.   Practically speaking, I can't think of 
any reason why someone would use a Long that was bigger than an int for this 
value, though.

It'd probably be better if this conversation were moved to the mailing list.


> ClassCastException in HtmlDataTable newspaperColumns
> ----------------------------------------------------
>
>                 Key: TOMAHAWK-1367
>                 URL: https://issues.apache.org/jira/browse/TOMAHAWK-1367
>             Project: MyFaces Tomahawk
>          Issue Type: Bug
>          Components: Extended Datatable
>    Affects Versions: 1.1.7
>         Environment: myFaces 1.1.5, tomahawk 1.1.7, richfaces 3.1.5
>            Reporter: Michael Heinen
>            Priority: Critical
>
> Following ClassCast Eception is thrown if I use an EL expression in the 
> newspaperColumns attribute:
> java.lang.ClassCastException: java.lang.Long cannot be cast to 
> java.lang.Integer
>       at 
> org.apache.myfaces.component.html.ext.HtmlDataTable.getNewspaperColumns(HtmlDataTable.java:453)
>       at 
> org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer.getNewspaperColumns(HtmlTableRenderer.java:81)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:250)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:140)
>       at 
> org.apache.myfaces.renderkit.html.ext.HtmlTableRenderer.encodeChildren(HtmlTableRenderer.java:280)
>       at 
> javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:415)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChildren(RendererUtils.java:401)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:418)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChildren(RendererUtils.java:401)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:418)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChildren(RendererUtils.java:401)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:418)
>       at 
> org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChildren(RendererUtils.java:401)
>       at 
> org.apache.myfaces.renderkit.html.ext.HtmlGroupRenderer.encodeEnd(HtmlGroupRenderer.java:71)
>       at 
> javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:539)
>       at 
> org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:286)
> sample usage:
> <t:dataTable id="l" forceId="true"
>   value="#{MyController.myList}"
>   newspaperOrientation="horizontal"
>   newspaperColumns="#{MyController.showFoo?7:8}"
> Pls see also TOMAHAWK-728 newspaperColumns attribute ignores EL expression.
> I provided a patch there but it is has not been applied and 728 has been set 
> to fixed although it is not working!

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to