0

I have a list of books which are stored in database. when i click any one record to see the details of that book, it displays all the book details stored in database. Following figures shows more details scenario:

List of books stored in database

Details of all books stored in database

As shown in above figures; when i click the Book Title or Book Title 2, it is display both book details. However, i want only that particular clicked details.

Following is my code where book title is displayed with command link:

<h:column>
    <f:facet name="header">
        <h:outputText value="Title"/>
     </f:facet>
   <h:form>
     <h:commandLink action="#{itemController.doBookDetails}"> <h:outputText value="#{bit.title}"/></h:commandLink>
    </h:form>
</h:column>

Following is the code of method doBookDetails

public String doBookDetails() {

        return "bookDetails.xhtml";
    }

I know problem is in above method because in bookDetails.xhtml there is list which contains the all books record. I have to run query but i dont know how to pass any variable with clicked linked which indicate me which record has been clicked ?

Any help will be appreciated.

RK.
  • 973
  • 5
  • 19
  • 45
  • The problem is in your `bookDetails.xhtml` page and in the managed bean. Looks like in it you're retrieving the data for all your books, which is wrong. You must send the id of the book to retrieve its details and show them in your page. – Luiggi Mendoza May 07 '13 at 16:39
  • Yes, but the problem is how to pass id by clicking the link ? – RK. May 07 '13 at 16:44
  • 1
    Refer to http://stackoverflow.com/q/2456295/1065197 – Luiggi Mendoza May 07 '13 at 16:49

0 Answers0