3 Replies Latest reply on Aug 19, 2010 7:44 AM by Leo van den berg

    Factory annotation on List-returning method

    Christian Decker Newbie

      Hi all,


      somehow I'm getting strange results using the @Factory annotation. I have a method returning a List of Entities with the name extracts. Now if I want to use it in a rich:dataTable I get following:


      javax.el.PropertyNotFoundException: /show-project.xhtml @838,32 filterBy="#{extract.id}": The class 'java.lang.String' does not have the property 'id'.
              at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
              at org.richfaces.model.impl.expressive.ValueBindingExpression.evaluate(ValueBindingExpression.java:79)
              at org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapObject(ObjectWrapperFactory.java:209)
              at org.richfaces.model.ModifiableModel$RowKeyWrapperFactory.wrapObject(ModifiableModel.java:75)
              at org.richfaces.model.impl.expressive.ObjectWrapperFactory$2.convert(ObjectWrapperFactory.java:190)
              at org.richfaces.model.impl.expressive.ObjectWrapperFactory.convertList(ObjectWrapperFactory.java:151)
              at org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapList(ObjectWrapperFactory.java:188)
              at org.bfabric.richfaces.extendedDataTable.model.ModifiableModel.filter(ModifiableModel.java:28)
              at org.richfaces.model.ModifiableModel.modify(ModifiableModel.java:240)
              at org.richfaces.component.UIExtendedDataTable.createDataModel(UIExtendedDataTable.java:376)



      Which is interesting since it should take elements of type Entity from the list Outjected into the view. I checked that the @Factory method is called exactly once and that it returns the correct type. If I replace the Outjection by a simple call to the manager it works like a charm, but is then called several times incurring in a huge overhead.


      Any ideas?


      Regards,
      Chris

        • 1. Re: Factory annotation on List-returning method
          Leo van den berg Master

          Hi,


          can you send the piece of code of the Factory and the rich:dataTable part of show-project.xhtml ?


          Leo


          • 2. Re: Factory annotation on List-returning method
            Christian Decker Newbie


                @Factory
                public List<Extract> getExtracts() {
                    if (extractList == null) {
                        extractList = getEntityManager().createQuery("select extract from Extract extract order by id desc").getResultList();
                    }
                    return extractList;
                }



            But I'm sure that it works fine, since when debugging it returns exactly what I expected. The extendedDataTable looks like this:





                          <rich:extendedDataTable
                            id="extractsTable"
                            value="extracts"
                            var="extract"
                            sortMode="single"
                            rows="25"
                            reRender="extractsTableScroller">
                            <rich:column
                              sortable="true"
                              sortBy="#{extract.id}"
                              filterBy="#{extract.id}"
                              filterEvent="onkeyup"
                              label="ID"
                              width="50px">
                              <f:facet name="header">
                                <h:outputText value="ID" />
                              </f:facet>
                              <h:outputText value="#{extract.id}" />
                            </rich:column>
                            <rich:column
                              sortable="true"
                              sortBy="#{extract.name}"
                              filterBy="#{extract.name}"
                              filterEvent="onkeyup"
                              label="Name"
                              width="350px">
                              <f:facet name="header">
                                <h:outputText value="Name" />
                              </f:facet>
                              <s:link
                                view="/userlab/show-extract.xhtml"
                                value="#{extract.name}"
                                propagation="none">
                                <f:param
                                  name="extractId"
                                  value="#{extract.id}" />
                              </s:link>
                            </rich:column>
                          </rich:extendedDataTable>



            If instead of extracts I use #{manager.getExtract()} for the value attribute in the <rich:extendedDataTable/> it all works like a charm.


            Did I miss something?

            • 3. Re: Factory annotation on List-returning method
              Leo van den berg Master

              Hi,


              The errormessage states a String in extract, and that is exactly what is happening. You're not referencing a bean, but a string value.


              You should use the following in you dataTable




              value="#{extracts}"
              



              Leo