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

ListGrid custom Datasource executeUpdate fails but edit is still visible on Grid

$
0
0
Hi,
we use SmartClient Version: v9.1p_2014-03-25/Enterprise Deployment (built 2014-03-25), though the dev console shows the smartclient, we use smartgwtee 4.1.

browser version - firefox 26.0

We have a listGrid bound to a custom Datasource which is populated from the results of a WebService.

The grid has only one boolean field editable.
Code:

grid = (ListGrid) screen.getByLocalId("GridCompBuilds");
                grid.setDataSource(ds);
                               
                ListGridField archiveFlag = grid.getField("componentArchiveFlag");
                archiveFlag.setCanEdit(true);
                archiveFlag.addCellSavedHandler(new CellSavedHandler() {
                       
                        @Override
                        public void onCellSaved(CellSavedEvent event) {
                                grid.invalidateCache();                               
                        }
                });

ds.xml file
Code:

<DataSource ID="ComponentBuildsList"
        serverConstructor="com.eterra.tdm.ui.wiring.CdiDataSourceDelegate">
        <fields>
                <field name="componentBuildId" type="integer" title="ID" primaryKey="true"/>               
                <field name="componentGroupName" type="text" title="GROUP" />
                <field name="componentTypeCode" type="text" title="TYPE" />
                <field name="componentName" type="text" title="NAME" />
                <field name="componentVersion" type="text" title="VERSION" />
                <field name="buildNumber" type="integer" title="SNAPSHOT #" />
                <field name="lastUpdateDate" type="datetime" title="LAST UPDATE" />
                <field name="updatedBy" type="text" title="UPDATED BY" />
                <field name="lastUpdatejobId" type="integer" title="LAST JOB ID" />       
                <field name="processName" type="text" title="LAST PROCESS" />
                <field name="componentId" type="integer" title="COMPONENT ID" hidden="true" />
                <field name="componentDescription" type="text" title="COMPONENT DESCRIPTION" />
                <field name="componentArchiveFlag" type="boolean" title="ARCHIVE"/>
        </fields>
</DataSource>

When I click the check-box on the UI, an executeupdate action happens. the request is handled by the webservice.

Code:

@Override
        @SuppressWarnings("unchecked")
        public DSResponse executeUpdate(DSRequest req) throws Exception {
               
                DSResponse resp = new DSResponse(DSResponse.STATUS_SUCCESS);
               
                Map<String, Object> values = req.getValues();
                Map<String, Object> oldvalues = req.getOldValues();               
               
                deploymentService.archive(ArchiveTarget.COMPONENT_BUILD,
                                (Long)values.get("componentBuildId"),
                                (Boolean)values.get("componentArchiveFlag") ? ArchiveAction.ARCHIVE
                                                                                                                        : ArchiveAction.UNARCHIVE);
                oldvalues.put("componentArchiveFlag",values.get("componentArchiveFlag"));                                                                               
               
                resp.setData(oldvalues);
                return resp;               
        }

On successful update there is no problem.

when update fails the exception is handled in superclass
Code:

private DSResponse handleError(Throwable aThrowable, Locale clientLocale) {

                if (clientLocale == null) {
                        clientLocale = Locale.getDefault();
                }
                String uiMessage = TdmServiceErrorHelper.getDetailErrorMessage(aThrowable, clientLocale);

                // We need a response with failure.
                DSResponse response = new DSResponse(DSResponse.STATUS_FAILURE);

                response.setFailure(uiMessage);

                return response;
        }


But if update fails, DSREsponse is set to failure.

But the edit is still cashed locally on clientSide. How do i rollback the clientSide edit?

Viewing all articles
Browse latest Browse all 4756

Trending Articles