我们正在从JSF 1.2升级到2.2,我们在升级特立尼达时遇到了障碍。
在 Trinidad 2.2.1 中,自定义提示分面时,数据表的详细信息戳将解析为 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上(。
爪哇岛:
@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>
我是个白痴。特立尼达工作正常。提示分面应位于细节图章分面之外。
<f:facet name="detailStamp">
#{product.id} | #{product.info.name}
</f:facet>
<f:facet name="prompt">
<tr:outputText value="Details" />
</f:facet>