Go to another page in rowselect of datatable in perffaces

I have a chart file where the number of records is displayed.

I want navigate to another page on the rowSelect event (to edit the selected entity for example).

The closest sample / demo I could find is to use the p: ajax tag to bind the rowSelect event to the listening method http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionInstant.jsf

I also got one article for the same http://forum.primefaces.org/viewtopic.php?f=3&t=14664

I tried to implement the same as them. But that also didn't work.

I try this way and guide me if I missed something.

   <p:dataTable var="product" value="#{addPatientBB.patientAddList}" paginator="true" rows="10" 
             selection="#{addPatientBB.pat}" selectionMode="single"> 

    <p:ajax event="rowSelect" listener="#{addPatientBB.onRowSelect}" />  



        <p:column>  
            <f:facet name="header">  
                <h:outputText value="FirstName" />  
            </f:facet>  
            <h:outputText value="#{product.firstName}" />  
        </p:column>  

          <p:column>  

            <f:facet name="header">  
                <h:outputText value="Email" />  
            </f:facet>  
          <h:outputText value="#{product.email}" />    

           </p:column>  


        <p:column>  
            <f:facet name="header">  
                <h:outputText value="Gender" />  
            </f:facet>  
          <h:outputText value="#{product.gender}" />    

           </p:column> 

     </p:dataTable>

And Backing bean:

@ManagedBean
@ViewScoped
public class AddPatientBB implements Serializable
{
    private Patient pat;

    public Patient getPat()
    {
    System.out.println("tried to get pat");
    return pat;
    }

    public void setPat(Patient pat)
    {
    this.pat = pat;
    System.out.println("tried to set pat");
    }

    public void onRowSelect()
    {
    System.out.println("inside onRow select  Method");
    ConfigurableNavigationHandler configurableNavigationHandler = (ConfigurableNavigationHandler) FacesContext.getCurrentInstance().getApplication().getNavigationHandler();

    System.out.println("navigation objt created");

    configurableNavigationHandler.performNavigation("Page?faces-redirect=true");

    // Page is my navigation page where I wish to navigate named as
    // "Page.xhtml"

    System.out.println("Navigation executed");

    }

}

So how can I go to another page in a rowselect event? and how to display its values ​​after navigating the form.

onRowSelect(), , :

configurableNavigationHandler.performNavigation( " = " );

- . ? - , Liferay?

.

+3
2

, , onRowSelect , .

:

public void onRowSelect(SelectEvent event)
{


  FacesContext.getCurrentInstance().getExternalContext().redirect("page.xhtml?id=" +pat.getId());


}
+8

u FacesServlet, use.jsf .xhtml

public void onRowSelect(SelectEvent event)
{
  FacesContext.getCurrentInstance().getExternalContext().redirect("page.jsf?id="+pat.getId());
}
-3

All Articles