我们正处于从JSF 1.2升级到2.2的过程中,我们在升级特立尼达时遇到了封锁。
在Trinidad 2.2.1中,当您自定义提示构面时,数据表的detailstamp将解析为null。其他人都知道为什么会这样吗?
这是在Wildfly(10.1.0.Final)上使用Mojarra 2.2.13.SP1,Java 8(1.8.0_131),JSF 2.2和Trinidad 2.2.1(2.2上也存在问题)进行测试的。
Java:
@Named
@RequestScoped
public class ProductBean {
private final AtomicBoolean seeded = new AtomicBoolean(false);
private final List<Product> products = Collections.synchronizedList(new ArrayList<>());
@PostConstruct
public void init() {
if (!seeded.get()) {
products.add(new Product(1, new ProductInfo("product 1", "1")));
products.add(new Product(2, new ProductInfo("product 2", "2")));
products.add(new Product(3, null));
seeded.set(true);
}
}
public List<Product> getProducts() {
return products;
}
public static class Product {
private final int id;
private final ProductInfo info;
public Product(int id, ProductInfo info) {
this.id = id;
this.info = info;
}
public int getId() {
return id;
}
public ProductInfo getInfo() {
return info;
}
}
public static class ProductInfo {
private final String name;
private final String code;
public ProductInfo(String name, String code) {
this.name = name;
this.code = code;
}
public String getName() {
return name;
}
public String getCode() {
return code;
}
}
}
XHTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<tr:document xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:trh="http://myfaces.apache.org/trinidad/html"
xmlns:tr="http://myfaces.apache.org/trinidad"
xmlns:ui="http://java.sun.com/jsf/facelets">
<tr:page>
<tr:form id="mainForm">
<tr:table id="products" value="#{productBean.products}"
var="product">
<tr:column headerText="Id">
<tr:outputText value="#{product.id}"></tr:outputText>
</tr:column>
<tr:column headerText="Naam">
#{product.info.name}
</tr:column>
<f:facet name="detailStamp">
<f:facet name="prompt">
<tr:outputText value="Details" />
</f:facet>
#{product.id} | #{product.info.name}
</f:facet>
</tr:table>
</tr:form>
</tr:page>
</tr:document>
答案 0 :(得分:0)
<f:facet name="detailStamp">
#{product.id} | #{product.info.name}
</f:facet>
<f:facet name="prompt">
<tr:outputText value="Details" />
</f:facet>