You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Thorsten Schäfer (JIRA)" <ji...@apache.org> on 2007/11/21 17:32:33 UTC

[jira] Created: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

ValueStackDataSource implementation leads to class cast exceptions
------------------------------------------------------------------

                 Key: WW-2333
                 URL: https://issues.apache.org/struts/browse/WW-2333
             Project: Struts 2
          Issue Type: Bug
          Components: Plugin - JasperReports
    Affects Versions: 2.0.11
            Reporter: Thorsten Schäfer


Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43622#action_43622 ] 

Dave Newton commented on WW-2333:
---------------------------------

I suspect the original implementation was meant as a convenience: rather than creating a collection and forcing the report developer to create the data source from it the source is created automatically. It actually makes writing new reports a bit easier.

I hesitate to just remove this feature as people using the Jasper plugin may be relying on this behavior (I am, anyway). We could add a flag that controls this, I suppose; would that satisfy people?

> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44586#action_44586 ] 

Dave Newton commented on WW-2333:
---------------------------------

I'm not sure what you said there.

All I know is that there have been reports of non-S2 reports failing because of the conversion/wrapping/whatever of action properties that are collections. (And my first S2-only report w/ subreports failed because I didn't know the S2 result type "helped" me by creating it.)

> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Ben Morgan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44585#action_44585 ] 

Ben Morgan commented on WW-2333:
--------------------------------

I'm with you now. I was under the (incorrect) impression, that subreports in standalone reports require a property of type JRDataSource to be passed, rather than the simpler way of wrapping a java.util.Collection with a JRDataSource. My apologies for wasting your time.

I agree with the flag approach.




> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Dave Newton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44584#action_44584 ] 

Dave Newton commented on WW-2333:
---------------------------------

If you attempt to create, say, a JRBeanCollectionDataSource from an iterable action property, the subreport will fail--you must pass the property through as-is, as the plugin will have done the conversion already. This makes reports containing subreports unusable outside of S2. This is a Bad Thing, as people with a large assortment of reports don't want to, and shouldn't have to, go in and modify all their reports (and, in turn, make them unusable outside of S2).

> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Ben Morgan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=44583#action_44583 ] 

Ben Morgan commented on WW-2333:
--------------------------------

As I understand it, to view collections in a standalone iReport, you would need to perform the extra work of creating a JRDataSource implementation as a source for a subreport to view Collection properties of a JavaBean.

A report for Struts2 does not need to do this, as the ValueStackDataSource does the lifting for you by creating a JRDataSource for any Iterable property.

So any report with a subreport on a collection that works for standalone iReport, will also work for Struts2 - the ValueStackDataSource doesn't recognise the JRDataSource property and just passes it through unaffected. The opposite is not true, however, I feel that taking this away, forces Struts2 developers to make reports usable in standalone iReport, where some simply don't need that functionality.

> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Jeff Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43623#action_43623 ] 

Jeff Brown commented on WW-2333:
--------------------------------

Understand the convenience method, but since it does not adhere to the expected Java behavior, reports must be tailored specifically for Struts2 and would not work correctly when run from other frameworks or clients - for example iReport.

A flag is probably the way to go because it needs to be somewhat backwardly compatible no matter what.  I would vote for the default behavior following the expected Java behavior of a Collection returning a Collection and the flag would cause it to return a ValueStackDataSource if desired for convenience.  But, if you feel strongly the other way for seamless backward compatibility, I understand.



> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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


[jira] Commented: (WW-2333) ValueStackDataSource implementation leads to class cast exceptions

Posted by "Jeff Brown (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43620#action_43620 ] 

Jeff Brown commented on WW-2333:
--------------------------------

Certainly breaks anything but the simplest Javabean-based reports.  Any word on when a patch will be available?

> ValueStackDataSource implementation leads to class cast exceptions
> ------------------------------------------------------------------
>
>                 Key: WW-2333
>                 URL: https://issues.apache.org/struts/browse/WW-2333
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - JasperReports
>    Affects Versions: 2.0.11
>            Reporter: Thorsten Schäfer
>             Fix For: Future
>
>
> Assume you have a class Foo that has a Collection of Bar's. Without using Struts, the expected behavior of a report that takes Foo's as input is, that a reference $F{bar} returns a java.util.Collection (of Bar's). However, this will not be the case when using the ValueStackDataSource implementation; an instance of ValueStackDataSource is returned instead of a collection. If the method "getFieldValue" gets called, it checks if the field value is iteratable (which is true for collections) and then returns a new ValueStackDataSource instead of the field value itself. I assume that this behavior breaks many reports.

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