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

    ComboBoxItem picklist update

    I have a form with a combobox in it that is connected to a datasource. When the combox icon is clicked it goes to the server and displays some data. The data is dynamic so when the user clicks on the combo box again, i want it to go back to the server can get the data again. The problem i have is that it only gets the data once. I thought it was caching the data so i set dont cache but the problem is still there.

    ComboBoxItem driveCombo = new ComboBoxItem("USB Drives");

    DynamicForm form = new DynamicForm();
    form.setDataSource(DataSource.get(DRIVEDIR_STR), driveCombo);

    So how do i get it to refresh or pull the data form the server every time the user clicks on the combobox?

    The ComboBoxItem will not re-fetch from the server automatically if the criteria have not changed.
    You can force a fetch by explicitly calling "fetchData()" on the ComboBoxItem, so if you want a fresh server fetch every time the user clicks the pickerIcon, you can use the pickerIconClickHandler, something like this:
            item1.addPickerIconClickHandler(new PickerIconClickHandler() {
                public void onPickerIconClick(PickerIconClickEvent event) {
                    SelectItem item = (SelectItem) event.getItem();
    If you're looking for a more general solution to notify the client of changes to a DataSource's server-side data, there are a few options:
    - You can explicitly call DataSource.invalidateCache(). (A similar API exists on specific components, like ListGrid too).
    - If cache invalidation should occur as a result of a particular operation, you can set the boolean 'invalidateCache' flag on the DSResponse returned by that operation
    - For a more targeted approach, you call dataSource.updateCaches(). This method takes a DSResponse object as an argument and will cause the DataSource to integrate the updated, added or removed data into all components' client side caches automatically, just as if you had performed the operation and got that response from the server.

    (This last option is sometimes used in conjunction with Messaging to allow the server to push changes to the client automatically in real time).

    Isomorphic Software