Announcement

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

    Cache at application start

    Hi, I am using version 6.1-p20190721.

    I have few SelectItems and Combobox in my application pages. All those SelectItems and Comboboxes have datasources attached with them. When i first click on the item, it fetches the data and smarGWT cache it at client side.
    I wish to cache this data at application start. I tried DataSource.fetchData() but it says. "Operation Type fetch is not supported for this datasource". Please suggest how to achieve it?

    #2
    If calling DataSource.fetchData() results in that message, then your DataSource is broken, but you claim it's working elsewhere, so you're giving incorrect information somehow.

    Calling fetchData() on the SelectItem will result in data being fetched and cached.

    Setting cacheAllData on the DataSource (see docs for details) can be used to create a DataSource-level cache of all available data, shared across any components that access that DataSource.

    Comment


      #3
      Hi,

      I have used following code to do fetch

      Code:
      DataSource.get(DataSourceConstant.DROPDOWN_DS).setCacheAllData(true);
      DataSource.get(DataSourceConstant.DROPDOWN_DS).setCacheAllOperationId("fetchByID");
      DataSource.get(DataSourceConstant.DROPDOWN_DS).fetchData();
      Also tried following

      Code:
       DataSource.get(DataSourceConstant.DROPDOWN_DS).setCacheAllData(true);
                              DataSource.get(DataSourceConstant.DROPDOWN_DS).setCacheAllOperationId("fetchByID");
                              DSRequest rep = new DSRequest();
                              rep.setOperationId("fetchByID");
                              rep.setOperationType(DSOperationType.FETCH);
                              DataSource.get(DataSourceConstant.DROPDOWN_DS).execute(rep);
      But both are giving me the issue : "Operation Type Fetch not supported for this datasource."
      Below is my datasource

      Code:
      <DataSource ID="Dropdown"
                  schemaBean="com.assaabloy.cow.shared.dto.DropDownDTO">
          <fields>
              <field name="dropdownId" align="center" primaryKey="true"/>
              <field name="id" align="center"/>
              <field name="name" align="center"/>
              <field name="address" align="center"/>
      
      
          </fields>
        <operationBindings>
              <binding operationType="fetch" operationId="fetchByID" serverMethod="getById"
                       beanFactory="org.springframework.beans.factory.BeanFactory"
                       invalidateCache="true">
                  <serverObject lookupStyle="spring" bean="dropdownService"/>
              </binding>
      
      <binding operationType="fetch" operationId="fetchByCode" serverMethod="getByCode"
                       beanFactory="org.springframework.beans.factory.BeanFactory"
                       invalidateCache="true">
                  <serverObject lookupStyle="spring" bean="dropdownService"/>
              </binding>
          </operationBindings>
      </DataSource>
      Could you please help what i am missing here or which documentation should i refer to get it work?

      Comment


        #4
        The only fetch operations you have defined have operationIds, but you have not specified an operationId for the fetch.

        Comment


          #5
          Sorry for late reply. I got into some other feature implementation. Now i am back to this. I am able to make successful call to fetch data for items datasource before its drawn up. My intention was that once i ll do fetch against combobox datasource, it ll maintain cache and wont send fetch request again on click of picker icon. but it still sends the new request.
          My code is :
          Code:
                   comboboxItem.getOptionDataSource().setCacheAllOperationId("abc");
                   DSRequest rep = new DSRequest();
                  rep.setOperationId("abc");
                  rep.setTextMatchStyle(TextMatchStyle.STARTS_WITH);
                  rep.setOperationType(DSOperationType.FETCH);
                  comboboxItem.getOptionDataSource().fetchData(null, null, rep);
          Can i achieve this that my fetch call does not happen again for this datasource on click of picker icon?

          Comment


            #6
            It doesn’t make any sense to put this code in the optionDataSource, because this cache is maintained at the DataSource level for all components to access that data source. If that’s what you want you should simply do the fetch at application start up.

            You also don’t seem to know what the cacheAllOperationID is for, please re-visit the docs.

            If instead you wanted just this combo box to fetch all rows, you just set filterLocally:true.

            Comment

            Working...
            X