Announcement

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

    MultiComboBoxItem not working with extended DataSource

    My testcase:

    Code:
    public class TestingModule implements EntryPoint {
    
    	private MultiComboBoxItem userSelectItem;
    
    	@Override
    	public void onModuleLoad() {
    
    		// ////////////////////////////////////////////////////////////////////////////
    		DynamicForm userForm = new DynamicForm();
    
    		userSelectItem = new MultiComboBoxItem();
    		userSelectItem.setOptionDataSource(DataSource.get("table"));
    		userSelectItem.setAutoFetchData(true);
    		userSelectItem.setWidth("100%");
    
    		userSelectItem.setLayoutStyle(MultiComboBoxLayoutStyle.FLOW);
    		userSelectItem.setValueField("f_schueler_id");
    		userSelectItem.setDisplayField("f_name");
    
    		userSelectItem.setTitle("table");
    		userSelectItem.setAlign(Alignment.LEFT);
    		userSelectItem.setTitleAlign(Alignment.LEFT);
    		userSelectItem.setRequired(true);
    
    		userSelectItem.setValue(523);
    
    		userForm.setFields(userSelectItem);
    		userForm.setWidth100();
    
    
    		final VStack layout = new VStack(10);
    		layout.setWidth(500);
    		layout.setMembers(userForm);
    
    		layout.draw();
    	}
    }
    This code normally works, (.setValue(523) correctly selects the user with f_schueler_id=523 and the name (f_name) is displayed).

    However, when extending the DataSource and injecting a criteria value, nothing is displayed:

    table.ds.xml
    Code:
    <DataSource ID="table" serverType="sql" tableName="t_schueler"
    	serverConstructor="de.mks_infofabrik.kids.server.TestDataSource" >
    	<fields>
    		<field name="f_schueler_id" type="sequence" primaryKey="true" />
    		<field name="f_name" type="text" />
    		<field name="f_mandant" type="integer" />
     	</fields>
    
    </DataSource>
    TestDataSource:
    Code:
    public class TestDataSource extends SQLDataSource {
    
    	@Override
    	public DSResponse executeFetch(DSRequest req) throws Exception {
    
    		AdvancedCriteria currentCriteria = req.getAdvancedCriteria();
    		AdvancedCriteria criteriaToUse = new AdvancedCriteria(
    				DefaultOperators.And, new Criterion[] {
    						currentCriteria.asCriterion(),
    						new SimpleCriterion("f_mandant",
    								DefaultOperators.Equals, 1) });
    		req.setAdvancedCriteria(criteriaToUse);
    		DSResponse response = super.executeFetch(req);
    		return response;
    	}
    
    }
    Executing the same testcase now doesn't show any value, and the DSRequests/Responses are very strange:
    DSRequest:
    Code:
    {
        dataSource:"table", 
        operationType:"fetch", 
        componentId:"isc_DynamicForm_0", 
        data:{
            f_schueler_id:[
                523
            ]
        }, 
        textMatchStyle:"exact", 
        callback:{
            target:[MultiComboBoxItem ID:isc_MultiComboBoxItem_1 name:isc_MultiComboBoxItem_0], 
            methodName:"fetchMissingValueReply"
        }, 
        showPrompt:false, 
        oldValues:{
            f_schueler_id:[
                523
            ]
        }, 
        requestId:"table$6270", 
        internalClientContext:{
            dataValue:{
                "0":523, 
                Class:"Array", 
                localeStringFormatter:"toString"
            }, 
            filterLocally:{
            }
        }, 
        fallbackToEval:false, 
        componentContext:"isc_MultiComboBoxItem_0", 
        bypassCache:true
    }
    DSResponse:
    Code:
    [
        {
            affectedRows:0, 
            data:[
            ], 
            endRow:0, 
            invalidateCache:false, 
            isDSResponse:true, 
            operationType:"fetch", 
            queueStatus:0, 
            startRow:0, 
            status:0, 
            totalRows:0
        }
    ]
    There *IS* a row with f_schueler_id=523 and f_mandant=1, so this should fetch the same row as before.

    Log:
    Code:
    === 2014-10-24 01:23:32,488 [c-39] DEBUG SQLDriver - [builtinApplication.table_fetch] About to execute SQL query in 'SQLSERVER' using connection '436418955'
    === 2014-10-24 01:23:32,488 [c-39] INFO  SQLDriver - [builtinApplication.table_fetch] Executing SQL query on 'SQLSERVER': SELECT t_schueler.f_schueler_id, t_schueler.f_name, t_schueler.f_mandant FROM t_schueler WHERE ((('0'='1')) AND (t_schueler.f_mandant = 1 AND t_schueler.f_mandant IS NOT NULL))
    WHERE '0'='1' ????????????????????????

    Nothing is special about the table used:
    Code:
    CREATE TABLE [dbo].[t_schueler](
    	[f_schueler_id] [int] IDENTITY(1,1) NOT NULL,
    	[f_name] [nvarchar](40) NOT NULL,
            [f_mandant] tinyint not null);
    Using smartGWT 4.1p power ( v9.1p_2014-10-09/PowerEdition Deployment ) with MSSQL 2014.

    #2
    You seem to be trying to use a MultiComboBoxItem to save to a field which is not multiple:true.

    Since the field is not multiple:true the array value the MultiComboBoxItem tries to save rejected (which is as expected), and 0=1 is generated to make sure the comparison will return false if it is included as a sub-expression of some other SQL (so this is also as expected).

    Comment


      #3
      I am not trying to save anything, I am only trying to display values, which works correctly if I remove this line from the "table.ds.xml":

      serverConstructor="de.mks_infofabrik.kids.server.TestDataSource"

      Removing this line makes everything to work, and the field is still not multiple:true
      Why is the example working when I remove this line, and not working when I put this line ?

      Comment


        #4
        Removing the line:

        serverConstructor="de.mks_infofabrik.kids.server.TestDataSource"

        Everything works:

        DSRequest:
        Code:
        {
            dataSource:"table", 
            operationType:"fetch", 
            componentId:"isc_DynamicForm_0", 
            data:{
                f_schueler_id:[
                    523
                ]
            }, 
            textMatchStyle:"exact", 
            callback:{
                target:[MultiComboBoxItem ID:isc_MultiComboBoxItem_1 name:isc_MultiComboBoxItem_0], 
                methodName:"fetchMissingValueReply"
            }, 
            showPrompt:false, 
            oldValues:{
                f_schueler_id:[
                    523
                ]
            }, 
            requestId:"table$6270", 
            internalClientContext:{
                dataValue:{
                    "0":523, 
                    Class:"Array", 
                    localeStringFormatter:"toString"
                }, 
                filterLocally:{
                }
            }, 
            fallbackToEval:false, 
            componentContext:"isc_MultiComboBoxItem_0", 
            bypassCache:true
        }
        DSResponse:
        Code:
        [
            {
                affectedRows:0, 
                data:[
                    {
                        f_mandant:1, 
                        f_schueler_id:523, 
                        f_name:"Anthon"
                    }
                ], 
                endRow:1, 
                invalidateCache:false, 
                isDSResponse:true, 
                operationType:"fetch", 
                queueStatus:0, 
                startRow:0, 
                status:0, 
                totalRows:1
            }
        ]
        So the criteria injecting is breaking the code.

        Comment


          #5
          So again, MultiComboBoxItem wouldn't be expected to work at all with a field that is not declared multiple="true". However, you may have found an issue that would actually apply to valid usage - can you show the complete log for the request, and in the future, please do not just show selected portions - you can easily omit logs that are significant, even if you don't realize they are significant.

          Comment


            #6
            My testcase is based on http://www.smartclient.com/smartgwt/showcase/#multicombobox_category : where is this field in your example declared multiple="true"? Why is the example in your showcase working then ?

            I am only trying to do something similar: let the user select some items. I am not trying to save anything with this field and it was always working until I added the serverConstructor declaration. As I said, it works if I remove the serverConstructor declaration.

            My complete logs are too large for the forum, I sent you an email to support@isomorphic.com

            Comment


              #7
              About your logs - they would be much shorter if you revert to the current shipped log4j.isc.config.xml, which would turn off several categories such as ISCKeyedObjectPool. Then you wouldn't need to email them.

              Regarding multiple="true" - it looked initially as though your sample code bound the MultiComboBoxItem to a DataSourceField that was not declared multiple="true". On looking more closely, you have the MultiComboBoxItem in a DynamicForm that has no DataSource. This is fine (like the sample).

              Your logs do reveal that the inbound criteria end up corrupted as part of your attempt to transform them, note the array value for an "equals" validator.

              === 2014-10-24 09:12:03,172 [ec-2] INFO SQLDataSource - [builtinApplication.table_fetch] Performing fetch operation with
              criteria: {criteria:[{criteria:[{value:[523],fieldName:"f_schueler_id",operator:"equals"}],operator:"and"},{value:1,fieldName:"f_mandant",operator:"equals"}],operator:"and",_constructor:"AdvancedCriteria"} values: {criteria:[{criteria:[{value:[523],fieldName:"f_schueler_id",operator:"equals"}],operator:"and"},{value:1,fieldName:"f_mandant",operator:"equals"}],operator:"and",_constructor:"AdvancedCriteria"}
              We'll look at the best way to automatically handle this in the framework. In the meantime, you could manually create an "equals" criterion from the inbound simple Criteria instead of using DSRequest.getAdvancedCriteria().

              Comment


                #8
                Originally posted by Isomorphic View Post
                Your logs do reveal that the inbound criteria end up corrupted as part of your attempt to transform them, note the array value for an "equals" validator.

                We'll look at the best way to automatically handle this in the framework. In the meantime, you could manually create an "equals" criterion from the inbound simple Criteria instead of using DSRequest.getAdvancedCriteria().
                Thank you. I cannot manually create an equals criterion from simple Criteria, because in my *real* application, different than in the simple test case, I have advancedCriteria very often, so I have to handle these cases with getAdvancedCriteria(). Only to call getCriteria() wouldn't work in these cases.

                Comment


                  #9
                  This case of faulty criteria conversion only comes up with simple Criteria so far as we know. Let us know if you think you've spotted another case.

                  Also, even if the criteria is advanced, you can use the AdvancedCriteria API to replace the faulty "equals" criteria that is array-valued.

                  Comment


                    #10
                    This issue has been fixed on 9.1p. The fix is available from today's build.

                    Regards,
                    Isomorphic Software

                    Comment


                      #11
                      Thanks, the fix works.

                      Comment

                      Working...
                      X