Get identifier from current dataTable string for JSF Primefaces Java reference

How can I get the current row id of Row p: dataTable in my link where this id is used? Describe this (sorry for my English). My dataTable looks in this picture:
http://www.image-share.com/igif-2333-105.html
When I click a button, I want to get the identifier of the row where this button is located, for example row 1 has identifier 1, therefore when I press button 1, I should get identifier = 1. Show me what my link looks like, where is the identifier required:
http: // 'serverAddress' / myApplication / PDF? type = document & id = "+ id"
The identifier of the variable is of type int and getters, sets in essence and bean. The button in JSF is as follows:
h: commandButton value = "Print" action = "# {printBean.print ()} "/">
The print method initiates my link. Any ideas how to do this? Thanks for the help.

+4
source share
2 answers

You can use the attribute p:dataTable rowIndexVar.

The name of the iterator to access the index of each row

Whose name of the iterator can be used in EL to get the string identifier

For example: if rowIndexVar="myId", then you can access each row index using this iterator name in EL using #{myID}.

Example:

<p:dataTable rowIndexVar="rowId" value="..." var="...">
    <p:column>
       <h:commandLink action="#{...}">
         <f:param name="id" value="#{rowId}" />
       </h:commandLink>
    </p:column>
</p:dataTable>
+18
source

Get idin bean

map<String,String> par_map = new HashMap<String,String>(); par_map=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

String id=par_map.get("id");
+1
source

All Articles