SmartClient Version: v10.1p_2016-12-11/Enterprise Deployment (built 2016-12-11)
Chrome Version 64.0.3282.167
I have a rather complicated screen I'm building. I have a VLayout with 2 ToolStrips and 2 ListGrids:
Both the parent object grid and child object grid are backed by ds.xml files. The parent object has foreignKey relationships that should populate SelectItems for those fields with the names of other objects in the database. I've excluded the child.ds.xml file because for now I've decoupled it from the parent grid until my issue is resolved. I've modified the names of attributes/files for company privacy:
The ds.xml for the objectA field:
The remaining "object*List" files are all identical (replacing their letter with * for brevity):
Each ds.xml file has operationBindings that point to a .java file that calls load/create/delete/update methods in an EJB.
Currently, if I remove all the foreignKey/includeFrom connections in my ds.xml files, I can select from/to dates in my ToolStrip and hit the "refresh" button. The ClickHandler for my "refresh" button calls discardAllEdits() on the parent grid, then sets the criteria on the grid to the selected from/to dates ("startDate" and "endDate" respectively), then calls refreshData() on the parent grid:
This successfully populates/repopulates the parent object grid with records whose startDate attributes are between the selected from/to dates, but without the SelectItems since there's no foreignKey/includeFrom relationships. Clicking on a parent object record will display child records in the 2nd grid.
However, if I have all the foreignKey/includeFrom connections in-place in my ds.xml files, selecting the from/to dates and hitting refresh displays no records. In Eclipse, I set debug points in my fetch method for the parent objects, and I can see that records are being retrieved from the database, the same as they were without the foreignKey/includeFrom, but once they are put into the DSResponse and returned, nothing shows up on the grid. The RPC tab of the developer console now shows no data returned in the RPC Response.
Parent Object Fetch Method:
As stated above, when debugging in Eclipse I can see that the objects Collection gets all of the objects from the database, loaded the same way it did without the foreignKey/includeFrom relationships, with each object's attributes mapped to their values. When the data is sent to the screen it is lost somewhere.
As a test case, I accessed some of the parent object records in the database directly and modified their startDate and endDate attributes to the current day because the server method sets the range of dates to load to the current day by default if the RelativeDateItems on the screen were unchanged. Doing this caused the modified records to be displayed when the screen was loaded since there was no date criteria sent from the screen. Hitting refresh at this point made the records disappear. The only difference I've noticed in Developer Console is that on screen initialization the startDate and endDate from the ToolStrip are null/un-set, so the fetch method sets the date range itself. When hitting the refresh button, the "startDate" and "endDate" criteria are sent as params with the long value of the dates selected.
The most puzzling thing to me is that the grid will populate, refresh, etc just fine without the foreignKeys setup in the ds.xml, but adding the foreignKey relationshipe causes the date range criteria to display nothing on fetch or refresh.
Is there some aspect of this process that I'm overlooking or misunderstanding? I thought that passing my RelativeDateItems' dates into my fetch or refresh as Criteria would just transmit those values to the backend for use in loading/processing, but it seems they're preventing records from being shown.
Chrome Version 64.0.3282.167
I have a rather complicated screen I'm building. I have a VLayout with 2 ToolStrips and 2 ListGrids:
- The top ListGrid is populated with parent objects
- The bottom ListGrid is populated with 0 to many child objects for a selected parent object
- The 1st ToolStrip has buttons for refresh, save, and add for parent objects, as well as a DynamicForm with 2 RelativeDateItems for loading parent objects within the range of specified dates
- The 2nd ToolStrip has buttons for refresh, save, and add for child objects of the selected parent object.
Both the parent object grid and child object grid are backed by ds.xml files. The parent object has foreignKey relationships that should populate SelectItems for those fields with the names of other objects in the database. I've excluded the child.ds.xml file because for now I've decoupled it from the parent grid until my issue is resolved. I've modified the names of attributes/files for company privacy:
Code:
<DataSource ID="parentObject" allowAdvancedCriteria="true"> <fields> <field name="objecttKey" title="Object Key" primaryKey="true" hidden="true" type="integer" canEdit="false"/> <field name="objectName" title="Full Name" hidden="false" type="text" detail="true" canEdit="true"/> <field name="objectShortName" title="Short Name" hidden="false" type="text" detail="true" canEdit="true"/> <field name="startDate" title="Start Date" hidden="false" type="datetime" canEdit="true" required="true"/> <field name="endDate" title="End Date" hidden="false" type="datetime" canEdit="true" required="true"/> <field name="description" title="Description" hidden="false" type="text" detail="true" canEdit="true"/> <field name="status" title="Status" hidden="false" type="text" canEdit="true"> <valueMap> <value id="N">New</value> <value id="O">Open</value> <value id="F">Final</value> </valueMap> </field> <field name="locked" title="Locked" hidden="false" type="boolean" detail="true" canEdit="true"/> <field name="objectAKey" title="Object A" hidden="false" type="integer" canEdit="true" nillable="true" foreignKey="objectA.objectAKey" displayField="objectAName" useLocalDisplayFieldValue="true"/> <field name="objectBKey" title="Object B" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectBList.key" displayField="objectB" useLocalDisplayFieldValue="true"/> <field name="objectCKey" title="Object C" hidden="false" type="integer" canEdit="true" nillable="true" foreignKey="objectCList.key" displayField="objectC" useLocalDisplayFieldValue="true"/> <field name="objectDKey" title="Object D" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objecetDList.key" displayField="objectD" useLocalDisplayFieldValue="true"/> <field name="objectEKey" title="Object E" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectEList.key" displayField="objectE" useLocalDisplayFieldValue="true"/> <field name="objectFKey" title="Object F" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectFList.key" displayField="objectF" useLocalDisplayFieldValue="true"/> <field name="objectGKey" title="Object G" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectGList.key" displayField="objectG" useLocalDisplayFieldValue="true"/> <field name="percent" title="%" hidden="false" type="float" detail="true" canEdit="true"/> <field name="loss" title="Loss" hidden="false" type="float" canEdit="true"/> <field name="rate" title="Rate" hidden="false" type="localeCurrency" detail="true" canEdit="true"/> <field name="Amount" title="Amount" hidden="false" type="localeCurrency" canEdit="true"/> <field name="objectHKey" title="Object H" hidden="false" type="integer" canEdit="true" nillable="true" foreignKey="objectHList.key" displayField="objectH" useLocalDisplayFieldValue="true"/> <field name="objectIKey" title="Object I" hidden="false" type="integer" canEdit="true" nillable="true" foreignKey="objectIList.key" displayField="objectI" useLocalDisplayFieldValue="true"/> <field name="buyDealKey" title="Buy Deal" hidden="false" type="integer" detail="true" canEdit="false"/> <field name="buyDealTermKey" title="Buy Deal Term" hidden="false" type="integer" detail="true" canEdit="false"/> <field name="sellDealKey" title="Sell Deal" hidden="false" type="integer" detail="true" canEdit="false"/> <field name="sellDealTermKey" title="Sell Deal Term" hidden="false" type="integer" detail="true" canEdit="false"/> <field name="objectJKey" title="Object J" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectJList.key" displayField="objectJ" useLocalDisplayFieldValue="true"/> <field name="objectKKey" title="Object K" hidden="false" type="integer" detail="true" canEdit="true" nillable="true" foreignKey="objectKList.key" displayField="objectK" useLocalDisplayFieldValue="true"/> <field name="volumeOne" title="Vol. 1" hidden="false" type="float" canEdit="true"/> <field name="volumeTwo" title="Vol. 2" hidden="false" type="float" canEdit="true"/> <field name="createdOn" hidden="true" title="" type="datetime" canEdit="false"/> <field name="createdBy" hidden="true" title="" type="text" canEdit="false"/> <field name="modifiedOn" hidden="true" title="" type="datetime" canEdit="false"/> <field name="modifiedBy" hidden="true" title="" type="text" canEdit="false"/> <field name="objectAName" includeFrom="objectA.name" hidden="true"/> <field name="objectB" includeFrom="objectBList.name" hidden="true"/> <field name="objectC" includeFrom="objectCList.name" hidden="true"/> <field name="objectD" includeFrom="objectDList.name" hidden="true"/> <field name="objectE" includeFrom="objectEList.name" hidden="true"/> <field name="objectF" includeFrom="objectFList.name" hidden="true"/> <field name="objectG" includeFrom="objectGList.name" hidden="true"/> <field name="objectH" includeFrom="objectHList.name" hidden="true"/> <field name="objectI" includeFrom="objectIList.name" hidden="true"/> <field name="objectJ" includeFrom="objectJList.name" hidden="true"/> <field name="objectK" includeFrom="objectKList.name" hidden="true"/> </fields> <operationBindings> <binding operationType="fetch" serverMethod="executeFetchData"> <serverObject className="com.server.objects.ObjectDS"/> </binding> <binding operationType="add" serverMethod="executeAddData"> <serverObject className="com.server.objects.ObjectDS"/> </binding> <binding operationType="update" serverMethod="executeUpdateData"> <serverObject className="com.server.objects.ObjectDS"/> </binding> <binding operationType="remove" serverMethod="executeRemoveData"> <serverObject className="com.server.objects.ObjectDS"/> </binding> </operationBindings> </DataSource>
Code:
<DataSource ID="objectA" allowAdvancedCriteria="true"> <fields> <field name="objectKey" hidden="true" title="Key" type="integer" primaryKey="true"/> <field name="name" hidden="false" title="Pipeline Name" type="text" width="20%" canEdit="true" required="true"/> <field name="shortName" hidden="false" title="Short Name" type="text" width="20%" canEdit="true"/> <field name="description" hidden="false" title="Description" type="text" width="30%" canEdit="true"/> <field name="objectType" hidden="false" title="Object Type" type="text" width="10%" canEdit="true" required="true"/> <field name="modifiedOn" hidden="true" title="Modified On" type="datetime" width="130" canEdit="false"/> <field name="modifiedBy" hidden="true" title="Modified By" type="text" width="130" canEdit="false"/> <field name="createdOn" hidden="true" title="Created On" type="datetime" width="130" canEdit="false"/> <field name="createdBy" hidden="true" title="Created By" type="text" width="130" canEdit="false"/> </fields> <operationBindings> <binding operationType="fetch" serverMethod="executeFetchData"> <serverObject className="com.server.objects.ObjectADS" /> </binding> <binding operationType="add" serverMethod="executeAddData"> <serverObject className="com.server.objects.ObjectADS" /> </binding> <binding operationType="update" serverMethod="executeUpdateData"> <serverObject className="com.server.objects.ObjectADS" /> </binding> <binding operationType="remove" serverMethod="executeRemoveData"> <serverObject className="com.server.objects.ObjectADS" /> </binding> </operationBindings> </DataSource>
Code:
<DataSource ID="object*List" allowAdvancedCriteria="true"> <fields> <field name="key" title="Key" primaryKey="true" hidden="true" type="integer" canEdit="false" required="true"/> <field name="name" title="Name" hidden="false" type="text" canEdit="true"/> </fields> <operationBindings> <binding operationType="fetch" serverMethod="executeFetchBooks"> <serverObject className="com.server.objects.Object*DS"/> </binding> </operationBindings> </DataSource>
Each ds.xml file has operationBindings that point to a .java file that calls load/create/delete/update methods in an EJB.
Currently, if I remove all the foreignKey/includeFrom connections in my ds.xml files, I can select from/to dates in my ToolStrip and hit the "refresh" button. The ClickHandler for my "refresh" button calls discardAllEdits() on the parent grid, then sets the criteria on the grid to the selected from/to dates ("startDate" and "endDate" respectively), then calls refreshData() on the parent grid:
Code:
this.discardAllEdits(); Criteria criteria = screen.getDateCriteria(); //gets the from and to dates from the ToolStrip and sets them as {"startDate", long time of startDate} and {"endDate", long time of endDate} in criteria this.setCriteria(criteria); this.refreshData();
However, if I have all the foreignKey/includeFrom connections in-place in my ds.xml files, selecting the from/to dates and hitting refresh displays no records. In Eclipse, I set debug points in my fetch method for the parent objects, and I can see that records are being retrieved from the database, the same as they were without the foreignKey/includeFrom, but once they are put into the DSResponse and returned, nothing shows up on the grid. The RPC tab of the developer console now shows no data returned in the RPC Response.
Parent Object Fetch Method:
Code:
public final DSResponse executeFetchData(final Map<String, Object> params, final DSRequest request, final HttpServletRequest httpRequest) { //Instantiate EJB as "EJB" final Date startDate = params.get("startDate") != null ? new Date(Long.parseLong((String) params.get("startDate"))) : new Date()); final Date endDate = params.get("endDate") != null ? new Date(Long.parseLong((String) params.get("endDate"))) : new Date(); final Collection<Map<String, Object>> objects = Arrays.stream(EJB.getAll(startDate, endDate)).map(s -> s.asMap()).collect(Collectors.toList()); //loads records from DB and maps their attributes/values reflectively DSResponse response = new DSResponse(objects); response.setStartRow(0); response.setEndRow(objects.size()); response.setTotalRows(objects.size()); return response; }
As a test case, I accessed some of the parent object records in the database directly and modified their startDate and endDate attributes to the current day because the server method sets the range of dates to load to the current day by default if the RelativeDateItems on the screen were unchanged. Doing this caused the modified records to be displayed when the screen was loaded since there was no date criteria sent from the screen. Hitting refresh at this point made the records disappear. The only difference I've noticed in Developer Console is that on screen initialization the startDate and endDate from the ToolStrip are null/un-set, so the fetch method sets the date range itself. When hitting the refresh button, the "startDate" and "endDate" criteria are sent as params with the long value of the dates selected.
The most puzzling thing to me is that the grid will populate, refresh, etc just fine without the foreignKeys setup in the ds.xml, but adding the foreignKey relationshipe causes the date range criteria to display nothing on fetch or refresh.
Is there some aspect of this process that I'm overlooking or misunderstanding? I thought that passing my RelativeDateItems' dates into my fetch or refresh as Criteria would just transmit those values to the backend for use in loading/processing, but it seems they're preventing records from being shown.
Comment