Redeem selected input values in the Datatable of the first faces

Asked

Viewed 777 times

1

datatable I tried to use ajax and the option f:attribute, but I cannot redeem the required values, that is, the selected line and the value of the input. I’d like some help. Thank you.

  • 5

    Could include the code of the button that performs action?

1 answer

1

Just create an attribute in your Bean of the type:

Lista<SeuObjeto> selecionados;

Define in your datatable that it can be selected by informing the Selection attribute, pointing to the property that Voce set just above and rowKey, follow an example:

    <h:form>
     <p:dataTable var="selecionado" value="#{seuBean.suaListaObjetos}" 
      selection="#{seuBean.selecionados}" rowKey="#{selecionado.id}" >

      <p:ajax event="rowSelectCheckbox" update="@form" />
      <p:ajax event="rowUnselectCheckbox" update="@form" />
      <p:ajax event="rowSelect" update="@form" />
      <p:ajax event="rowUnselect" update="@form" />
      <p:ajax event="toggleSelect" update="@form" />
      <p:column selectionMode="multiple"/>

      conteudo do dataTable...........

    </p:dataTable>

   </h:form>

Remembering that he has to be inside a tag <h:form></h:form>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.