I need to show a list of auction items. When a user clicks on a Bid button next to each item, I'd like to have ajax open a bid form right under this auction item. So I'm going with a ui:repeat
and a f:ajax
as shown below, but when I go to the page all the auction items have the bid component open next to them. And clicking any of the buttons doesn't do anything. This is the code (with the bid form simplified to just an outputText:
)
<h:form>
<table border="1">
<ui:repeat var="parcel" varStatus="status" value="#{auctionsViewBean.parcels}">
<tr>
<td><h:commandButton value="Bid" action="nothing">
<f:ajax render="bidView"/>
</h:commandButton></td>
<td>#{status.index + 1}</td>
<td>#{parcel.a}</td>
<td>#{parcel.b}</td>
<td>#{parcel.c}</td>
</tr>
<tr><td><h:outputText id="bidView" value="#{auctionsViewBean.showBidViewForParcel(parcel)}">Some text</h:outputText></td></tr>
</ui:repeat>
</table>
</h:form>
What am I doing wrong? And how can I specify only the bid component related to the clicked auction item?