• Post Reply Bookmark Topic Watch Topic
  • New Topic

a4j:command link in h:datatable refreshed datatable even when not reRendered  RSS feed

 
sambhav maniar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a datatable and been using rich a4j:commandlink for particular column.

<a4j:repeat value="#{EquityAccountMenu.accountList}" id="accountList" var="accounts" rowKeyVar="rowKey">
<a4j:form ajaxSubmit="true" id="accSelForm" >
<a4j:commandLink value="#{rowKey}" action="#{EquityActionHandler.onAccountSelection}" />
</a4j:form>
</a4j:repeat>

now every time I click command link, Constructor for EquityAccountMenu gets called and accountList gets fetched from the database, even if the a4j:repeat is not reRendered by the command link.

EquityAccountMenu is request scope bean

How can I avoid unnecessary calling of accountList?
 
Jennylyn Fernandez
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you clicked the link, <a4j:commandLink> will reload the whole page that's why EquityAccountMenu is being called again. So, instead of putting <a4j:commandLink> inside <a4j:form>, put it inside <a4j:region> instead. After all, <a4j:form> there is useless because links are automatically GET methods.

See <a4j:region> description here:
http://docs.jboss.org/richfaces/latest_3_3_X/en/devguide/html/a4j_region.html.

Therefore, your code should be like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!