2 Replies Latest reply on Dec 13, 2006 9:36 PM by jboss-nth-fan

    Programatic example for Query Objects



      Are there any examples showing programmatic use of Query object. Mainly interested seen the capabilites of the "framework:restrictions" piece.

      I've had a quick overview in the code for the Query class but not evident at least for me.

      I found the comparation for Home Object between programmatic and xml aproach very illustrative.

      Thanks for your assistance.


        • 1. Re: Programatic example for Query Objects

          This may not be what you're looking for, but here's a sample where I'm using an EntityQuery to populate an auto-complete list of names (forgive any syntax errors, I cribbed this from my working code, but changed the names.).

          @In(required = false)
          Person examplePerson;
          @Out(required = false)
          EntityQuery people;
          public void refreshPeople() {
           List<String> restrictions = new ArrayList<String>();
           restrictions.add("lower(name) like lower( #{examplePerson.name} || '%' )");
           people = new EntityQuery();
           people.setEjbql("from Person");

          <h:inputText value="#{examplePerson.name}">
           <a4j:support event="onkeyup" reRender="autocompletePeople" action="#{personHome.refreshPeople}" requestDelay="100" />
          <a4j:outputPanel id="autocompletePeople">
           <ui:repeat value="#{people.resultList}" var="p">
           <h:outputText value="#{p.name}" />

          • 2. Re: Programatic example for Query Objects

            That's perfect!, it does help me. Thanks
            I was just trying to get my head around the concept but I think I got it.

            BTW, it's extremely exciting to see 1.1.GA !

            Congrats Seam guys!