导航到primefaces中数据表rowselect上的另一个页面

Jav*_*ava 4 ajax primefaces jsf-2 liferay-6

我有一个显示记录数量的primefaces数据表.

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

我能找到的最接近的示例/演示是使用p:ajax标记将rowSelect事件绑定到侦听器方法 http://www.primefaces.org/showcase-labs/ui/datatableRowSelectionInstant.jsf

我也有一篇文章 http://forum.primefaces.org/viewtopic.php?f=3&t=14664

,我试着像他们一样实施.但它也没有奏效.

我正在尝试这种方式并指导我如果我错过了什么.

   <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>
Run Code Online (Sandbox Code Playgroud)

而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");

    }

}
Run Code Online (Sandbox Code Playgroud)

那么如何在rowselect事件中导航到另一个页面?以及如何在导航表单后显示其值.

我能够进入onRowSelect()方法,实际问题是他无法获得或理解该路径:

configurableNavigationHandler.performNavigation( "?页面重定向=真");

因此他无法在此行之后打印任何日志.为什么会这样?是因为我正在使用Liferay?

Pla指导我.

Tan*_*enk 9

我认为onRowSelect永远不会被执行,因为你定义错了.

试试这个:

public void onRowSelect(SelectEvent event)
{


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


}
Run Code Online (Sandbox Code Playgroud)