- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在尝试导出包含某些列的 DataTable 时遇到问题,DataTable 和 Column 组件都是复合元素,如下所示:
自定义数据表 XHTML (v:dataTable):
<cc:interface>
<cc:attribute name="value" required="true" />
<cc:attribute name="selectionMode" default="multiple" />
<cc:attribute name="selectionBean" />
<cc:attribute name="selectionProperty" />
<cc:facet name="header" />
</cc:interface>
<cc:implementation>
<p:dataTable id="teste" var="tableItem" value="#{cc.attrs.value}"
selection="#{cc.attrs.selectionBean[cc.attrs.selectionProperty]}"
rowKey="#{tableItem.id}" rowsPerPageTemplate="15, 30, 45"
paginator="true" rows="15"
emptyMessage="#{messages['dataTable.emptyMessage']}">
<cc:insertChildren />
<f:facet name="footer">
<p:commandButton value="#{messages['dataTable.exportExcel']}"
ajax="false">
<p:dataExporter type="xls" target="teste" fileName="export" />
</p:commandButton>`enter code here`
</f:facet>
</p:dataTable>
</cc:implementation>
自定义列 XHTML (v:dataColumn):
<cc:interface
componentType="com.example.VDataColumn">
<cc:attribute name="value" />
</cc:interface>
<cc:implementation>
<c:choose>
<c:when test="#{cc.childCount gt 0}">
<cc:insertChildren />
</c:when>
<c:otherwise>
<h:outputText value="#{cc.attrs.value}" />
</c:otherwise>
</c:choose>
</cc:implementation>
Column 组件是 org.primefaces.component.column.Column 类的扩展:
package com.example.component;
import javax.faces.component.FacesComponent;
import javax.faces.component.NamingContainer;
import javax.faces.component.UINamingContainer;
import org.primefaces.component.column.Column;
@FacesComponent("com.example.VDataColumn")
public class VDataColumn extends Column implements NamingContainer {
@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
}
DataTable 和 Column 的使用如下:
<v:dataTable
value="#{testController.resultList}"
selectionBean="#{testController}"
selectionProperty="selectedList" selectionMode="multiple">
<p:column value="#{tableItem.id}" headerText="ID" />
<v:dataColumn value="#{tableItem.code}" headerText="Code" />
<v:dataColumn value="#{tableItem.nome}" headerText="Name" />
<v:dataColumn value="#{tableItem.desc}" headerText="Desc" />
</v:dataTable>
当我尝试使用组件内部的 dataExporter 导出 dataTable 时,我在 XLS 文件中只得到一列,而且它只是 p:column。
调试 primefaces DataExporter 类,我注意到 DataTable 对象在 getChildren() 方法中包含 4 个对象,一个 Column 和 3 个 VDataColumn,只有 Column 对象包含子对象本身。
有人遇到同样的问题吗?我正在使用 Primefaces 4.0
最佳答案
我在使用自定义组件时遇到了同样的问题。我们通过扩展导出器并对组件使用自定义验证来解决。
if (component instanceof UINamingContainer) {
UINamingContainer uiNamingContainer = (UINamingContainer) component;
UIComponent panel = uiNamingContainer.getFacet(UIComponent.COMPOSITE_FACET_NAME);
Collection<UIComponent> children = panel.getChildren();
for (UIComponent uiComponent : children) {
if (uiComponent instanceof javax.faces.component.html.HtmlOutputText) {
try {
uiNamingContainer.encodeBegin(context);
return super.exportValue(context, uiComponent);
} catch (IOException e) {
LOGGER.error(e);
} finally {
try {
uiNamingContainer.encodeEnd(context);
} catch (IOException e) {
LOGGER.error(e);
}
}
}
}
}
关于jsf-2 - p :Column composite element wont export in p:DataExporter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20292709/
我正在开始开发一个使用 JSF 2 作为 View 技术的新 Web 应用程序。 我之前没有使用 JSF 的经验,对这些概念有点困惑。 我阅读了一些关于 JSF 的文档,主要思想是它是一个基于组件的框
我试图找出这是一个 JSF/EL 问题还是这里出了什么问题。 基本上,我想将项目对象作为 ui:param 传递给 ui:composition 并在里面有一个按钮(即引导按钮,因此它们实际上是 ht
我是 GWT 的新手,正在尝试制作一个简单的应用程序(例如 fmylife 的小型版本)。到目前为止,我制作了一个加载事实的复合 Material 和另一个具有提交新事实的表单的复合 Material
我对 Agda 很陌生,我正在尝试做一个简单的证明“ map 的组合就是组合的 map ”。 (来自 this course 的练习) 相关定义: _=$=_ : {X Y : Set}{f f' :
我有三个组合(compFinal、compSlide1 和 compSlide2)。 我已经使用脚本将 compSlide1 和 compSlide2 添加到 compFinal 组合中。 我使用以下
我有以下情况: #{cc.attrs.someValue} 因此,在我的复合组件中,我正在调用其他一些复合组件,并尝试将提供给“主”复合组件的参数
我正在尝试使用 Constraint composition并希望为每个复合约束定义组,如下例所示:- 复合约束 @Target({ ElementType.FIELD, Elemen
尝试使用 Jetpack Compose 显示 AlertDialog,但应用程序在调用 AlertDialog 函数时崩溃,错误为 java.lang.IllegalStateException:
我想根据按钮的可见性属性重绘组合中的按钮。我根据其中的按钮进行合成以调整大小,并且我正在使用以下代码来刷新合成。问题:下面的代码工作正常,但按钮从未在复合中重新定位请帮忙。代码中是否缺少要重新定位的内
我正在研究 After Effects 脚本并使用 AE 脚本指南作为学习基础。 我有一个 After Effect 项目,其中包含两个 AE 项目,并且每个项目中都有多个项目。 我想从具有特定名称的
我一直在学习如何在 python 编程中实现组合,但我很难理解为什么它比继承更受欢迎。 例如,这是迄今为止我的代码: class Particle: # Constructor (public)
概述 是一种结构型模式,将对象以树形结构组织起来,以表示“部分 - 整体”的层次结构,使得客户端对单个对象和组合对象的使用具有唯一性。 UML类图 上面的类图包含的角色: Compone
我们已经尝试去定义类。定义类,就是新建了一种类型(type)。有了类,我们接着构造相应类型的对象。更进一步,每个类型还应该有一个清晰的接口(interface),供用户使用。 我们可以在一个新类的
一、Options API的弊端 Options api的一大特点就是在对应得属性中编写对应的模块。比如data定义数据、methods中定义方法、computed中定义计算属性、watch中监听属性
我正在使用 SWT ScrolledComposite,但是当我在 Windows 中滚动时,如果我快速滚动,我会出现一些撕裂/闪烁。我该怎么做才能加倍缓冲或减少这种影响,或者我该怎么做才能覆盖默认滚
在 JSP 和 JSTL 中我通常会做这样的事情: ${user.name} ${user.description}
几周以来,我们的 Web 应用程序出现了性能问题。首先我们认为问题属于大 DOM。大 DOM 并不是很好,但这不是主要的性能问题。 问题在于复合组件。过去几周,我们开发了核心复合组件,以减少代码冗余并
如何在 mySQL 中创建复合主键。在 table1 中,我需要将 id1、id2 设置为复合主键。我使用了这个查询。但它使每个成为主键。它检查每个条目的重复项 ALTER TABLE `table1
我是 Java 的新手,我想将背景图像添加到 Composite。我只能使用 SWT,不能使用 JFace。我正在使用 eclipse indigo IDE (3.8),当我想设置背景图像时,首先我将
我有一个程序必须使用复合键来管理对象。这个键,简单来说就是几个字符串。 我有以下代码: public struct MyKey { public string Part1 { get; set
我是一名优秀的程序员,十分优秀!