click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang Xiaohe (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CLK-797) Select with only one option, Select isValid() return error when this option select in browser.
Date Wed, 14 Aug 2013 04:28:47 GMT
Zhang Xiaohe created CLK-797:
--------------------------------

             Summary: Select with only one option, Select isValid() return error when this
option select in browser.
                 Key: CLK-797
                 URL: https://issues.apache.org/jira/browse/CLK-797
             Project: Click
          Issue Type: Bug
          Components: core
    Affects Versions: 2.3.0
         Environment: Windows 7, Tomcat 7.0, JDK 1.6
            Reporter: Zhang Xiaohe
            Priority: Minor


I have development a page, 

this page struct:

   SettingsPage
        |
        | ---> Table
        |
        | ---> Form
                  |
                  | ----> Select
                  |            |
                  |            | ---> Option (Only one option from DataProvider)
                  |
                  | ----> TextField
                  |
                  | --->  Submit ( my logic call onConfigFromSubmit) 

when I select option, and input some content to TextField, and click Submit,

the method onConfigFromSubmit invoke, and I check Form isValid() , the select return false.

My Code fragment:


package com.vhly.servers.innerstore.pages;

import com.vhly.servers.innerstore.InnerConfigUtil;
import com.vhly.servers.innerstore.model.ConfigValuePair;
import org.apache.click.Page;
import org.apache.click.control.*;
import org.apache.click.dataprovider.DataProvider;
import org.apache.click.extras.control.FieldColumn;
import org.apache.click.util.Bindable;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 13-8-13
 * Email: vhly@163.com
 */
public class SettingsPage extends Page {

    private Form configForm = new Form("configEditor");
    private Table table = new Table("configs");

    public SettingsPage() {

        table.setClass(Table.CLASS_ITS);
        table.addColumn(new Column("name"));
        table.addColumn(new Column("value"));
        table.setDataProvider(new DataProvider() {
            @Override
            public Iterable getData() {
                InnerConfigUtil configUtil = InnerConfigUtil.getInstance();
                return configUtil.getAllProperties();
            }
        });

        addControl(table);


        addControl(configForm);

        Select select = new Select("property", true);
        select.setDataProvider(new DataProvider() {
            @Override
            public Iterable getData() {
                InnerConfigUtil configUtil = InnerConfigUtil.getInstance();
                List<ConfigValuePair> allProperties = configUtil.getAllProperties();
                List<Option> options = new LinkedList<Option>();
                for (ConfigValuePair valuePair : allProperties) {
                    String name = valuePair.getName();
                    options.add(new Option(name, name));
                }
                return options;
            }
        });
        configForm.add(select);

        configForm.add(new TextField("value", true));
        configForm.add(new Submit("OK"));

        configForm.setListener(this, "onConfigFromSubmit");
    }

    public boolean onConfigFromSubmit() {
        boolean bret = false;
        if (configForm.isValid()) {   // In this case, only one option will return false from
Select.isValid()
            String name = configForm.getFieldValue("property");
            String value = configForm.getFieldValue("value");
            InnerConfigUtil configUtil = InnerConfigUtil.getInstance();  // my logic
            configUtil.setProperty(name, value);
            bret = true;
        }
        return bret;
    }
}



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message