How can i get Id of current Row p:dataTable primefaces to my link where is used this Id? Describe it (sorry for my English). My dataTable looks like on this picture:
http://www.image-share.com/igif-2333-105.html
When i click the button i want to get Id of row where is this button, for example row 1 have id 1, so when button 1 is clicked i must get ID = 1. Show how looks my link where need id:
http://'serverAddress'/myApplication/PDF?type=document&id="+id"
Variable id have type int and getters, setters in entity and bean. Button in JSF looks like below:
h:commandButton value="Print" action="#{printBean.print()}"/>
Method 'Print' initiate my link. Any ideas how to do this? Thanks for help.
You can use p:dataTable
's rowIndexVar
attribute.
Name of the iterator to refer each row index
Whose iterator name can be used in EL to get the Row Id
For Example:
if rowIndexVar="myId"
then you can access each row Index using that 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>
Get id
in bean
map<String,String> par_map = new HashMap<String,String>(); par_map=FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String id=par_map.get("id");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With