- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在 JSP 中使用自定义 TableDecorator 和以下 DisplayTag 表进行外部分页/排序:
<display:table id="ixnlist" name="pageScope.itemList" sort="external"
decorator="org.mdibl.ctd.pwa.displaytag.decorator.IxnTableWrapper">
<display:column title="Row" property="rowNum" />
...more columns...
</display:table>
在表装饰器中,getListIndex() 返回仅与当前页面相关的行号,而不是整个列表(即,如果我们每页显示 100 个对象,则 getListIndex() 返回“0”第 2 页顶部,而不是“100”)。
/**
* Returns the row number data for the current row.
*
* @return String containing row number heading.
*/
public String getRowNum() {
final StringBuilder out = new StringBuilder(8);
out.append(nf.format(getListIndex() + 1))
.append('.');
return out.toString();
}
是否有可能在表格装饰器中以某种方式获得反射(reflect)正确偏移量的行号? Displaytag 知道某处的偏移量,因为它使用它来格式化分页链接。
displaytag 文档没有解决这个问题,${row_rowNum} 隐式对象的工作方式与装饰器中的 getListIndex() 相同。
是的,可以通过向分页 SQL 添加一个行号列并让 TableDecorator 使用它(如果可用)来实现这一点,但我宁愿不依赖 DAO 来获取这种元数据。以下 TableDecorator 方法利用 rownum 列(如果它存在),否则它使用 getListIndex():
/**
* Returns the row number data for the current row.
*
* @return String containing row number heading.
*/
public String getRowNum() {
final StringBuilder out = new StringBuilder(8);
final Map row = (Map) getCurrentRowObject();
// Use 'rnum' column for external pagination if it exists.
// Kludgy way of doing this.
if (row.get("rnum") != null) {
out.append(nf.format(row.get("rnum")));
} else {
out.append(nf.format(getListIndex() + 1));
}
out.append('.');
return out.toString();
}
谢谢。
/mcr
最佳答案
您应该能够通过引用请求中的页码来计算正确的整体索引值。
编写类似这样的代码,您的 TableDecorator
类应该可以工作:
public String getIndex() {
int numItemsPerPage = 100;
int page = Integer.parseInt(getPageContext().getRequest().getParameter("page"));
int index = getListIndex();
return ((page - 1) * numItemsPerPage) + index + 1;
}
关于java - displaytag 外部分页/排序并获取真实行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/965198/
我想从 d-bunchofnumbers-p 更改丑陋的 displayTag (tableid) 参数到一个 URL 友好的。我还想更改排序和页面参数。 这样做是微不足道的吗? 如果是这样,怎么做?
在显示标签中,我使用了分页功能,当我想查看 15 行的列表但显示标签从数据库中获取所有行时。每次当我点击分页号时,它都会从数据库中获取所有行。因此,它会降低应用程序的性能。 我希望在显示标记中看到 1
我想使用显示标签,但不了解官方文档。谁能给我展示其他好的教程? 最佳答案 假设您在谈论 JSP display tag library ,那么他们在their Sourceforge code sit
我希望有人可以帮助我解决 DisplayTag 问题。这是我当前的 java JSP 代码 ?action=viewProduct&id=',
我正在使用 DisplayTag library 1.2 和导出所有链接都导出为文本。如何从导出中删除链接。 最佳答案 您可以在 display:column 标记上将 media 属性设置为“htm
我正在使用 java displaytag 库。即使不存在数据,我也需要在 html 页面中显示标题。如何启用它? 最佳答案 您需要更改属性值 basic.empty.showtable至 true
我不知道是否有这样的问题,但我没有找到我要找的东西。这就是问题所在: 在我的数据库中,我有一个表,其中包含时间戳值(字符串)。 (即1370842140205) 当我在 中获得该值时它显示的内容与
如何使用 DisplayTag(和 Spring MVC)对服务器端进行分页? 我的 Controller 代码如下: @RequestMapping("/cuenta/refreshCombos.d
我正在寻找一个可以插入 Velocity 模板的组件,例如可用于 JSP 的 displaytag?我需要一个具有分页和自动排序功能的表格渲染器。 如果有任何想法,请告诉我。 干杯 最佳答案 使用Ve
我正在尝试设置 的样式获得看起来很棒的东西。 官方演示如下: http://demo.displaytag.org/displaytag-examples-1.2/example-paging.js
我正在使用 Displaytag 框架进行分页和导出。因为我也在使用 Strut2Tiles Integration。 每当我调用任何 Action 类时,它都会返回一个列表并通过 Displayta
我在 formBean 上使用显示表: 当我单击分页表格上的列标题时,我的结果是第一页表格中排序良好的列表。但是当我点击表格的另一页时,排序会丢失。是否有显示标签的配置以保持此排序标准?一切都由显示
我正在尝试修复已有大约 10 年历史的项目。 它是一个 java webapp,曾经在 Tomcat 6 中运行良好。有一小群模块是使用 Java 5 和 Java 6 使用 Ant 和 Maven
我正在使用 displayTag 表装饰器来显示我的 JSP 页面。 该页面有一个包含列的表格。其中一列是“操作”,其中显示了 2 个超链接。一是工资,二是接近。每行将有 5 列操作,最后一列带有超链
我目前正在为 Liferay 开发一个 portlet(使用 Spring MVC 框架)。现在,我只是使用 displaytag 库来实现在 portlet 上显示的列表上的分页。 我现在的问题是,
我已经使用 displaytag 创建了一个表。我想让表标题或列标题固定,并且只有表的正文应该滚动。我能够使包含表的 div 为可滚动的。但是当滚动时,表格的标题也会滚动。它并没有保持固定。我尝试了一
我正在使用带有外部排序和部分列表的 dsiplaytag。当我使用包含数值(持续时间)的特定列对表进行排序时,整个列表在全局范围内是有序的(例如降序),但在每一页上它都是升序的。这是一个例子: Pag
我在需要向其传递参数的显示标签表上指定了一个装饰器。装饰器向行添加一个 id 属性。目前我需要的值是硬编码的。 我需要的参数是: 用作 ID 值的属性名称 id 前缀(通常使用的属性是数字,IE 不喜
我在显示标签为我输出的分页消息时遇到了一个小问题。我通过partialList方法执行分页,但“显示项目X到Y”无法正确显示。 流程如下: 用户执行搜索 查询数据库中匹配记录的数量 根据显示标签页码和
我在 JSP 中使用自定义 TableDecorator 和以下 DisplayTag 表进行外部分页/排序: ...more columns... 在表装饰器中,getListIn
我是一名优秀的程序员,十分优秀!