Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

MultiComboBoxItem not working with extended DataSource

$
0
0
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.

Viewing all articles
Browse latest Browse all 4756

Trending Articles