Hi Isomorphic,
there is a big difference between how IDACall and RESTHandler handle fetches for DataSources with field with multiple="true".
For RESTHandler, the field is repeated n times, every time with a different value.
For IDACall, you get an arry like EmployeeStatus:[
"active",
"terminated",
"LOA"
]
Please see this testcase (v12.0p_2019-02-21):
BuiltInDS.java:
employees..ds.xml:
Start the testcase an change Abigail Meyler to have all three EmployeeStatus-values. Then send this ARC request (if using Chrome)
ARC Request:
Response:
I'm pretty sure that this is not on purpose, although I don't have any docs on this.
Also, <queueStatus>0</queueStatus> is there in the response twice again (regression).
Best regards
Blama
there is a big difference between how IDACall and RESTHandler handle fetches for DataSources with field with multiple="true".
For RESTHandler, the field is repeated n times, every time with a different value.
For IDACall, you get an arry like EmployeeStatus:[
"active",
"terminated",
"LOA"
]
Please see this testcase (v12.0p_2019-02-21):
BuiltInDS.java:
Code:
package com.smartgwt.sample.client;
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.Version;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.data.AdvancedCriteria;
import com.smartgwt.client.data.Criterion;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.SortSpecifier;
import com.smartgwt.client.types.OperatorId;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.PageKeyHandler;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.IButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;
public class BuiltInDS implements EntryPoint {
private VLayout mainLayout;
public void onModuleLoad() {
KeyIdentifier debugKey = new KeyIdentifier();
debugKey.setCtrlKey(true);
debugKey.setKeyName("D");
Page.registerKey(debugKey, new PageKeyHandler() {
public void execute(String keyName) {
SC.showConsole();
}
});
mainLayout = new VLayout(20);
mainLayout.setWidth100();
mainLayout.setHeight100();
{
IButton recreateBtn = new IButton("Recreate fetchBadNoVelocityException");
recreateBtn.setWidth(250);
recreateBtn.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
recreate();
}
});
mainLayout.addMember(recreateBtn);
}
mainLayout.draw();
recreate();
}
private void recreate() {
Window w = new Window();
w.setWidth("95%");
w.setHeight("95%");
w.setMembersMargin(0);
w.setModalMaskOpacity(70);
w.setTitle(" (" + Version.getVersion() + "/" + Version.getSCVersionNumber() + ")");
w.setTitle("Problem with Velocity and .ds.xml RequestModifier" + w.getTitle());
w.setShowMinimizeButton(false);
w.setIsModal(true);
w.setShowModalMask(true);
w.centerInPage();
final ListGrid employeesGrid = new ListGrid();
employeesGrid.setCanEdit(true);
employeesGrid.setHeight100();
employeesGrid.setAutoFetchData(false);
employeesGrid.setDataSource(DataSource.get("employees"));
ListGridField employeeId = new ListGridField("EmployeeId");
ListGridField name = new ListGridField("Name");
ListGridField gender = new ListGridField("Gender");
ListGridField job = new ListGridField("Job");
ListGridField employeeStatus = new ListGridField("EmployeeStatus");
employeesGrid.setFields(employeeId, name, gender, job, employeeStatus);
employeesGrid.setSort(new SortSpecifier[] { new SortSpecifier(name.getName(), SortDirection.ASCENDING) });
employeesGrid.fetchData(new AdvancedCriteria(new Criterion(name.getName(), OperatorId.LESS_OR_EQUAL, "L")));
w.addItem(employeesGrid);
w.show();
}
}
Code:
<DataSource
ID="employees"
serverType="sql"
tableName="employeeTable"
recordName="employee"
testFileName="/examples/shared/ds/test_data/employees.data.xml"
titleField="Name"
>
<fields>
<field name="userOrder" title="userOrder" type="integer" canEdit="false" hidden="true"/>
<field name="Name" title="Name" type="text" length="128"/>
<field name="EmployeeId" title="Employee ID" type="integer" primaryKey="true" required="true"/>
<field name="ReportsTo" title="Manager" type="integer" required="true"
foreignKey="employees.EmployeeId" rootValue="1" detail="true"/>
<field name="Job" title="Title" type="text" length="128"/>
<field name="Email" title="Email" type="text" length="128"/>
<field name="EmployeeType" title="Employee Type" type="text" length="40"/>
<field name="EmployeeStatus" title="Status" type="text" multiple="true" length="40">
<valueMap>
<value>active</value>
<value>terminated</value>
<value>LOA</value>
</valueMap>
</field>
<field name="Salary" title="Salary" type="float"/>
<field name="OrgUnit" title="Org Unit" type="text" length="128"/>
<field name="Gender" title="Gender" type="text" length="7">
<valueMap>
<value>male</value>
<value>female</value>
</valueMap>
</field>
<field name="MaritalStatus" title="Marital Status" type="text" length="10">
<valueMap>
<value>married</value>
<value>single</value>
</valueMap>
</field>
</fields>
</DataSource>
ARC Request:
Code:
Post URL: http://127.0.0.1:8888/builtinds/sc/RESTHandler
Body:
<request>
<dataSource>employees</dataSource>
<operationType>fetch</operationType>
<data>
<EmployeeId>222</EmployeeId>
</data>
</request>
Code:
<?xml version="1.0" ?> <response> <status> 0 </status> <queueStatus> 0 </queueStatus> <startRow> 0 </startRow> <endRow> 1 </endRow> <totalRows> 1 </totalRows> <queueStatus> 0 </queueStatus> <data> <record> <OrgUnit> Management </OrgUnit> <Salary> 7400.0 </Salary> <MaritalStatus> single </MaritalStatus> <Email> ameyler@server.com </Email> [B]<EmployeeStatus> active </EmployeeStatus> <EmployeeStatus> terminated </EmployeeStatus> <EmployeeStatus> LOA </EmployeeStatus>[/B] <userOrder> 83 </userOrder> <ReportsTo> 185 </ReportsTo> <Gender> female </Gender> <EmployeeId> 222 </EmployeeId> <Job> Dir Mat Mgmt Admin </Job> <Name> Abigail Meyler </Name> <EmployeeType> part time </EmployeeType> </record> </data> </response>
Also, <queueStatus>0</queueStatus> is there in the response twice again (regression).
Best regards
Blama
Comment