I'm using a RequestTransformer to add HTTP params to my DSRequests for a grid, which works fine unless the criteria of the request is the result of combining two AdvancedCriteria objects. In this case, the RequestTransformer discards the "_constructor" marker of one of the original AdvancedCriteria objects - which results in a garbage criteria when combined again. I've posted a test case below that reproduces the issue. The first request looks fine - but the 2nd (and later ) request(s) have a garbage criteria.
I've tried replacing the:
return dsRequest.getCriteria().getJsObj();
line with:
return getDefaultTransformRequest(dsRequest);
- the result is the same.
I'm using the 09/15 nightly build: SmartClient Version: SNAPSHOT_v9.1d_2013-09-15/PowerEdition Deployment (built 2013-09-15) - behavior seems to be browser independent, though I've confirmed with FF17 and Chrome.
thanks,
dan
Code:
VLayout layout = new VLayout(); layout.setWidth("100%"); final Criteria crit1 = new AdvancedCriteria(OperatorId.AND, new Criterion[] { new Criterion("field1", OperatorId.EQUALS, "value1"), new Criterion("field2", OperatorId.EQUALS, "value2") }); Criteria crit2 = new AdvancedCriteria(OperatorId.AND, new Criterion[] { new Criterion("field3", OperatorId.EQUALS, "value3"), new Criterion("field4", OperatorId.EQUALS, "value4") }); Criteria crit3 = new AdvancedCriteria(OperatorId.AND, new Criterion[] { new Criterion("field5", OperatorId.EQUALS, "value5"), new Criterion("field6", OperatorId.IN_SET, new String[] { "value4", "value8", "value9" }) }); final DataSource ds = DataSource.get("loadData"); final DynamicForm form = new DynamicForm(); SpinnerItem spinner1 = new SpinnerItem("fieldN"); SpinnerItem spinner2 = new SpinnerItem("fieldM"); SelectItem si = new SelectItem("fieldZ"); si.setValueMap("v1", "v2", "v3", "v4", "v5"); si.setMultiple(true); form.setFields(spinner1, spinner2, si); spinner1.setValue(0); spinner2.setValue(0); final Label label1 = new Label(); label1.setContents("Adjust form to combine criteria..."); final ListGrid test = new ListGrid(); test.setDataSource(DataSource.get("loadData", new RequestTransformer() { @Override protected Object transformRequest(DSRequest dsRequest) { // TODO Auto-generated method stub Map params = new HashMap(); params.put("test", "test_param"); dsRequest.setParams(params); return dsRequest.getCriteria().getJsObj(); } }, null)); form.addItemChangedHandler(new ItemChangedHandler() { @Override public void onItemChanged(ItemChangedEvent event) { AdvancedCriteria tmp = new AdvancedCriteria(OperatorId.AND, new Criterion[] { crit1.asAdvancedCriteria(), form.getValuesAsAdvancedCriteria() }); label1.setContents(JSON.encode(tmp.getJsObj())); test.fetchData(tmp); } }); layout.setMembers(form, test, label1); layout.draw();
return dsRequest.getCriteria().getJsObj();
line with:
return getDefaultTransformRequest(dsRequest);
- the result is the same.
I'm using the 09/15 nightly build: SmartClient Version: SNAPSHOT_v9.1d_2013-09-15/PowerEdition Deployment (built 2013-09-15) - behavior seems to be browser independent, though I've confirmed with FF17 and Chrome.
thanks,
dan
Comment