首页 \ 问答 \ 贾斯珀报告:如何编译子报表(Jasper Reports: How to compile subreports)

贾斯珀报告:如何编译子报表(Jasper Reports: How to compile subreports)

我有一个独立的应用程序,其职责之一是采取* .jrxml文件的路径并编译它。

直到带有子报表的报表出现,其中主表的编译没有编译它的任何子项,导致子报表* .jasper文件在跟踪后面找不到,我可以毫无问题地做到这一点。

有什么办法可以

1)设置JasperCompileManager自动获取子报表?

2)获取包含在JasperDesign或JasperReport对象中的子报表的路径列表?

我无法直接访问jrxml文件,因此修改报告以适应编译方法不是一种选择,也不适用任何标准命名方案来推断哪些子报告属于哪些报告。

这里有一个类似的问题:

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=40683

使用JRVisitor生成JRSubreport对象列表,但是没有解释如何使用它来获取子报表的路径,以便编译它并递归查找子报表的子报表,我无法弄清楚。


I have a standalone application, and one of its duties is to take the path of a *.jrxml file and compile it.

I can do this without problem until a report with a subreport comes up, where the compilation of the master does not compile any of its children, resulting in a subreport *.jasper file not found later down the track.

Is there any way to

1) Set the JasperCompileManager to automatically pick up subreports?

2) Get a list of paths to subreports contained within either a JasperDesign or JasperReport object?

I have no direct access to the jrxml files, so modifying the reports to suit the compile method is not an option, nor is applying any standard naming scheme to infer which subreports belong to which reports.

There is a similar problem here:

http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=40683

where a JRVisitor is used to produce a list of JRSubreport objects, however there is no explanation of how to use this to get a path to the subreport in order to compile it and recursively look for subreports of subreports, and I cant figure it out.


原文:https://stackoverflow.com/questions/10004800
更新时间:2021-09-26 07:09

最满意答案

使用change事件而不是click 。 也可以使用toggleClass而不是首先检查元素是否具有使用hasClass的类,然后添加/删除它。

演示

$("fieldset.radio label").change(function() {
  $("fieldset.radio label").removeClass("radioselect");
  $(this).addClass("radioselect");
});

