001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5;
014
015import java.util.List;
016
017/**
018 * Defines the possible options and option groups for a <select> [X]HTML element.
019 *
020 * Primarily used by the {@link org.apache.tapestry5.corelib.components.Select} component, but potentially used by
021 * anything similar, that needs to present a list of options to the user. Generally paired with a {@link
022 * org.apache.tapestry5.ValueEncoder} to create client-side representations of server-side values.
023 *
024 * @see org.apache.tapestry5.corelib.components.Palette
025 */
026public interface SelectModel
027{
028    /**
029     * The list of groups, each containing some number of individual options.
030     *
031     * @return the groups, or null
032     */
033    List<OptionGroupModel> getOptionGroups();
034
035    /**
036     * The list of ungrouped options, which appear after any grouped options. Generally, a model will either provide
037     * option groups or ungrouped options, but not both.
038     *
039     * @return the ungrouped options, or null
040     */
041    List<OptionModel> getOptions();
042
043    /**
044     * Allows access to all the {@link OptionGroupModel}s and {@link OptionModel}s within the SelectModel.
045     */
046    void visit(SelectModelVisitor visitor);
047}