* user entered string value for the new item
*/
public void sendNewItem(String itemValue) {
- getConnection().updateVariable(getConnectorId(), "newitem", itemValue,
- immediate);
+ rpc.createNewItem(itemValue);
}
/**
}
private ComboBoxServerRpc rpc = new ComboBoxServerRpc() {
-
+ @Override
+ public void createNewItem(String itemValue) {
+ if (isNewItemsAllowed()) {
+ // New option entered (and it is allowed)
+ if (itemValue != null && itemValue.length() > 0) {
+ getNewItemHandler().addNewItem(itemValue);
+ // rebuild list
+ filterstring = null;
+ prevfilterstring = null;
+ }
+ }
+ }
};
/**
filterstring = filterstring.toLowerCase(getLocale());
}
requestRepaint();
- } else if (isNewItemsAllowed()) {
- // New option entered (and it is allowed)
- final String newitem = (String) variables.get("newitem");
- if (newitem != null && newitem.length() > 0) {
- getNewItemHandler().addNewItem(newitem);
- // rebuild list
- filterstring = null;
- prevfilterstring = null;
- }
}
if (variables.containsKey(FocusEvent.EVENT_ID)) {
* @since
*/
public interface ComboBoxServerRpc extends ServerRpc {
-
+ /**
+ * Create a new item in the combo box. This method can only be used when the
+ * ComboBox is configured to allow the creation of new items by the user.
+ *
+ * @param itemValue
+ * user entered string value for the new item
+ */
+ public void createNewItem(String itemValue);
}