0

I have a p:datatable, on select i want to navigate to different page. I was able to do it with <p:ajax event="rowSelect" listener="#{users.onUserSelect(userInformation.id)}"/>

public void onUserSelect(long id) {
    System.out.println("user selected" + id);
    try {
        FacesContext.getCurrentInstance().getExternalContext().redirect("users/user.jsf?id=" + id);
        FacesContext.getCurrentInstance().responseComplete();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

in the resulting page i want to get some data from db using that ID and display it. So, first of all is this approach ok? If so how/where should i get that ID in the resulting page, using request params? or may be there is some other best practice to achieve what i want?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Asiat
  • 401
  • 1
  • 5
  • 14

1 Answers1

0

In result page:

<f:metadata>
        <f:viewParam name="id" value="#{switchController.id}" />
        <f:viewAction action="#{switchController.loadData}"/>
 </f:metadata>