Package org.apache.click.control

Examples of org.apache.click.control.Option


     */
    public void onInit() {
        super.onInit();

        List customers = getCustomerService().getCustomers();
        select.add(new Option("[Select]"));
        select.addAll(customers, "id", "name");
        applyOptions();
    }
View Full Code Here


     */
    public void onInit() {
        super.onInit();

        List customerList = getCustomerService().getCustomers();
        customerSelect.add(new Option(""));
        for (Iterator i = customerList.iterator(); i.hasNext();) {
            Customer customer = (Customer) i.next();
            customerSelect.add(new Option(customer.getId(), customer.getName()));
        }

        if (getContext().isForward() && courseBooking != null) {
            customerSelect.setValueObject(courseBooking.getCustomerId());
            dateField.setDate(courseBooking.getBookingDate());
View Full Code Here

            throw new IllegalStateException(msg);
        }

        // Determine whether option list should be loaded
        if (getOptionList().size() == 1) {
            Option option = (Option) getOptionList().get(0);
            if (option.getValue().equals(Option.EMPTY_OPTION.getValue())) {
                // continue and load option list

            } else {
                // Don't load list
                return;
            }

        } else if (getOptionList().size() > 1) {
            // Don't load list
            return;
        }

        DataContext dataContext = DataContext.getThreadDataContext();

        List list = Collections.EMPTY_LIST;

        if (getSelectQuery() != null) {
            list = dataContext.performQuery(getSelectQuery());

        } else if (getNamedQuery() != null) {
            list = dataContext.performQuery(getNamedQuery());

        } else if (getQueryName() != null) {
            list = dataContext.performQuery(getQueryName(), getExpireCache());
        }

        if (isRequired() && getOptionList().isEmpty() || isOptional()) {
            getOptionList().add(Option.EMPTY_OPTION);
        }

        Map cache = new HashMap();

        for (int i = 0; i < list.size(); i++) {
            Object row = list.get(i);

            Object value = null;
            Object label = null;

            if (row instanceof DataRow) {
                DataRow dataRow = (DataRow) row;

                if (dataRow.containsKey(getOptionValue())) {
                    value = dataRow.get(getOptionValue());

                } else {
                    String msg = "no value in dataRow for optionValue: "
                                 + getOptionValue();
                    throw new RuntimeException(msg);
                }

                if (getOptionLabel() != null) {

                    if (dataRow.containsKey(getOptionLabel())) {
                        label = dataRow.get(getOptionLabel());

                    } else {
                        String msg = "no value in dataRow for optionLabel: "
                                     + getOptionLabel();
                        throw new RuntimeException(msg);
                    }

                } else {
                    label = getDecorator().render(dataRow, getContext());
                }

            } else {

                try {

                    value = PropertyUtils.getValue(row, getOptionValue(), cache);

                    if (getOptionLabel() != null) {
                        label = PropertyUtils.getValue(row, getOptionLabel(), cache);

                    } else {
                        label = getDecorator().render(row, getContext());
                    }

                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            value = (value != null) ? value : "";
            label = (label != null) ? label : "";

            getOptionList().add(new Option(value.toString(), label.toString()));
        }
    }
View Full Code Here

            String msg = "options parameter cannot be null";
            throw new IllegalArgumentException(msg);
        }
        for (Iterator i = options.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            Option option = new Option(entry.getKey().toString(), entry
                    .getValue().toString());
            getOptionList().add(option);
        }
    }
View Full Code Here

            String msg = "options parameter cannot be null";
            throw new IllegalArgumentException(msg);
        }
        for (int i = 0; i < options.length; i++) {
            String value = options[i];
            getOptionList().add(new Option(value, value));
        }
    }
View Full Code Here

            try {
                Object valueResult = PropertyUtils.getValue(object, value, cache);
                Object labelResult = PropertyUtils.getValue(object, label, cache);

                Option option = null;

                if (labelResult != null) {
                    option = new Option(valueResult, labelResult.toString());
                } else {
                    option = new Option(valueResult.toString());
                }

                getOptionList().add(option);

            } catch (Exception e) {
View Full Code Here

        List optionList     = getOptionList();
        List selectedValues = getSelectedValues();
        List options        = new ArrayList();

        for (int i = 0; i < optionList.size(); i++) {
            Option option = (Option) optionList.get(i);
            Map map = new HashMap();
            map.put("option", option);
            map.put("selected", new Boolean(selectedValues.contains(option.getValue())));
            options.add(map);
        }

        Map model = new HashMap();
View Full Code Here

        form.setErrorsPosition(Form.POSITION_TOP);

        // Gender Select
        genderSelect = new Select("gender");
        genderSelect.setRequired(true);
        genderSelect.add(new Option("U", ""));
        genderSelect.add(new Option("M", "Male"));
        genderSelect.add(new Option("F", "Female"));
        form.add(genderSelect);

        // Investment Select
        List investmentOptions = new ArrayList();

        OptionGroup property = new OptionGroup("property");
        property.add(new Option("Commerical Property", "Commercial"));
        property.add(new Option("Residential Property", "Residential"));
        investmentOptions.add(property);

        OptionGroup securities = new OptionGroup("securities");
        securities.add(new Option("Bonds"));
        securities.add(new Option("Options"));
        securities.add(new Option("Stocks"));
        investmentOptions.add(securities);

        investmentSelect = new Select("investment");
        investmentSelect.setOptionList(investmentOptions);
        investmentSelect.setMultiple(true);
View Full Code Here

    private PickList pickList = new PickList("languages");

    public PickListDemo() {
        pickList.setHeaderLabel("Languages", "Selected");

        pickList.add(new Option("002", "C/C++"));
        pickList.add(new Option("003", "C#"));
        pickList.add(new Option("004", "Fortran"));
        pickList.add(new Option("005", "Java"));
        pickList.add(new Option("006", "Ruby"));
        pickList.add(new Option("007", "Perl"));
        pickList.add(new Option("008", "Visual Basic"));

        pickList.addSelectedValue("004");

        form.add(pickList);
View Full Code Here

    public void add(Object option) {
        if (option instanceof Option) {
            getOptionList().add(option);

        } else if (option instanceof String) {
            getOptionList().add(new Option(option.toString()));

        } else if (option instanceof Number) {
            getOptionList().add(new Option(option.toString()));

        } else if (option instanceof Boolean) {
            getOptionList().add(new Option(option.toString()));

        } else {
            String message = "Unsupported options class "
                + option.getClass().getName() + ". Please use method "
                + "PickList.addAll(Collection, String, String) instead.";
View Full Code Here

TOP

Related Classes of org.apache.click.control.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.