p:commandButton action和f:setpropertyactionlistener未在p:columngroup中调用 [英] p:commandButton action and f:setpropertyactionlistener not invoked in p:columngroup
问题描述
我需要将子组件放置在字母子页脚(p:columngroup type =footer)中,但标准子表单渲染器不提供此类机会。所以我已经覆盖了org.primefaces.component.SubTableRenderer来添加子渲染:
I need to put child components in primefaces subtable footer (p:columngroup type="footer"), but standard subtable renderer doesn't provide such opportunity. So I have overrided org.primefaces.component.SubTableRenderer to add children rendering:
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:列组中,如:
When I put some child components in p:column group like:
<p:dataTable>
<p:subTable>
<p:column>..</p:column>
<p:columnGroup type="footer"> <p:row> <p:column colspan="3">
<p:commandButton id="button"
action="#{myBean.someAction}"
oncomplete="jQuery('#select').modal('show');return false;"
value="#{val.add}" alt="#{val.add}"
title="#{val.add}"> </p:commandButton>
<f:setPropertyActionListener value="#{otherBean.id}"
target="#{anotherBean.selectedBackId}" /></p:column> </p:row>
</p:columnGroup> </p:subTable>
</p:dataTable>
按钮被渲染,onClick事件调用正常,但是按钮的动作也没有f:setPropertyActionListener不会调用。如何使它们工作?
Button is rendered and onClick event invokes fine, but neither button's action nor f:setPropertyActionListener don't invokes. How to make them work?
如果我更改p:columnGroup type =footer结构到p:列标签比按钮动作和f:setPropertyActionListener都工作正常p>
if I change p:columnGroup type="footer" construction to p:column tag than button action and f:setPropertyActionListener both work fine
推荐答案
PrimeFaces有一个错误,其中commandButton或commandLink不会触发动作侦听器,如果它位于头部(源 - 见第二个缺陷)。我有一个希望,你在页脚中遇到了同样的问题。
PrimeFaces has a bug wherein a commandButton or commandLink doesn't fire the action listener if it is located in the header (source - see second defect). I have a hunch you've encountered the same problem in the footer.
这是在最近的版本中修复的,但还没有公开。如果您想使用PrimeFaces按钮(而不是标准的HTML按钮),则必须购买PrimeFaces Elite订阅或从头开始编译源代码。
This was fixed in a recent release, but it's not yet available to the public. If you want to use a PrimeFaces button (rather than a standard HTML button), you will have to buy a PrimeFaces Elite subscription or compile the source from scratch.
这篇关于p:commandButton action和f:setpropertyactionlistener未在p:columngroup中调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!