Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Empty fetch Criteria custom datasource

    GWT v2.5
    SmartGWT 3.1d EE, (v8.3p_2012-12-28Enterprise Isomorphic-SmartClient-Package-Date: 2012-12-28)
    Browser: IE9
    Environment: Eclipse Indigo
    Java 1.6

    Please be patient with me on this. It reeks of fresh noob.

    I'm pulling a string and two dates from a drop down and two date fields and putting them into a Criteria which I send with the grid fetch. In the custom datasource the criteria map is empty. Please set me straight.

    Client Side
    Code:
    Criteria criteria = new Criteria();
    		criteria.addCriteria("startDate", this.startDate.getValueAsDate());
    		criteria.addCriteria("endDate", this.endDate.getValueAsDate());
    		criteria.addCriteria("study", this.studyField.getValueAsString());
    		quickQuoteGrid.fetchData(criteria);
    Data Source
    Code:
    	public DSResponse executeFetch(DSRequest req) throws Exception
    	{
    		List<Deal> records = fetchRecords(req.getCriteria());
    		return new DSResponse(records);
    	}
    
    private List<Deal> fetchRecords(Map criteria)
    	{
    		return data;
    	}
    This is a mockup datasource. No live data.

    #2
    Things to check:

    1. if you haven't declared DataSourceFields for those criteria, they would be ignored and stripped out before the request reaches your DataSource

    2. if you've set dataFetchMode:"local", DataSource.cacheAllData:true or related settings that would cause all DataSource data to be fetched then managed locally, empty criteria at the server would be expected

    Also, if you're just mocking, either a clientOnly DataSource or a SQLDataSource using a table auto-generated by the Admin Console would probably be better choices.

    Comment


      #3
      is there an example of how to use a DataSourceField properly in the showcase or elsewhere?

      Comment


        #4
        Yes, every single example involving a DataSource :)

        What we meant is: if you have not declared a DataSourceField called 'startDate', specifying startDate in the criteria will not work.

        Comment


          #5
          ...except for the custom data source example. We have to use a custom data source because we will be using EJBs to handle the data.

          Are DataSourceFields used with custom datasources as well? If not, can you point me to an example of how to do it?

          Comment


            #6
            Lots of basic misconceptions here.. can you read through the QuickStart Guide, especially the chapters on DataSources and Data Binding, then revisit this?

            Using EJBs does not imply custom DataSources unless you are using obsolete EJB versions. EJBs are accessible via JPA.

            The Custom DataSource examples, while possibly inapplicable now that you've revealed your target data store, do indeed show use of DataSourceFields just as described in the QuickStart.

            Comment


              #7
              EJB 2

              Will study

              Comment


                #8
                From the javadoc

                "Out of the box, and with no code to write, Smart GWT supports SQL and Hibernate for persistence. For other Java-based persistence systems, such as EJB, JPA, or systems proprietary to your company, you write a custom DataSource class in Java. In most cases, it is possible to write a single, generic DataSource class that provides access to all data that is a available from a given persistence mechanism; for example, a single DataSource class can typically be written for accessing all Entity Beans available via EJB. "

                Is this out of date? If not, can you please show me an example of how to pass in criteria to a custom data source?

                Comment


                  #9
                  That's partly out of date in that it doesn't mention built-in support for JPA. We'll update that aspect.

                  The Custom DataSource examples already demonstrate passing criteria, in fact, they cover this in great depth: notice how the Hibernate one turns the passed criteria in the DSRequests into a Hibernate-specific Criteria object, for example.

                  Comment


                    #10
                    setDataFetchMode(FetchMode.BASIC) fixed it

                    Comment


                      #11
                      Right, as we mentioned:

                      2. if you've set dataFetchMode:"local", DataSource.cacheAllData:true or related settings that would cause all DataSource data to be fetched then managed locally, empty criteria at the server would be expected

                      Comment


                        #12
                        Yes, thanks. That's where I got it. It was actually the first suggestion you made. :-)

                        Comment

                        Working...
                        X