2 Replies Latest reply on Jun 23, 2009 12:55 PM by fpsdyl

    Problems with EntityQuery

    dklogica

      Hello guys,


      i have a question regarding the usage of EntityQuery. I'm using a POJO, created by seam-gen, to execute several search queries and to store the results. This POJO extends EntityQuery. The results are displayed by means of a rich data table. I'm using pagination to navigate through the results. The actual problem is, that the EntityQuery POJO will be instantiated again, in the case of clicking a button/link on the page. Due to that, all my search results are gone after clicking a pagination link(e.g. next page). Is there a best practise to avoid this? I suppose the reason for that is the EntityQuery's standard scope EVENT. But i didn't managed to place the EntityQuery in Session Scope, because of Problems with the EntityManager (Conversation - Session).


      Thanx in advance.

        • 1. Re: Problems with EntityQuery
          fpsdyl
          I think if your using richfaces u can add a dataScroller to your data table like this :

          <rich:panel>
            <s:decorate template="../layout/display.xhtml">
              <ui:define name="label">Pojo Search Property</ui:define>
                 <h:inputText id="prop" value="#{pojoQuery.entity.property}">
                     <a4j:support event="onkeyup" reRender="results" />
                 </h:inputText>
            </s:decorate>
          </rich:panel>

          <rich:dataTable id="results" reRender="ds" rows="25" value="#{pojoQuery.resultList}">
            <h:column>
              ....
            <h:column>
            <f:facet name="footer">
              <rich:datascroller id="ds" for="clubEntityList"></rich:datascroller>
            </f:facet>
          </rich:dataTable>

          And then in you Pojo :

          public class PojoQuery extends EntityQuery<Entity> {

             private Entity entity = new Entity();
            
             // create getter+setter for entity property(avoid excessive outjection).
            
             public PojoQuery(){
                   setEjbql( "from Entity e where e.property = " + entity.getProperty() );
             }
          }


          This is currently what I'm using and it works nicely..
          Let me know if you are still having problems..
          • 2. Re: Problems with EntityQuery
            fpsdyl
            Sorry I double-checked my post after I saved it change :

            <rich:datascroller id="ds" for="clubEntityList"></rich:datascroller>

            to :

            <rich:datascroller id="ds" for="results"></rich:datascroller>