protected Object getNewSelection ( final Request request ) { String paramValue = request . getParameter ( getId ( ) ) ; if ( paramValue == null ) { return null ; } // Figure out which option has been selected. List < ? > options = getOptions ( ) ; if ( options == null || options . isEmpty ( ) ) { if ( ! isEditable ( ) ) { // User could not have made a selection. return null ; } options = Collections . EMPTY_LIST ; } int optionIndex = 0 ; for ( Object option : options ) { if ( option instanceof OptionGroup ) { List < ? > groupOptions = ( ( OptionGroup ) option ) . getOptions ( ) ; if ( groupOptions != null ) { for ( Object nestedOption : groupOptions ) { if ( paramValue . equals ( optionToCode ( nestedOption , optionIndex ++ ) ) ) { return nestedOption ; } } } } else if ( paramValue . equals ( optionToCode ( option , optionIndex ++ ) ) ) { return option ; } } // Option not found, but if editable, user entered text if ( isEditable ( ) ) { return paramValue ; } // Invalid option. Ignore and use the current selection LOG . warn ( "Option \"" + paramValue + "\" on the request is not a valid option. Will be ignored." ) ; Object currentOption = getValue ( ) ; return currentOption ; }
Determines which selection has been included in the given request .