Didn't wanted to bloat the post, but it happens with every dataTable I have, wheter
they use query objects, my own custom beans, or even bean.property of type list, they all
get queryed again for every s:link in every row (of a h:dataTable).
Here's a quick sample, the COMPLETE page list-regions.xhtml:
| <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
| <ui:composition
xmlns="http://www.w3.org/1999/xhtml"
|
xmlns:c="http://java.sun.com/jstl/core"
|
xmlns:ui="http://java.sun.com/jsf/facelets"
|
xmlns:h="http://java.sun.com/jsf/html"
|
xmlns:f="http://java.sun.com/jsf/core"
|
xmlns:s="http://jboss.com/products/seam/taglib"
|
xmlns:a="https://ajax4jsf.dev.java.net/ajax"
| template="/template.xhtml">
|
| <!-- content -->
| <ui:define name="content">
|
| <div class="section">
| <span class="errors">
| <h:messages globalOnly="true"/>
| </span>
| <h1>#{messages.list_regions_label}</h1>
| </div>
|
| <div class="section">
| <h:dataTable id="regions" value="#{regions.resultList}"
var="region" rowClasses="row0,row1" >
| <h:column rendered="#{s:hasRole('Debug')}">
| <f:facet name="header">id</f:facet>
| #{region.id}
| </h:column>
| <h:column>
| <f:facet
name="header">#{messages.region_name_label}</f:facet>
| #{region.name}
| </h:column>
| <h:column>
| <f:facet
name="header">#{messages.region_options_label}</f:facet>
|
| <s:link propagation="none"
view="/register/register-region.xhtml" style="text-decoration:
none">
| <h:graphicImage url="/img/status_bullet/pencil_blue.gif"
onmouseover="return escape('#{messages.region_edit_label}');"
styleClass="icon" />
| <f:param name="selectedRegionId" value="#{region.id}"
/>
| </s:link>
|
| <s:link propagation="join" view="/list/list-employees.xhtml"
>
| <h:graphicImage url="/img/status_bullet/avatars_blue.gif"
onmouseover="return escape('#{messages.view_region_employees}');"
styleClass="icon" />
| <f:param name="selectedRegionId" value="#{region.id}"
/>
| </s:link>
|
| <s:link propagation="join" view="/list/list-complexes.xhtml"
>
| <h:graphicImage url="/img/status_bullet/house_blue.gif"
onmouseover="return escape('#{messages.view_region_complexes}');"
styleClass="icon" />
| <f:param name="selectedRegionId" value="#{region.id}"
/>
| </s:link>
|
| </h:column>
| </h:dataTable>
| </div>
|
| </ui:define>
|
| <!-- sidebar -->
| <ui:define name="sidebar">
| <ui:include src="/menu-simple.xhtml" />
| </ui:define>
|
| </ui:composition>
|
and the actual full entityQuery that does the work (it is the COMPLETE source, that's
all):
| @Name("regions")
| public class RegionList extends EntityQuery {
|
| @Logger Log log ;
|
| @Override
| public String getEjbql() {
| return "SELECT r FROM Region AS r WHERE r.active > 0 ORDER BY r.name "
;
| }
|
| @Override
| public List getResultList() {
| log.debug("fetchin' list") ;
| return super.getResultList() ;
| }
| }
|
there are 16 entries on the database, it prints in the logs:
| DEBUG [RegionList] fetchin' list
| X 49
|
exactly 49 times, one for the table, one for each s:link (16*3+1), if I remove 1, 2, or
the 3 s:links, then it prints 33 (16*2+1), 17 (16+1) and 1 (1 :P) times respectively. So,
it's fetching again for each s:link on the table.
... this HAS to be an error.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061539#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...