Reputation: 918
I want to want to update a div with id="contents" when a h:commandButton
is clicked but the complicated part is that h:commandButton is in a c:forEach
so there are multiple h:commandButton
s. I want the div to be refreshed whenever any of the command button is clicked. Is possible using ajax or jquery?
1)
<h:form>
<div id="contents">
<c:forEach var="p" items="#{statusBean.statusList}">
<h:commandButton>Click Me</h:commandButton>
//content
</c:forEach>
</div>
</h:form>
Upvotes: 0
Views: 1785
Reputation: 14277
First of all you button is not an AJAX button at all, so add f:ajax
inside it:
<h:commandButton value="Click Me">
<f:ajax render="@form"/>
</h:commandButton>
Notice that I rendered hole form, as your div is actually only tag inside it. You can't update ordinary HTML tag with JSF. You can change your div to h:panelGroup
but it is not necessary in this example.
Upvotes: 3