Page using EntityQuery executes unwanted queries
jivkoto.jivkoto.gmail.com Jan 28, 2009 2:07 PMHi,
Currently I am using Seam 2.0.2.GA. I have used seam-gen to create the base CRUD pages and entities. It creates pages that have form for search and a panel with table. As a backend it creates an EntityQuery instance for each page. snippet bellow:
If I access the page by initial request (by link for example) everything works fine. But I have a problems when I make a post-back - when submitting the form by hitting submit button.
The problem is that I have one or two useless queries instead the one that comes in
#{cdrList.resultList}
Here are two problems that I found.
1. The first is that I have one useless query instead the one in the Render Response phase
. The correct query in the render response t contains the updated values added with the submit.
The unwanted query is executed as executed for the initial request. It does not contain any data from the submit. It seams that this is done after the post back in the RestoreView Phase
of the life cycle when the component model is rebuild, before applying values and running validations.
If you think that my suggestions are correct please, suggest a fix.
2. The second one is that there is a separate requests from a same component for each EntityQuery component. May be it is also camming from the ElValueValidation.
<rich:dataTable id="cdrListTable" var="cdr" value="#{cdrList.resultList}" rendered="#{not empty cdrList.resultList}" >
Here is a snippet from my xhtml file:
<h:form id="cdrSearch"> <rich:simpleTogglePanel label="Call Search parameters" switchType="ajax"> <s:decorate template="layout/display.xhtml"> <ui:define name="label" >gsm</ui:define> <h:inputText id="gsm" value="#{cdrList.gsm}" /> </s:decorate> </rich:simpleTogglePanel> <div class="actionButtons"> <h:commandButton id="search" action="/CdrList.xhtml" value="Search" /> </div> </h:form> <rich:panel id="tablePanel" > <f:facet name="header">Calls search results</f:facet> <h:outputText value="The calls search returned no results" rendered="#{not empty cdrList.resultList}" /> <rich:dataTable id="cdrListTable" var="cdr" value="#{cdrList.resultList}" rendered="#{not empty cdrList.resultList}"> ... <h:column> <f:facet name="header" > <s:link styleClass="columnHeader" value="number" /> </f:facet> #{cdr.destination} </h:column> ... </rich:dataTable> </rich:panel>
Here is a snippet from the EnittyQuery class:
@Name("cdrList") public class CdrList extends EntityQuery<CallDetailRecord> { /** Constant for maximum results */ private static final int MAX_RESULTS = 25; private static final String RESTRICTIONS[] = { "cdr.destination like concat(#{cdrList.gsm}, '%')", }; /** Gsm criteria*/ private String gsm; public CdrList() { setRestrictions(Arrays.asList(RESTRICTIONS)); } /** @see org.jboss.seam.framework.Query#getEjbql() */ @Override public String getEjbql() { return "Select cdr from CallDetailRecord cdr"; } /** @see org.jboss.seam.framework.Query#getMaxResults() */ @Override public Integer getMaxResults() { return MAX_RESULTS; } public String getGsm() { return gsm; } public void setGsm(String gsmArg) { this.gsm = gsmArg; } }