This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes JSF and the fly likes a4j:command link in h:datatable refreshed datatable even when not reRendered Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "a4j:command link in h:datatable refreshed datatable even when not reRendered" Watch "a4j:command link in h:datatable refreshed datatable even when not reRendered" New topic
Author

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

sambhav maniar
Greenhorn

Joined: Sep 23, 2009
Posts: 1
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?


Sambhav Maniar
Jennylyn Fernandez
Greenhorn

Joined: Sep 24, 2009
Posts: 2
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:
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: a4j:command link in h:datatable refreshed datatable even when not reRendered
 
Similar Threads
how to create a list of inplaceInput tags from an array in the glue bean
Rich:Datatable rerendering problem
How to identify which commandLink was clicked? [SOLVED]
Problem in creating a search result page
a4j:commandLink + f:param