Announcement

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

    Unwanted reusing ListGrid and ResultSet in Tab

    Hi,

    I use a Tab as main layout of ma app.

    When I open a Tab which contains ListGrid then it fetches data into a ResultSet.

    After closing and opening the tab. I create new Tab() constructor as well as new ListGrid on it. Those object have the same ID as the previous Tab which has been closed.

    When I call new ListGrid. I don't mind that it reuses a component in memory for optimalization but I have a problem that it reuses loaded ResultSet.

    When I call new ListGrid I'd like to have listGrid.invalidateCache() called automatically.

    This issue is with many input components which holds some values i.e. ResultSet or FormItems.

    What can I do in order to disable this side effect?

    I uses the official SmartGWT 2.5 release.

    #2
    There's no mechanism by which a ResultSet could be re-used, you are probably seeing an effect of your own code.

    If you remove a Tab and you don't want to use those components any more, call destroy() on them. Just calling destroy() on the root component of any nested layout is sufficient to destroy the whole thing.

    Comment


      #3
      thanks,

      so this should do the trick?

      Code:
      tabSet.addCloseClickHandler(new CloseClickHandler() {
      	@Override
      	public void onCloseClick(TabCloseClickEvent event) {
      		Tab tab = event.getTab();
      		tab.getPane().destroy();
      	}
      });

      Comment


        #4
        Hi,

        if I destroy the whole Tab the situation has improved but I still facing a problem with cached data.

        I have a dynamic form in a Tab. When I click on the SelectItem it reads data from optionalDataSource. When I close a destroy the tab and open it again the SelectItem somehow remembers options to display and the optinalDataSource is ignored.

        Please, find attached a test case including video demonstration located at www.zdary.cz/selectitem.wmv

        I created criteria for fetch based on other options that is why I overrided getPickListFilterCriteria method.
        I tried to override getOptionCriteria method with no luck. It doesn't reach the body of the getOptionCriteria method at all.
        I also tried to set setPickListFilterCriteriaFunction(new FormItemCriteriaFunction(){...}

        Tested it on smartGWT 3.0 15.09.2011 eval.

        best regards,
        Zdary
        Attached Files
        Last edited by zdary; 18 Sep 2011, 05:30.

        Comment


          #5
          Hi Zdary

          setPickListFilterCriteriaFunction() is the correct way to customize the criteria for the pickList.

          It appears to be working for us - running against the September 19th nightly, 3.x branch.

          We modified your code slightly to do this:
          Code:
          sitem.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction(){
          			@Override
          			public Criteria getCriteria(FormItemFunctionContext itemContext) {
          			    SC.logWarn("RUNNING!");
          				Criteria criteria = new Criteria();
          				int answerId = (int) Math.round(Math.random()*3);
          				
              			criteria.addCriteria("answerId",answerId);
                          return criteria;
          			}});
          The method is firing every time the user clicks icon to show the pickList (you can see the "RUNNING" text in the log).

          By default SelectItems will not hit the server if fetching data from an optionDataSource if filter criteria are unchanged.
          In the above example we've modified the criteria generation code to vary the criteria randomly. Hit it a few times and you'll see that the server is queried whenever the criteria actually change.

          This caching behavior is shared across SelectItems - this means in the common case of having a number of SelectItems on a page bound to the same option dataSource we don't issue a number of redundant fetches to populate them with the same data set.

          We'll add a method "setCachePickListResults()" to the SelectItem and ComboBoxItem class to allow you to disable this behavior. This will show up in the next nightly build (3.x branch)


          Regards
          Isomorphic Software

          Comment

          Working...
          X