0

There are a list with 100 "Favs" on it. It only shows 10 when the page loads. When I click on "Show More Favs" it shows 10 more Favs.

What's weird about it, it's after I click on Show More Favs, clicking on Remove from list, it's not calling the method in the backBean.

My backBean is ViewScoped.

<ui:repeat value="#{bean.list}" var="fav">
 <h:form>
  <h:commandLink styleClass="someStyle" title="Remove from list" action="#{bean.remove(fav.id)}"/>
 </h:form>
</ui:repeat>
<h:form>
 <h:commandButton value="Show More Favs" action="#{bean.showMore}" >
  <f:param name="moreFav" value="10" />
  <f:ajax event="action" render="@all" />
 </h:commandButton>
</h:form>

1 Answer 1

1

The culprit is the usage of multiple forms and the render="@all". If you re-render another form from inside an ajax form, the viewstate of the another form will get lost.

You need to change the code so that only the content of another form is re-rendered:

<h:form id="otherform">
 <h:panelGroup id="list">
  <ui:repeat value="#{bean.list}" var="fav">
   <h:commandLink styleClass="someStyle" title="Remove from list" action="#{bean.remove(fav.id)}"/>
  </ui:repeat>
 </h:panelGroup>
</h:form>
<h:form>
 <h:commandButton value="Show More Favs" action="#{bean.showMore}" >
  <f:param name="moreFav" value="10" />
  <f:ajax event="action" render=":otherform:list" />
 </h:commandButton>
</h:form>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.