问题描述:

I'm Java developer for about 2 years but I'm new with Jasper so I need some help, I know how to deal with a simple report with fields coming from a class or entity but now I have to do something harder.

I have these 3 entities:

Group

Function

Privilege

The group may have a list of function, and a function has a list oc privileges, that is the simplest scenario but a group may have a list of other groups instead of a list of function.

simple example: Group1 -> (Function1 [Privilege1, Privilege2], Function2 [Privilege3, Privilege4] - Group1 got a list with 2 functions each one with 2 privileges.

complex example: Group2 -> (Group1 -> [Function1 {Privilege1, Privilege2}, Function2 {Privilege3, Privilege4}], Group3 -> [FunctionX {Privilege1, Privilege2}, FunctionY... - Group 2 got a list with 2 sub-groups, each sub-group got functions and so on.

To build the report I'm used to send to Jasper just one object, in this case the parent group so I believe I need a way to iterate through its lists but I don't know what is the best approach.

I made some research about groups and sub reports but I couldn't find any situation like that and I can't figure out what is the best for what I need to do.

Some help would be appreciated!

网友答案:

I'm create jasper report as pass one single object as parameter or field. assume one file structure

com.project.MyClass,we pass object of MyClass this object is pass as parameter or as datasource whatever you want.

assume myClass is object

if you are pass one single object than you must be change expression class java.lung.String to com.project.MyClass in jasper.

now you can access your object in as $F{myClass }.getMethodName()

you can also use use $F{myClass }.getMethodName().getSubmethodName()

this is 100% work. i'm use it for my all reports.if you want any help then ask.

相关阅读:
Top