4

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

Renju
  • 51
  • 1
  • 1
  • 6
  • I see this in the issue tracker (URL below). I'm looking forward to this as well. http://code.google.com/p/primefaces/issues/detail?id=2277 – Howard Sep 11 '11 at 02:50

2 Answers2

7

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

jimmybondy
  • 2,092
  • 3
  • 21
  • 33
  • 1
    I am using this approach and it works fine, until the user filters the datatable. Then event.getData() returns invalid data( new Car() object in your case). Any ideas why is this happening? Thanks. – Rahim Mammadli Dec 12 '14 at 12:45
  • A little late, but I had the same problem and in my case the solution was to add the `filteredValue` attribute to the datatable. – burubum Aug 22 '17 at 09:59
0

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.

siebz0r
  • 18,867
  • 14
  • 64
  • 107