Search in sources :

Example 6 with OptionModelImpl

use of org.apache.tapestry5.internal.OptionModelImpl in project tapestry-5 by apache.

the class OptionGroupForm method getModel.

public SelectModel getModel() {
    return new AbstractSelectModel() {

        private List<OptionGroupModel> groupModels = null;

        public List<OptionModel> getOptions() {
            return null;
        }

        public List<OptionGroupModel> getOptionGroups() {
            if (groupModels == null) {
                computeModel();
            }
            return groupModels;
        }

        private void computeModel() {
            groupModels = new ArrayList<OptionGroupModel>();
            for (Entity entity : entityList) {
                List<OptionModel> options = new ArrayList<OptionModel>();
                options.add(new OptionModelImpl(entity.getLabel(), entity));
                OptionGroupModel groupModel = new OptionGroupModelImpl(entity.getLabel(), false, options);
                groupModels.add(groupModel);
            }
        }
    };
}
Also used : Entity(org.apache.tapestry5.integration.app1.data.Entity) OptionGroupModel(org.apache.tapestry5.OptionGroupModel) OptionModelImpl(org.apache.tapestry5.internal.OptionModelImpl) AbstractSelectModel(org.apache.tapestry5.util.AbstractSelectModel) OptionGroupModelImpl(org.apache.tapestry5.internal.OptionGroupModelImpl) OptionModel(org.apache.tapestry5.OptionModel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

OptionModelImpl (org.apache.tapestry5.internal.OptionModelImpl)5 OptionModel (org.apache.tapestry5.OptionModel)4 SelectModelImpl (org.apache.tapestry5.internal.SelectModelImpl)4 Test (org.testng.annotations.Test)3 XMLMarkupModel (org.apache.tapestry5.dom.XMLMarkupModel)2 MarkupWriterImpl (org.apache.tapestry5.internal.services.MarkupWriterImpl)2 StringValueEncoder (org.apache.tapestry5.internal.services.StringValueEncoder)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 OptionGroupModel (org.apache.tapestry5.OptionGroupModel)1 Entity (org.apache.tapestry5.integration.app1.data.Entity)1 OptionGroupModelImpl (org.apache.tapestry5.internal.OptionGroupModelImpl)1 AbstractSelectModel (org.apache.tapestry5.util.AbstractSelectModel)1