Uploaded image for project: 'Click'
  1. Click
  2. CLK-797

Select with only one option, Select isValid() return error when this option select in browser.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 2.3.0
    • None
    • core
    • Windows 7, Tomcat 7.0, JDK 1.6

    Description

      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;
      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            vhly Zhang Xiaohe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: