0

Each row in the table below represents an Auction. For each Auction there are a number of Offers (so a @ManyToOne relationship between Offers and Auctions).

The blue button means "Add Offer". When the user clicks "Add Offer" I want to open a form (in a new page) that the user fills in order to add an offer to the correspondng auction.

How do I send the current row Auction object to the Add Offer .xhtml form?

In PHP for example I would just send the corresponding Auction ID in the URL (the button would be a link <a href='add_offer?auction_id=123' role='button'>, and then I would use $_GET['auction_id'] to retrieve the corresponding auction's id).

Sorry if my question is stupid, I'm new to JavaEE.

enter image description here

Hello Lili
  • 1,527
  • 1
  • 25
  • 50
  • Are you asking about the mapping? – Sujal Mandal Nov 14 '17 at 09:46
  • @SujalMandal Yes, how do I map a new Offer to a specific Auction (the one on the corresponding row on the table), when I persist a new Offer? – Hello Lili Nov 14 '17 at 09:52
  • 2
    Given your PHP comparison, it sounds like you're more asking about the web framework being used than about JPA. JPA doesn't at all generate HTML code. You normally use e.g. JSF or JSP for this. You should ignore the JPA part and reframe the question to ask how to pass the current row object to the controller when clicking a button in a table. Once you have that answer, the rest you need to do in JPA should speak for itself. – BalusC Nov 14 '17 at 09:57
  • @BalusC thanks for rephrasing, this is exactly what I need! I'll edit the question. – Hello Lili Nov 14 '17 at 10:01

0 Answers0