• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
reply
    Bookmark Topic Watch Topic
  • New Topic