5 Replies Latest reply on May 9, 2007 10:33 AM by pmuir

    framework:entity-query class attribute

    fernando_jmt

      I was using entity-query, now I need to make some extensions to EntityQuery provided by Seam. I assumed that using the class atribute for the framework:entity-query I can define a subclass of the EntityQuery. Is my assumption correct?



      public class MyEntityQuery extends org.jboss.seam.framework.EntityQuery {
      ...some stuff
      }
      


      components.xml

      <framework:entity-query name="userListing" ejbql="select u from User u" auto-create="true" max-results="5" scope="SESSION" class="com.app.MyEntityQuery"/>
      
      


      Above code does not work. It seems that Seam EntityQuery is used even if I declare a class attribute.

      One of the errors I got when adding new properties to the extended EntityQuery:
      Caused by: javax.faces.el.PropertyNotFoundException: /admin/userList.xhtml @130,105 value="#{userListing.currentPage}": Bea
      n: org.jboss.seam.framework.EntityQuery_$$_javassist_1, property: currentPage
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
       at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
       at javax.faces.component.UIInput.getValue(UIInput.java:88)
       at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getValue(RendererUtils.java:278)
       ... 59 more
      



      do I am misunderstanding the use of such class attribute? or is it a bug?

      Any ideas?


        • 1. Re: framework:entity-query class attribute
          pmuir

          Just extend it and use the @Name attribute (just like an EntityHome)

          • 2. Re: framework:entity-query class attribute
            fernando_jmt

            Thanks Pete, for your suggestion, nevertheless that was something I did previously.

            To be specific, in the extended EntityQuery I added some generic (for all lists) methods like the total pages and the current page (among others). These changes should be used for all entity-queries in my app. Now, your suggestion obliges me to create one class for every entity query and annotate it with @Name, and each class will have exactly the same methods. I think this is not a very good solution (a lot of classes only difering the @Name, even if I have a super class I will need to extend it and add a @Name for each one), and this is the reason I ask if the entity-query class attribute can be used for that purpose (to use an extended EntityQuery instead the Seam EntityQuery directly).



            Hope now is more clear than before, and you can point me out.


            Thanks in advance.



            • 3. Re: framework:entity-query class attribute
              pmuir

              Ah, in that case:

              public abstract class MyEntityQuery extends EntityQuery {
              
               // Overridden/extra methods
              }


              <component name="fooQuery" class="MyEntityQuery">
               <property name="maxResults">10</maxResults>
              <component>


              - you loose the namespace stuff in components.xml. You could always set up your own namespace for MyEntityQuery if you like.

              HTH

              • 4. Re: framework:entity-query class attribute
                fernando_jmt

                Thanks Pete.

                I also thought in that solution. But I was afraid to loose the namespace stuff for entity-query. Now, I think this is my only chance (or define my own namespace).

                Only by curiosity. Do you know what is the purpose of the "class" attribute in the <framework:entity-query> stuff? I looked for it in the seam reference, but I cannot find it.

                Thanks.

                • 5. Re: framework:entity-query class attribute
                  pmuir

                  There isn't any afaik.