p:commandButton action和f:setpropertyactionlistener未在p:columngroup中调用

我需要将子组件放在primefaces子表格页脚中(p:columngroup type =“footer”),但标准子表格渲染器不提供这样的机会。 所以我已经覆盖了org.primefaces.component.SubTableRenderer来添加子渲染:

public class CustomSubTableRenderer extends SubTableRenderer{ @Override protected void encodeColumnFooter(FacesContext context, SubTable table, Column column) throws IOException { ResponseWriter writer = context.getResponseWriter(); String style = column.getStyle(); String styleClass = column.getStyleClass(); styleClass = styleClass == null ? DataTable.COLUMN_FOOTER_CLASS : DataTable.COLUMN_FOOTER_CLASS + " " + styleClass; writer.startElement("td", null); writer.writeAttribute("class", styleClass, null); if(column.getRowspan() != 1) writer.writeAttribute("rowspan", column.getRowspan(), null); if(column.getColspan() != 1) writer.writeAttribute("colspan", column.getColspan(), null); if(style != null) writer.writeAttribute("style", style, null); //encode children for(UIComponent footerColumnChild : column.getChildren()) { if(footerColumnChild.isRendered()) { footerColumnChild.encodeAll(context); } } UIComponent facet = column.getFacet("footer"); String text = column.getFooterText(); if(facet != null) { facet.encodeAll(context); } else if(text != null) { writer.write(text); } writer.endElement("td"); } 

}

当我在p:列组中放入一些子组件时:

 

..

按钮被渲染并且onClick事件调用正常,但是按钮的动作和f:setPropertyActionListener都不会调用。 如何使它们工作?

如果我将p:columnGroup type =“footer”构造更改为p:列标记而不是按钮操作和f:setPropertyActionListener都可以正常工作

PrimeFaces有一个错误,如果它位于标题中,则commandButton或commandLink不会触发动作侦听器( 源 – 请参阅第二个缺陷)。 我有一个预感,你在页脚中遇到了同样的问题。

这在最近的版本中得到了修复,但尚未向公众开放。 如果您想使用PrimeFaces按钮(而不是标准HTML按钮),则必须购买PrimeFaces Elite订阅或从头开始编译源代码。

我可以将setPropertyActionListener放在commandButton中,如下所示:

    
Interesting Posts