onRowSelect(SelectEvent event) Method
public void onRowSelect(SelectEvent event) {
FacesMessage msg = new FacesMessage("Car Selected", ((Car) event.getObject()).getModel());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
I need to know the following:
- When I click on a Row, will this method be called?
- Can I display the rows content using this method?
See: http://c开发者_Go百科ode.google.com/p/primefaces/source/browse/examples/trunk/showcase/src/main/webapp/ui/datatableRowSelectionInstant.xhtml?r=3293
This PrimeFaces Showcase example fully covers these cases:
http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionSingle.jsf
To answer your questions:
- Yes.
- Yes. Set a
car
attribute in your bean inside this method. Make sure getters and setters are available for yourcar
. Display thecar
on your page using an Ajax PPR when the row select event happens.
The code in the showcase example I referenced has all the pieces you need to do this.
精彩评论