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

Best Practice For Sending Custom Parameters with a DSRequest

$
0
0
Hi Isomorphic

We currently use the SmartGWT LPGL version and are considering upgrading, I am currently reviewing the SmartGWTEE trial.

I have a question regarding the recommended approach for sending custom parameters to the server as part of a DSRequest.

We have a permissions system that allows a User Permission to be connected to multiple databases simultaneously. A user, for example, could have open two Bill Entry Activities both pointing to different customer databases. We therefore have a DatabaseHash String that is known on the client and needs to be sent back to the server with any DSRequest to identify which database the CRUD operation needs to be directed to.

I have attempted to achieve this with the following code
Code:

      RequestTransformer req = new RequestTransformer() {

        @Override
        protected Object transformRequest(DSRequest dsRequest) {
            //setAttribute
            dsRequest.setAttribute("databaseHash", "databaseHashAttribute");
           
            //set params
            Map<String, String> params = new HashMap<String, String>();
            params.put("databaseHash", "databaseHashAttributeParam");
            dsRequest.setParams(params);
           
            //set criteria
            Criteria criteria = new Criteria();
            criteria.addCriteria("databaseHash", "databaseHashAttributeCriteria");
            dsRequest.setCriteria(criteria);
           
            return super.getDefaultTransformRequest(dsRequest);
        }
      };
     
      dataSource = DataSource.getDataSource("bulkBillBatch", req, null);

The databasehash does not arrive on the server, either as an Attribute or Parameter. It does arrive as a Criteria but using Criteria is clearly a hack and would not be viable when sending back actual filter criteria.

What would be the best approach for sending it to the server? Having read the Quick Start guide this would suggest we could extend DataSource or use a custom servlet filter to intercept the HTTP Request.

Viewing all articles
Browse latest Browse all 4756

Trending Articles