Hi,
These might prove to be the simplest questions ever... but I can't find any examples or find anything more in the documentation to help me along, so here goes.
Implemented my own "fetch" which is called from client. Works GREAT (wanted to stress this point)... however, I have doubt if the way I'm doing it is the best way of doing it?
1) It seems to me that I can do the same call easier via a custom operation as well. Is there a benefit of overriding fetch iso using a custom method?
2) I stored my methodArguments in the "payload" of the dsRequest, is this the best way to go or should I use the "param" map or "attributes"?
Thanx a lot!
I agree that my PoC included below isn't the best... but I added my code just in case anybody is interested ;-)
ds.xml
These might prove to be the simplest questions ever... but I can't find any examples or find anything more in the documentation to help me along, so here goes.
Implemented my own "fetch" which is called from client. Works GREAT (wanted to stress this point)... however, I have doubt if the way I'm doing it is the best way of doing it?
1) It seems to me that I can do the same call easier via a custom operation as well. Is there a benefit of overriding fetch iso using a custom method?
2) I stored my methodArguments in the "payload" of the dsRequest, is this the best way to go or should I use the "param" map or "attributes"?
Thanx a lot!
I agree that my PoC included below isn't the best... but I added my code just in case anybody is interested ;-)
ds.xml
Code:
... <operationBindings> <binding operationId="fetchOverloaded" operationType="fetch" serverMethod="fetchOverloaded" methodArguments="$dsRequest, $dsRequest.criteria.name" > <serverObject lookupStyle="new" className="server.stores.useraccount.LeasingCompanyStore"/> </binding> </operationBindings>
Code:
Button generateButton = new Button("Fetch overloaded"); generateButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { com.smartgwt.client.data.DataSource ds = com.smartgwt.client.data.DataSource.get("106"); JavaScriptObject arg = JSOHelper.createObject(); JSOHelper.setAttribute(arg, "name", "asCriteria"); DSRequest dsRequest = new DSRequest(); dsRequest.setOperationId("fetchOverloaded"); //dsRequest.setAttribute("name", "asAttribute"); //Map<String, String> params = new HashMap<String, String>(); //params.put( "name", "asParam"); //dsRequest.setParams(params); JavaScriptObject data = JSOHelper.createObject(); JSOHelper.setAttribute(data, "name", "asData"); dsRequest.setData(data); ds.fetchData(null, new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { RootPanel.get().add(new Label("Response = " + (String) rawData)); } }, dsRequest); } });
Comment