private SelectItemAndComponent determineSelectedItem ( FacesContext context , SelectOneMenu menu , List < SelectItemAndComponent > items , Converter converter ) { Object submittedValue = menu . getSubmittedValue ( ) ; Object selectedOption ; if ( submittedValue != null ) { selectedOption = submittedValue ; } else { selectedOption = menu . getValue ( ) ; } for ( int index = 0 ; index < items . size ( ) ; index ++ ) { SelectItemAndComponent option = items . get ( index ) ; if ( option . getSelectItem ( ) . isNoSelectionOption ( ) ) continue ; Object itemValue = option . getSelectItem ( ) . getValue ( ) ; String itemValueAsString = getOptionAsString ( context , menu , itemValue , converter ) ; Object optionValue ; if ( submittedValue != null ) { optionValue = itemValueAsString ; } else { optionValue = itemValue ; } if ( itemValue != null ) { if ( isSelected ( context , menu , selectedOption , optionValue , converter ) ) { return option ; } } } return null ; }
Compare current selection with items if there is any element selected