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