$("fieldset.check label").change(function(e) {
  $(this).toggleClass("checkselect");
});
body,
a {
  background-color: #000;
  color: #fff;
}
div.fieldrow {
  clear: both;
  overflow: hidden;
  margin: 0 0 15px 0;
}
div.fieldrow > label {
  cursor: pointer;
}
div.fieldrow > label {
  width: 50%;
  float: left;
  padding-right: 15px;
  text-align: right;
  line-height: 10px;
}
form div.fieldrow > div,
form div.fieldrow > fieldset > div {
  float: right;
  margin-left: 1%;
}
fieldset {
  border: 0;
  padding: 5px 0 0 0;
}
div.fieldrow > fieldset label {
  line-height: 1.7;
}
input {
  border: 1px solid #3f6e74;
  background: rgba(3, 32, 38, 0.5);
}
fieldset input[type=checkbox],
fieldset input[type=radio] {
  position: absolute;
  left: -9999px;
}
fieldset label {
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  display: block;
  font-weight: normal;
  line-height: 1.5;
  margin-bottom: 0;
}
fieldset > div > div > label > input {
  float: left;
  margin-top: 6px;
}
fieldset > div > div > label > span {
  display: block;
  margin: 0 0 0 30px;
  position: relative;
  top: -2px;
}
fieldset > div > div {
  position: relative;
}
fieldset > div > div > label:before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  position: absolute;
  left: 2px;
  top: 3px;
  background-color: #032026;
  border: 1px solid #76cddb;
}
fieldset.radio label:before {
  border-radius: 8px;
}
fieldset.radio > div > div > label.radioselect:before {
  background-color: #76CDDB;
}
fieldset.check > div > div > label.checkselect:before {
  content: "\2713";
  font-size: 28px;
  color: #76CDDB;
  text-align: center;
  line-height: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div>Radio works:</div>
<div class="fieldrow">
  <fieldset class="radio">
    <div>
      <div>
        <label>
          <input type="radio" value="1"> <span>Here is option one</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="2"> <span>Here is option two</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="3"> <span>Here is option three</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>
<div>Checks do not:</div>
<div class="fieldrow">
  <fieldset class="check">
    <div>
      <div>
        <label>
          <input type="checkbox" value=""> <span>I have read the <a href="#">terms &amp; conditions</a>.</span>

        </label>
      </div>
      <div>
        <label>
          <input type="checkbox" value=""> <span>I want to receive cool news and promotions.</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>


如果您可以更改HTML结构,则根本不需要JS复选框。

  1. 将复选框元素移出label
  2. 将id添加到复选框,并将属性值添加到相应的label
  3. 使用:checked属性和相邻的兄弟CSS选择器为选中的复选框设置样式

$("fieldset.radio label").change(function() {
  $("fieldset.radio label").removeClass("radioselect");
  $(this).addClass("radioselect");
});
body,
a {
  background-color: #000;
  color: #fff;
}
div.fieldrow {
  clear: both;
  overflow: hidden;
  margin: 0 0 15px 0;
}
div.fieldrow > label {
  cursor: pointer;
}
div.fieldrow > label {
  width: 50%;
  float: left;
  padding-right: 15px;
  text-align: right;
  line-height: 10px;
}
form div.fieldrow > div,
form div.fieldrow > fieldset > div {
  float: right;
  margin-left: 1%;
}
fieldset {
  border: 0;
  padding: 5px 0 0 0;
}
div.fieldrow > fieldset label {
  line-height: 1.7;
}
input {
  border: 1px solid #3f6e74;
  background: rgba(3, 32, 38, 0.5);
}
fieldset input[type=checkbox],
fieldset input[type=radio] {
  position: absolute;
  left: -9999px;
}
fieldset label {
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  display: block;
  font-weight: normal;
  line-height: 1.5;
  margin-bottom: 0;
}
fieldset > div > div > label > input {
  float: left;
  margin-top: 6px;
}
fieldset > div > div > label > span {
  display: block;
  margin: 0 0 0 30px;
  position: relative;
  top: -2px;
}
fieldset > div > div {
  position: relative;
}
fieldset > div > div > label:before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  position: absolute;
  left: 2px;
  top: 3px;
  background-color: #032026;
  border: 1px solid #76cddb;
}
fieldset.radio label:before {
  border-radius: 8px;
}
fieldset.radio > div > div > label.radioselect:before {
  background-color: #76CDDB;
}
fieldset.check > div > div >:checked + label:before {
  /* Use :checked and adjacent sibling properties here*/
  content: "\2713";
  font-size: 28px;
  color: #76CDDB;
  text-align: center;
  line-height: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div>Radio works:</div>
<div class="fieldrow">
  <fieldset class="radio">
    <div>
      <div>
        <label>
          <input type="radio" value="1"> <span>Here is option one</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="2"> <span>Here is option two</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="3"> <span>Here is option three</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>
<div>Checks do not:</div>
<div class="fieldrow">
  <fieldset class="check">
    <div>
      <div>
        <input id="1c" type="checkbox" value="">
        <!-- Move it out of label -->
        <label for="1c">
          <!-- Add for with the corresponding checkbox id -->
          <span>I have read the <a href="#">terms &amp; conditions</a>.</span>
        </label>
      </div>
      <div>
        <input id="2c" type="checkbox" value="">
        <!-- Move it out of label -->
        <label for="2c">
          <!-- Add for with the corresponding checkbox id -->
          <span>I want to receive cool news and promotions.</span>
        </label>
      </div>
    </div>
  </fieldset>
</div>


Use change event instead of click. Also use toggleClass instead of first checking if the element have a class using hasClass and then adding/removing it.

Demo

$("fieldset.radio label").change(function() {
  $("fieldset.radio label").removeClass("radioselect");
  $(this).addClass("radioselect");
});

$("fieldset.check label").change(function(e) {
  $(this).toggleClass("checkselect");
});
body,
a {
  background-color: #000;
  color: #fff;
}
div.fieldrow {
  clear: both;
  overflow: hidden;
  margin: 0 0 15px 0;
}
div.fieldrow > label {
  cursor: pointer;
}
div.fieldrow > label {
  width: 50%;
  float: left;
  padding-right: 15px;
  text-align: right;
  line-height: 10px;
}
form div.fieldrow > div,
form div.fieldrow > fieldset > div {
  float: right;
  margin-left: 1%;
}
fieldset {
  border: 0;
  padding: 5px 0 0 0;
}
div.fieldrow > fieldset label {
  line-height: 1.7;
}
input {
  border: 1px solid #3f6e74;
  background: rgba(3, 32, 38, 0.5);
}
fieldset input[type=checkbox],
fieldset input[type=radio] {
  position: absolute;
  left: -9999px;
}
fieldset label {
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  display: block;
  font-weight: normal;
  line-height: 1.5;
  margin-bottom: 0;
}
fieldset > div > div > label > input {
  float: left;
  margin-top: 6px;
}
fieldset > div > div > label > span {
  display: block;
  margin: 0 0 0 30px;
  position: relative;
  top: -2px;
}
fieldset > div > div {
  position: relative;
}
fieldset > div > div > label:before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  position: absolute;
  left: 2px;
  top: 3px;
  background-color: #032026;
  border: 1px solid #76cddb;
}
fieldset.radio label:before {
  border-radius: 8px;
}
fieldset.radio > div > div > label.radioselect:before {
  background-color: #76CDDB;
}
fieldset.check > div > div > label.checkselect:before {
  content: "\2713";
  font-size: 28px;
  color: #76CDDB;
  text-align: center;
  line-height: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div>Radio works:</div>
<div class="fieldrow">
  <fieldset class="radio">
    <div>
      <div>
        <label>
          <input type="radio" value="1"> <span>Here is option one</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="2"> <span>Here is option two</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="3"> <span>Here is option three</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>
<div>Checks do not:</div>
<div class="fieldrow">
  <fieldset class="check">
    <div>
      <div>
        <label>
          <input type="checkbox" value=""> <span>I have read the <a href="#">terms &amp; conditions</a>.</span>

        </label>
      </div>
      <div>
        <label>
          <input type="checkbox" value=""> <span>I want to receive cool news and promotions.</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>


If you can change the HTML structure, you don't need JS at all for checkbox.

  1. Move the checkbox element out of the label
  2. Add id to the checkbox and same as for attribute value to the corresponding label
  3. Use :checked property and adjacent sibling CSS selector to set styles for the checked checkbox

$("fieldset.radio label").change(function() {
  $("fieldset.radio label").removeClass("radioselect");
  $(this).addClass("radioselect");
});
body,
a {
  background-color: #000;
  color: #fff;
}
div.fieldrow {
  clear: both;
  overflow: hidden;
  margin: 0 0 15px 0;
}
div.fieldrow > label {
  cursor: pointer;
}
div.fieldrow > label {
  width: 50%;
  float: left;
  padding-right: 15px;
  text-align: right;
  line-height: 10px;
}
form div.fieldrow > div,
form div.fieldrow > fieldset > div {
  float: right;
  margin-left: 1%;
}
fieldset {
  border: 0;
  padding: 5px 0 0 0;
}
div.fieldrow > fieldset label {
  line-height: 1.7;
}
input {
  border: 1px solid #3f6e74;
  background: rgba(3, 32, 38, 0.5);
}
fieldset input[type=checkbox],
fieldset input[type=radio] {
  position: absolute;
  left: -9999px;
}
fieldset label {
  font-size: 1rem;
  color: #fff;
  cursor: pointer;
  display: block;
  font-weight: normal;
  line-height: 1.5;
  margin-bottom: 0;
}
fieldset > div > div > label > input {
  float: left;
  margin-top: 6px;
}
fieldset > div > div > label > span {
  display: block;
  margin: 0 0 0 30px;
  position: relative;
  top: -2px;
}
fieldset > div > div {
  position: relative;
}
fieldset > div > div > label:before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  position: absolute;
  left: 2px;
  top: 3px;
  background-color: #032026;
  border: 1px solid #76cddb;
}
fieldset.radio label:before {
  border-radius: 8px;
}
fieldset.radio > div > div > label.radioselect:before {
  background-color: #76CDDB;
}
fieldset.check > div > div >:checked + label:before {
  /* Use :checked and adjacent sibling properties here*/
  content: "\2713";
  font-size: 28px;
  color: #76CDDB;
  text-align: center;
  line-height: 8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<div>Radio works:</div>
<div class="fieldrow">
  <fieldset class="radio">
    <div>
      <div>
        <label>
          <input type="radio" value="1"> <span>Here is option one</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="2"> <span>Here is option two</span>

        </label>
      </div>
      <div>
        <label>
          <input type="radio" value="3"> <span>Here is option three</span>

        </label>
      </div>
    </div>
  </fieldset>
</div>
<div>Checks do not:</div>
<div class="fieldrow">
  <fieldset class="check">
    <div>
      <div>
        <input id="1c" type="checkbox" value="">
        <!-- Move it out of label -->
        <label for="1c">
          <!-- Add for with the corresponding checkbox id -->
          <span>I have read the <a href="#">terms &amp; conditions</a>.</span>
        </label>
      </div>
      <div>
        <input id="2c" type="checkbox" value="">
        <!-- Move it out of label -->
        <label for="2c">
          <!-- Add for with the corresponding checkbox id -->
          <span>I want to receive cool news and promotions.</span>
        </label>
      </div>
    </div>
  </fieldset>
</div>

相关问答

更多

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)