我在 p:dataGrid 中有 ap:commandButton(我也尝试过 p:dataTable,p:dataList)
命令按钮操作侦听器方法未执行,但对服务器进行了 ajax 调用。
请注意,dataGrid 是延迟加载的。
请找到示例代码:
<p:dataGrid id="portfolioView" value="#{controller.values}" var="p"
lazy="true" rendered="#{controller.hasValues()}"
style="width: 100%" paginator="true" rows="20" columns="1">
<p:column id="portfolioViewColumn">
<h:panelGroup id="portfolioPanel" layout="block"
style="width: 95%; padding: 20px; margin-bottom: 5px; margin-top: 5px; border-radius: 5px"
styleClass="importantpanel_down_less_spread">
<h:panelGrid columns="3" >
<p:graphicImage value="#{controller.photo}" width="60" height="60"/>
<h:panelGroup layout="block" style="width: 100%" >
<h:outputText value="#{controller.user.name}" style="font-weight: bold; font-size: 12px"/>
<br/>
<h:outputText value="#{p.dateString}"
style="font-weight: bold; font-size: 12px; color: #454545/>
<br/>
<h:outputText value="#{p.portfolioTitle}"
style="font-weight: bold; font-size: 14px; color: #454545"/>
</h:panelGroup>
<h:panelGroup layout="block" >
<h:form>
<p:commandButton icon="ui-icon-trash" id="deletePortfolio" value="Delete" title="Delete this portfolio"
styleClass="fs-button-portfolio" actionListener="#{controller.deleteValue(p)}"/>
<p:commandButton icon="ui-icon-pencil" id="editPortfolio" value="Edit" title="Edit this portfolio"
styleClass="fs-button-portfolio" actionListener="#{controller.editValue(p)}" />
</h:form>
</h:panelGroup>
</h:panelGrid>
</p:column>
<p:dataGrid>
public void deleteValue(Portfolio portfolio) {
try {
System.out.println("Removing portfolio ...");
portfolioFacade.remove(portfolio);
JsfUtil.addSuccessMessage("Portfolio Removed", "You have deleted a portfolio from your timeline");
} catch (Exception e) {
JsfUtil.addErrorMessage("Failure", "Sorry! We have failed to remove this portfolio from your timeline.");
}
}
public void editValue(Portfolio portfolio) {
System.out.println("Preparing portfolio edit...");
this.currentPortfolio = portfolio;
}
我在 glassfish 3.1.2.2、primefaces 3.4、mojarra 上运行
谢谢。