4
votes

I am using Primefaces 3.0 with JSF 2.0. I have a datatable with expansion enabled. I wanted to call a bean method when the user clicks on rowToggler. Basically I wanted to load the expansion details only when the user clicks the expand button. I can't see a server side callback for row expansion in the documentation. Please let me know if I can have any workaround for this problem.

Thanks and Regards, Renju

2
I see this in the issue tracker (URL below). I'm looking forward to this as well. code.google.com/p/primefaces/issues/detail?id=2277 - Howard

2 Answers

6
votes

Following the link Howard provided in the question comment I could see that this was implemented in PF 3.4:

XHTML

<p:ajax event="rowToggle" listener="#{tableBean.onRowToggle}" update=":form:growl" />

Bean

public void onRowToggle(ToggleEvent event) {
    FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO,
                                        "Row State " + event.getVisibility(),
                                        "Model:" + ((Car) event.getData()).getModel());

    FacesContext.getCurrentInstance().addMessage(null, msg);
}

You can see this in the showcase: https://www.primefaces.org/showcase/ui/data/datatable/expansion.xhtml

0
votes

Primefaces' rowToggler already loads content with ajax so you should be fine ;-)

From the manual:

p:rowToggler component places an expand/collapse icon, clicking on a collapsed row loads expanded content with ajax.