本文介绍了cellEditor中的commandLink不会触发action / actionListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Primefaces 3.4和JSF 2.0。我有ap:commandLink:

I'm using Primefaces 3.4 and JSF 2.0. I have a p:commandLink:

<p:commandLink action="#{wizard.onRemoveFoodItem}" update="@(#ingredientListContent)" immediate="true">
    <span class="ui-icon ui-icon-close"></span>
    <f:setPropertyActionListener target="#{wizard.selectedFoodItem}" value="#{foodItem}" />
</p:commandLink> 

它的目的是从我的p:dataTable中的食物清单中删除一行,它工作。问题在于我想在同一位置也有ap:rowEditor,对于那些熟悉primefaces rowEditor的人,在编辑时,你可以看到一个检查和一个x图标(用于结束编辑模式)我不希望有两个关闭图标,其中一个含义取消编辑模式,另一个删除当前行。

It's purpose is to remove a row from a list of food items in my p:dataTable and it works under normal circumstances. The problem lies in the fact that I want to also have a p:rowEditor in the same position, and for those of you that are familiar with primefaces rowEditor, while editing, you can see a check and an x icon (for ending edit mode) and I don't want to have two close icons with one meaning to cancel edit mode and one to remove the current row.

所以我决定将它嵌入到ap中: cellEditor,以便在编辑期间隐藏删除行的x:

So I decided to embed it in a p:cellEditor so that the "x" to remove the row is hidden during editing:

<p:cellEditor>   
    <f:facet name="output">  
        <p:commandLink action="#{wizard.onRemoveFoodItem}" update="@(#ingredientListContent)" immediate="true">
            <span class="ui-icon ui-icon-close"></span>
            <f:setPropertyActionListener target="#{wizard.selectedFoodItem}" value="#{foodItem}" />
        </p:commandLink> 
    </f:facet>  
    <f:facet name="input"><h:outputText value="" /></f:facet>                       
</p:cellEditor> 

这奇怪地发送ajax请求并获得更新响应(没有明显的验证错误),但它不会调用onRemoveFoodItem上的action方法,就像它不在p:cellEditor标记内时那样。我理解p:cellEditor并不是真的意味着以这种方式使用,但我认为在可见时,它会表现得好像没有p:cellEditor包围它。

This strangely sends an ajax request and gets an update response (with no apparent validation error), but it doesn't call the action method onRemoveFoodItem like it did when it wasn't inside an p:cellEditor tag. I understand that p:cellEditor wasn't really meant to be used this way, but I would assume when visible, it would behave as if there were no p:cellEditor surrounding it.

任何人都可以在这里看到任何明显错误或者这是一个问题吗?我将不胜感激任何帮助。

Can anyone see anything obviously wrong here or is this an issue with primefaces? I would be grateful for any help.

推荐答案

我遇到了类似的问题并通过添加 process =解决了这个问题@this属性为 p:commandLink

I’ve got a similar problem and solved it by adding process="@this" attribute to p:commandLink.

这篇关于cellEditor中的commandLink不会触发action / actionListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 03:45