How to select a row from a data table and send me to another page?

0

I have the following table, what I want to do is that when selecting a row, send me to another page to be able to show data according to the person you select in the table,

<h:form>
  <p:dataTable var="consultaPersona" style="max-width:3000px;max-height:770px;" value="#{ConsultaPersonasUnidadFisicaComponent.listNivelesPersona}" emptyMessage="No se encontraron registros." selectionMode="single" selection="#{ConsultaPersonasUnidadFisicaComponent.nivelesPersona}"
    rowKey="#{consultaPersona.persona.cveIdPersona}">

    <p:ajax event="rowSelect" listener="#{ConsultaPersonasUnidadFisicaComponent.mostrarPantallaHorario}" />

    <p:column headerText="No.Empleado">
      <h:outputText value="#{consultaPersona.persona.noEmpleado}" />
    </p:column>

    <p:column headerText="RFC">
      <h:outputText value="#{consultaPersona.persona.rfc}" />
    </p:column>

    <p:column headerText="Nombre">
      <h:outputText value="#{consultaPersona.persona.nombre}" />
    </p:column>

    <p:column headerText="Ubicacion">
      <h:outputText value="#{consultaPersona.unidadAdministrativa.cveIdUnidadAdmin}" />
    </p:column>
    <p:column headerText="Entrada">
      <h:outputText />
    </p:column>
    <p:column headerText="Salida">
      <h:outputText />
    </p:column>
  </p:dataTable>
</h:form>

I already select the rows, and I add a rowselect ajax, which calls the following method, but it does not do anything to me

public String mostrarPantallaHorario(SelectEvent event) {
    return RUTA2;
}

How can I make it so that when I select the row, send me to another page?

    
asked by Root93 26.02.2018 в 18:19
source

2 answers

3

Try doing a redirect programmatically:

public void mostrarPantallaHorario(SelectEvent event) {
    try {
        FacesContext.getCurrentInstance().getExternalContext().redirect(RUTA2);
    } catch (IOException e) {
        //log error?
    }
}
    
answered by 26.02.2018 в 19:02
-1

I was going to tell you to add the onclick event to the tag but I found this page where you can also see more options. link

    
answered by 26.02.2018 в 19:02