Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug with ComboBoxItem when used with setPickListCriteria

    Hi Isomorphic,

    please see this minimal testcase. When enabling the setPickListCriteria(), the ComboBoxItem does no longer filter with TextMatchStyle.SUBSTRING, actually it doesn't filter at all.

    Best regards,
    Blama

    Environment:
    Code:
    Firefox11 Dev Mode
    v8.2p_2012-08-14/EVAL Deployment 2012-08-14
    Client Java:
    Code:
    package com.smartgwt.sample.client;
    
    import com.smartgwt.client.data.Criteria;
    import com.smartgwt.client.data.Criterion;
    import com.smartgwt.client.data.DataSource;
    import com.smartgwt.client.types.OperatorId;
    import com.smartgwt.client.types.TextMatchStyle;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
    import com.smartgwt.client.widgets.form.fields.FormItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.google.gwt.core.client.EntryPoint;
    
    public class Testcase4 implements EntryPoint {
    	@Override
    	public void onModuleLoad() {
    		VLayout vL = new VLayout() {
    			{
    				setWidth100();
    				setHeight100();
    				final DynamicForm testForm = new DynamicForm() {
    					{
    						FormItem nameFI = new FormItem("NAME");
    						ComboBoxItem prjCBI = new ComboBoxItem("PROJEKT_ID") {
    							{
    								setOptionDataSource(DataSource.get("T_PROJEKT"));
    								setValueField("ID");
    								setDisplayField("NAME");
    								setTextMatchStyle(TextMatchStyle.SUBSTRING);
    								//Uncomment the following line to see the bug:
    								//setPickListCriteria(new Criterion("ID", OperatorId.NOT_EQUAL, 1000));
    							}
    						};
    						setDataSource(DataSource.get("T_MODUL"));
    						setFields(nameFI, prjCBI);
    					}
    				};
    				addMember(testForm);
    			}
    		};
    		vL.draw();
    	}
    }


    SQL (Oracle):
    Code:
    DROP TABLE t_modul CASCADE CONSTRAINTS ;
    DROP TABLE t_projekt CASCADE CONSTRAINTS ;
    DROP SEQUENCE T_MODUL_ID ;
     CREATE TABLE t_modul
        ( id INTEGER NOT NULL, projekt_id INTEGER NOT NULL, name VARCHAR2(10 CHAR)
        ) ;
    ALTER TABLE t_modul ADD CONSTRAINT PK_modul PRIMARY KEY
    (
      id
    )
    ;
    ALTER TABLE t_modul ADD CONSTRAINT UC_t_modul_project_id_name UNIQUE
    (
      projekt_id, name
    )
    ;
    DROP SEQUENCE T_PROJEKT_ID ;
     CREATE TABLE t_projekt
        (
          id        INTEGER NOT NULL,
          shortname VARCHAR2(10 CHAR) NOT NULL,
          name      VARCHAR2(50 CHAR) NOT NULL
        ) ;
    ALTER TABLE t_projekt ADD CONSTRAINT PK_projekt PRIMARY KEY
    (
      id
    )
    ;
    ALTER TABLE t_projekt ADD CONSTRAINT UC_t_projekt_shortname UNIQUE
    (
      shortname
    )
    ;
    ALTER TABLE t_modul ADD CONSTRAINT FK_t_modul_t_projekt FOREIGN KEY
    (
      projekt_id
    )
    REFERENCES t_projekt
    (
      id
    )
    ;
    CREATE SEQUENCE T_MODUL_ID NOCACHE ORDER ;
    CREATE OR REPLACE TRIGGER t_modul_BI BEFORE
       INSERT ON t_modul FOR EACH ROW WHEN(NEW.id IS NULL) BEGIN
       SELECT T_MODUL_ID.NEXTVAL INTO :NEW.id FROM DUAL;
    END;
    /
    CREATE SEQUENCE T_PROJEKT_ID NOCACHE ORDER ;
    CREATE OR REPLACE TRIGGER t_projekt_BI BEFORE
       INSERT ON t_projekt FOR EACH ROW WHEN(NEW.id IS NULL) BEGIN
       SELECT T_PROJEKT_ID.NEXTVAL INTO :NEW.id FROM DUAL;
    END;
    /
    INSERT INTO T_PROJEKT(SHORTNAME, NAME) VALUES ('1st', 'This includes y.');
    INSERT INTO T_PROJEKT(SHORTNAME, NAME) VALUES ('2nd', 'This includes z.');
    INSERT INTO T_PROJEKT(SHORTNAME, NAME) VALUES ('3rd', 'This includes z and y.');
    COMMIT;
    T_MODUL.ds.xml:
    Code:
    <DataSource schema="testcase" dbName="Oracle" tableName="T_MODUL" ID="T_MODUL" dataSourceVersion="1"
    	serverType="sql"
    >
    	<fields>
    		<field primaryKey="true" hidden="true" name="ID" type="sequence"></field>
    		<field name="PROJEKT_ID" title="Projekt" required="true" foreignKey="T_PROJEKT.ID" displayField="PROJEKT_NAME"
    			editorType="selectItem"
    		></field>
    		<field name="PROJEKT_NAME" hidden="true" required="false" canSave="false" includeFrom="T_PROJEKT.SHORTNAME"></field>
    		<field name="NAME" title="Modulname" required="true" length="10" type="text"></field>
    	</fields>
    </DataSource>
    T_PROJEKT.ds.xml:
    Code:
    <DataSource schema="testcase" dbName="Oracle" tableName="T_PROJEKT" ID="T_PROJEKT" dataSourceVersion="1"
    	serverType="sql"
    >
    	<fields>
    		<field primaryKey="true" hidden="true" name="ID" type="sequence"></field>
    		<field name="SHORTNAME" title="Kurzname" length="10" type="text" required="true">
    			<validators>
    				<validator type="isUnique" errorMessage="Jedes Projektkürzel darf nur einmal vergeben werden!"></validator>
    			</validators>
    		</field>
    		<field name="NAME" length="50" type="text" required="true"></field>
    	</fields>
    </DataSource>

    #2
    The expected behavior would be that no records match, since none have the ID you specified in your criteria. Doesn't appear to be a bug.

    Comment


      #3
      Hi Isomorphic,

      then I most likely get the usage wrong:

      What I observe is the following:
      a) with setPickListCriteria(new Criterion("ID", OperatorId.NOT_EQUAL, 1000)):
      - SQL includes "WHERE (T_PROJEKT.ID <> '1000' OR T_PROJEKT.ID IS NULL)"
      - When I type "z" the list includes 3 entries.

      b) w/o setPickListCriteria:
      - No WHERE clause in SQL
      - When I type "z" the list includes 2 entries (searching takes place in the "NAME" field).

      Desired behaviour is:
      - WHERE clause
      - searching takes place in the "NAME" field

      I also found the setFilterFields-API, which seems to adress my usecase, but even if I put "setFilterFields("NAME");", searching doesn't take place in the "NAME" field.


      Code:
      setOptionDataSource(DataSource.get("T_PROJEKT"));
      setPickListCriteria(new Criterion("ID", OperatorId.NOT_EQUAL, 1000));
      setValueField("ID");
      setDisplayField("NAME");
      setTextMatchStyle(TextMatchStyle.SUBSTRING);
      setFilterFields("NAME");
      In the log I get:
      Code:
      === 2012-08-18 21:54:23,947 [0-10] INFO  RequestContext - URL: '/builtinds/sc/IDACall', User-Agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0': Moz (Gecko) with Accept-Encoding header
      === 2012-08-18 21:54:23,947 [0-10] DEBUG XML - Parsed XML from (in memory stream): 0ms
      === 2012-08-18 21:54:23,947 [0-10] DEBUG RPCManager - Processing 1 requests.
      === 2012-08-18 21:54:23,947 [0-10] DEBUG RPCManager - Request #1 (DSRequest) payload: {
          criteria:{
              ID:"z"
          },
          operationConfig:{
              dataSource:"T_PROJEKT",
              operationType:"fetch"
          },
          componentId:"isc_Testcase4_1$1_0",
          appID:"builtinApplication",
          operation:"T_PROJEKT_fetch",
          oldValues:{
              ID:"z"
          }
      }
      === 2012-08-18 21:54:23,948 [0-10] INFO  IDACall - Performing 1 operation(s)
      === 2012-08-18 21:54:23,948 [0-10] DEBUG AppBase - [builtinApplication.T_PROJEKT_fetch] No userTypes defined, allowing anyone access to all operations for this application
      === 2012-08-18 21:54:23,948 [0-10] DEBUG AppBase - [builtinApplication.T_PROJEKT_fetch] No public zero-argument method named '_T_PROJEKT_fetch' found, performing generic datasource operation
      === 2012-08-18 21:54:23,948 [0-10] INFO  SQLDataSource - [builtinApplication.T_PROJEKT_fetch] Performing fetch operation with
      	criteria: {ID:"z"}	values: {ID:"z"}
      === 2012-08-18 21:54:23,948 [0-10] WARN  SQLWhereClause - [builtinApplication.T_PROJEKT_fetch] Got non-numeric value 'z' for numeric column 'ID', creating literal false expression: java.lang.NumberFormatException: For input string: "z"
      === 2012-08-18 21:54:23,948 [0-10] INFO  SQLDataSource - [builtinApplication.T_PROJEKT_fetch] derived query: SELECT $defaultSelectClause FROM $defaultTableClause WHERE $defaultWhereClause
      === 2012-08-18 21:54:23,948 [0-10] INFO  SQLDataSource - [builtinApplication.T_PROJEKT_fetch] Executing SQL query on 'Oracle': SELECT T_PROJEKT.ID, T_PROJEKT.NAME, T_PROJEKT.SHORTNAME FROM testcase.T_PROJEKT WHERE ('0'='1')
      === 2012-08-18 21:54:23,979 [0-10] DEBUG PoolableSQLConnectionFactory - [builtinApplication.T_PROJEKT_fetch] Returning pooled Connection
      === 2012-08-18 21:54:23,979 [0-10] INFO  SQLDriver - [builtinApplication.T_PROJEKT_fetch] Executing SQL query on 'Oracle': SELECT T_PROJEKT.ID, T_PROJEKT.NAME, T_PROJEKT.SHORTNAME FROM testcase.T_PROJEKT WHERE ('0'='1')
      === 2012-08-18 21:54:23,979 [0-10] INFO  DSResponse - [builtinApplication.T_PROJEKT_fetch] DSResponse: List with 0 items
      === 2012-08-18 21:54:23,979 [0-10] DEBUG RPCManager - Content type for RPC transaction: text/plain; charset=UTF-8
      === 2012-08-18 21:54:23,979 [0-10] DEBUG RPCManager - non-DMI response, dropExtraFields: false
      === 2012-08-18 21:54:23,979 [0-10] INFO  Compression - /builtinds/sc/IDACall: 173 -> 148 bytes

      Comment

      Working...
      X