/** * @return - true if selectedIndex has been fixed, refresh() must be called manually in that case. * * <br><br> Unfortunately jqm likes to change selectedIndex from -1 to 0 (for example it happens * on initialization, i.e. selectmenucreate). Also this behavior is browser specific, so * we need this guard method to make sure that null value is supported properly. * * <br><b>IE11 needs</b> much more attention, because even if selectedIndex set/fixed to -1, * browser anyway always considers item0 as selected, so choosing first item from dropdown list is not * working for empty combo. <br> The only way to <b>solve this</b> - always add {@code<option value="" text=""></option>} * to JQMSelect. <br> See special logic in getValue(0) for returning null in such case. */ protected boolean checkSelectedIndex() { if (mandatorySelIdx == null) return false; int i = select.getSelectedIndex(); if (mandatorySelIdx != i) { if (isMultiple()) return false; select.setSelectedIndex(mandatorySelIdx); return true; } else { return false; } }
/** * @return - true if selectedIndex has been fixed, refresh() must be called manually in that case. * * <br><br> Unfortunately jqm likes to change selectedIndex from -1 to 0 (for example it happens * on initialization, i.e. selectmenucreate). Also this behavior is browser specific, so * we need this guard method to make sure that null value is supported properly. */ protected boolean checkSelectedIndex() { if (mandatorySelIdx == null) return false; int i = select.getSelectedIndex(); if (mandatorySelIdx != i) { if (isMultiple()) return false; select.setSelectedIndex(mandatorySelIdx); return true; } else { return false; } }
/** * @return - true if selectedIndex has been fixed, refresh() must be called manually in that case. * * <br><br> Unfortunately jqm likes to change selectedIndex from -1 to 0 (for example it happens * on initialization, i.e. selectmenucreate). Also this behavior is browser specific, so * we need this guard method to make sure that null value is supported properly. */ protected boolean checkSelectedIndex() { if (mandatorySelIdx == null) return false; int i = select.getSelectedIndex(); if (mandatorySelIdx != i) { if (isMultiple()) return false; select.setSelectedIndex(mandatorySelIdx); return true; } else { return false; } }
protected void changed() { if (!isMultiple()) mandatorySelIdx = select.getSelectedIndex(); fireValueChange(getValue()); }
@Override public void onChange(ChangeEvent event) { if (!isMultiple()) mandatorySelIdx = select.getSelectedIndex(); fireValueChange(getValue()); } });
/** * Returns the index of the currently selected option */ public int getSelectedIndex() { checkSelectedIndex(); return select.getSelectedIndex(); }
/** * Returns the index of the currently selected option */ public int getSelectedIndex() { checkSelectedIndex(); return select.getSelectedIndex(); }
@Override public void onChange(ChangeEvent event) { if (!isMultiple()) mandatorySelIdx = select.getSelectedIndex(); fireValueChange(getValue()); } });
/** * Returns the index of the currently selected option */ public int getSelectedIndex() { checkSelectedIndex(); return select.getSelectedIndex(); }