Primefaces dataTable with embedded commandLink
15,903
This is possible. Your actionListener should be called. Keep in mind that the p:commandButton
uses ajax by default. So you should use the update
attribute in order to define the components to be updated.
However, I don't know if this affects the actionListener. Did you try it with action
instead of 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:
public String selectPatient(Patient p) {
// do something
// return some outcome
}
Author by
c12
Updated on June 04, 2022Comments
-
c12 almost 2 years
I'm trying to embed a Primefaces commandLink and call an action listener from a link inside a column of a Primefaces dataTable. Is this not possible? The "Test" onclick alert gets fired but it never makes it to my bean's method.
<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... }
-
c12 almost 13 yearsI'll give yours a try but I also see this example...primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf