Passing parameters between subreports

0

Hi,

Is there any workaround to pass parameters between subreports?. Subreports are in a main report detail section.I can do this if it is in Last page footer or summary, not working if it is placed in any other section.

Any help will be really crossing one more milestone in iReport design.

Regards
Suresh

Attachments: 
sureshk's picture
Joined: Jul 23 2006 - 3:31pm
Last seen: 13 years 4 months ago

6 Answers:

0
I also have a Subreport in detail Area, and I am able to get return Values from the Subreport, but it seems impossible to give the Subreport return Value to a Subreport as parameter.
Is it possible to pass Values between Subreports?
JulEgner's picture
Joined: Aug 3 2006 - 10:59pm
Last seen: 13 years 4 months ago
0
I also have a Subreport in detail Area, and I am able to get return Values from the Subreport, but it seems impossible to give the Subreport return Value to a Subreport as parameter.
Is it possible to pass Values between Subreports?
JulEgner's picture
Joined: Aug 3 2006 - 10:59pm
Last seen: 13 years 4 months ago
0
If both the subreports are placed on the same band, straightforwardly passing a value returned from one of the subreport to the second one would not work because the value is not yet returned at the time the parameter value expressions are evaluated.

There are (at least) two ways to work around this (I assume that the second subreport is placed under the first one):
  • Introduce a dummy group which breaks at each row and place the second subreport in the group's footer. This ensures that the parameter values for the second subreport are evaluated after the first subreport returned the value.

  • Don't use the standard mechanism for returning values from subreports, use a value holder subreport parameter instead. The first subreport would use a dummy expression to save the value in the holder and the second one would retrieve it from the holder.
  • [/ol]

    HTH,
    Lucian
    lucianc's picture
    7154
    Joined: Jul 17 2006 - 1:10am
    Last seen: 9 hours 38 min ago
    0
    I understand the first solution, but not the second one. Could you describe what you mean with a holder?

    i cannot use the first solution (and maybe not even the second) because I have only one Subreport in the Detail Band, that gives a return value back.
    I want to take a value from the subreport and give it to the (same) subreport in the "next" detail value.
    I want to use this to start calculating values in the Subreport from a startpoint I know from the last Subreport. I want to use this for faster Report generation.
    JulEgner's picture
    Joined: Aug 3 2006 - 10:59pm
    Last seen: 13 years 4 months ago
    0
    If you want to pass the value returned from a subreport to the same subreport in the next detail row, the straightforward approach should work. Be careful to set calculation="System" and not to set resetType="None" for the variable in the master report. See the attached sample.

    By a holder I meant an object which can store a value, something like
    Code:
    <br />
    class Holder {<br />
      Object value;<br />
      void setValue(Object value);<br />
      Object getValue();<br />
    }<br />
    </td></tr></tbody></table><br />
    <br />
    You could have a variable of this type in the master, pass it to the subreport as a parameter and, in the subreport (using a scriptlet or a dummy expression), store a value in the holder.  The same holder would be passed to the second subreport which would retrieve the value from it.<br />
    <br />
    HTH,<br />
    Lucian [file name=subrep.zip size=1261]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/subrep.zip[/file]
    lucianc's picture
    7154
    Joined: Jul 17 2006 - 1:10am
    Last seen: 9 hours 38 min ago
    0
    Thats working! I set calculation=system and resettype=report (Variables in master report), and now I get the variable from the subreport to the mainreport and back to the subreport in the next row. Thank you.
    JulEgner's picture
    Joined: Aug 3 2006 - 10:59pm
    Last seen: 13 years 4 months ago
    Feedback
    randomness