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

        Working...
        X