Announcement
Collapse
No announcement yet.
X
-
Best practice is to introduce a field with customSQL="true" and use customFields to cause your additional field to appear in the SELECT and WHERE clauses for just the one operation. The problem is that you *also* tried to use customSelectExpression, and it did what it is documented to do.. but that defeats the purpose of the other two settings.
-
Hi Blama
removing customSQL and customFields, I get the same results. This makes sense, since these are only there to use the field with only one operationBinding. If I remove this, it does the same.
Yes, LOWER(null) just a replacement of the field with customSelectExpression, which is the definition of "customSelectExpression". So this seems right. But then customSelectExpression="null" does not work in the case you use the criteria in your operationBinding...
So-> Which is then the correct way to pass a value to the server ?
In my other thread I have 3 approaches (one of these is customSelectExpression="null"), none of which is working as I expected. I am waiting for Isomorphic 's response on this.
Leave a comment:
-
Hi edulid,
My usecase is a bit different. I only need this to transfer data to the serverside.- I do not use customSql, only customSelectExpression
- In my server side DMI I read the criteriaValue of that field
- I never execute the incoming dsRequest in my server DMI - I only need the data and do other requests (therefore I don't have the LOWER(null)='abc'-problem you are seeing
- I return the DSResponse from a handcrafted request
Your generated SQL does look OK to me. ((LOWER(null)='abc')) is your ($defaultWhereClause). And it's LOWER(null) because of your customSelectExpression and the request being ingnoreCase.
Best regards
Blama
Leave a comment:
-
Hi Blama
I made a simple test case with this approach, but something seems not to work well. Are you using customFields="FAKECOLUMN" in your operationBinding ?
Here my testcase:
1 Testcase:
Code:<DataSource ID="minimalTestcase" serverType="sql" tableName="minimalTestcase"> <fields> <field name="FAKECOLUMN" type="text" customSelectExpression="null" customSQL="true" /> <field name="f_id" type="integer" primaryKey="true" /> <field name="f_lastname" type="text" /> <field name="f_firstname" type="text" /> </fields> <operationBindings> <operationBinding operationType="fetch" customFields="FAKECOLUMN"> <whereClause><![CDATA[ $defaultWhereClause ]]></whereClause> </operationBinding> </operationBindings> </DataSource>The sql created:Code:public DSResponse doCallServer(DSRequest dsRequest, HttpServletResponse servletResponse, RPCManager rpcManager) throws Exception { System.out.println("doCallServer"); DSRequest fetchRequest = new DSRequest("minimalTestcase", DataSource.OP_FETCH, rpcManager); fetchRequest.setCriteria("FAKECOLUMN", "abc"); fetchRequest.execute(); return new DSResponse(); }
This sql seems incorrect. You are setting your criteria values with "setPickListCriteria(new AdvancedCriteria("FAKECOLUMN", OperatorId.NOT_EQUAL, valueToTransmit)))", but this should have the same effect ?Code:SELECT null AS FAKECOLUMN, minimalTestcase.f_id, minimalTestcase.f_lastname, minimalTestcase.f_firstname FROM minimalTestcase WHERE (LOWER(null)='abc')
2. Testcase:
If I change my operationBinding definition (leaving everything else exactly the same) to:
I get this sql:Code:<operationBinding operationType="fetch" customFields="FAKECOLUMN"> <whereClause><![CDATA[ $advancedCriteria.FAKECOLUMN = 'abc' and ($defaultWhereClause) ]]></whereClause> </operationBinding>
This sql will never return a row. But, since my criteria value is 'abc' and I compare this criteria value with 'abc', this should return columns... or ? Isomorphic is this a bug ?Code:SELECT null AS FAKECOLUMN, minimalTestcase.f_id, minimalTestcase.f_lastname, minimalTestcase.f_firstname FROM minimalTestcase WHERE 'abc' = 'abc' and ((LOWER(null)='abc'))
Using smartgwt 6.1p power 2018-03-28
Leave a comment:
-
If a change in this field changes what is returned from the server, then it is in fact criteria. There is also no reason to consider the field fake, since, although it is not persisted, it is a field used as criteria, and the field's type and other details potentially affect what the framework does with it, so that declaration is quite necessary.
Leave a comment:
-
Best practice: Have SelectItem or ComboBoxItem transport additional data to the server
Hi Isomorphic,
I have the requirement that a DataBound ComboBoxItem or SelectItem transfers additional data to the server with it's fetch request for the picklist.
That data will be used for DMIs that in the end return the request picklist data.
What's the suggested approach for this?
Right now, I'm using a fake DataSource field in my optionDataSource for this:
and add fake criteria to the item:Code:<field name="FAKECOLUMN" type="integer" customSelectExpression="null" />
In the serverside I get the criteria viaCode:setPickListCriteria(new AdvancedCriteria("FAKECOLUMN", OperatorId.NOT_EQUAL, valueToTransmit)))
Code:request.getCriteriaValue("FAKECOLUMN")
This works, but is this really the best approach?
Thank you & Best regards
BlamaTags: None
Leave a comment: