[英]Primefaces dataTable with embedded commandLink
I'm trying to embed a Primefaces commandLink and call an action listener from a link inside a column of a Primefaces dataTable. 我正在尝试嵌入Primefaces commandLink并从Primefaces dataTable列内的链接调用操作侦听器。 Is this not possible? 这不可能吗? The "Test" onclick alert gets fired but it never makes it to my bean's method. “ Test” onclick警报被触发,但是它从未进入我的bean的方法。
<p:dataTable var="location" value="#{adminBean.locations}">
<p:column headerText="Options">
<p:commandLink value="delete" actionListener="#{admin.deleteLocation}" onclick="alert('test')"/>
</p:column>
</p:dataTable>
bean code: 豆代码:
public void deleteLocation(ActionEvent e){
//delete logic here...
}
This is possible. 这个有可能。 Your actionListener should be called. 您的actionListener应该被调用。 Keep in mind that the p:commandButton
uses ajax by default. 请记住,默认情况下, p:commandButton
使用ajax。 So you should use the update
attribute in order to define the components to be updated. 因此,您应该使用update
属性来定义要更新的组件。
However, I don't know if this affects the actionListener. 但是,我不知道这是否影响actionListener。 Did you try it with action
instead of actionListener
? 您是否尝试过用action
代替actionListener
?
Here is an example how I got it working: 这是我如何使其工作的示例:
<p:commandLink action="#{spc.selectPatient(item)}"
ajax="false"
value="Open"/>
The bean method looks as follows: bean方法如下所示:
public String selectPatient(Patient p) {
// do something
// return some outcome
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.