All correct. However just to clarify, what you've just explained is the Java platform's definition of a Java Bean, not something we came up with.
Announcement
Collapse
No announcement yet.
X
-
Originally posted by Isomorphic...definition of a Java Bean, not something we came up with.
This is also what I was expecting to happen when when I started this thread and tried to figure out how to throw a bean into the response and have the platform send it back to the server (as a map or whatever). This all makes it much clearer (at least for me).
Thanks for the help.
Comment
-
Yes, we defined the .ds.XML format. However it is the Java platform that defines that a Java Bean's properties exist because of getter/setter pairs with a particular naming convention, and that given a getter/setter pair like getBlah() / setBlah(), the name of the property is considered to "blah" with a lowercase B.
Comment
-
Hi isomorphic,
I am trying to get JSON object from server using RPC manager. I am sending a Map(java.util.Map) from server using REST. Getting data as well on client side. But the issue is that I am unable to convert that data in Map or any other object at client side. Here is my code snipet:
Client side:
RPCRequest request = new RPCRequest();
request.setHttpMethod("GET");
request.setContentType("application/json");
request.setActionURL("/resource/cms/end-points");
request.setUseSimpleHttp(true);
RPCManager.sendRequest(request, new RPCCallback() {
@Override
public void execute(RPCResponse response, Object rawData, RPCRequest request) {
try {
// JavaScriptObject jso = response.getDataAsMap();
Map<String,String> map = response.getDataAsMap();
String msg = map.get("viewNewsUrl");
GWT.log(msg);
}
catch(Exception ex) {
GWT.log(ex.getLocalizedMessage());
GWT.log(ex.getMessage());
GWT.log(ex.toString());
}
}
});
Server side code is:
@Controller
@RequestMapping("/resource")
public class ResourceResolverController {
@RequestMapping(value="/cms/end-points", method = RequestMethod.GET, headers = "Accept="
+ MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, String> getCMSContentUrls(HttpServletRequest request, HttpServletResponse response) {
Map<String, String> cmsContentUrls = new LinkedHashMap<String, String>();
cmsContentUrls.put("viewNewsUrl", "some url");
cmsContentUrls.put("addNewsUrl", "some url");
cmsContentUrls.put("viewEventsUrl", "some url");
cmsContentUrls.put("addEventsUrl", "some url");
return cmsContentUrls;
}
}
Getting below exception:
convertToMap - unable to convert the passed JavaScript object to a Map. JavaScript is: "{"viewNewsUrl":"some url","addNewsUrl":"some url","viewEventsUrl":"some url","addEventsUrl":"some url"}"
SuperDevModeLogger.java:71 convertToMap - unable to convert the passed JavaScript object to a Map. JavaScript is: "{"viewNewsUrl":"some url","addNewsUrl":"some url","viewEventsUrl":"some url","addEventsUrl":"some url"}"
SuperDevModeLogger.java:71 java.lang.IllegalArgumentException: convertToMap - unable to convert the passed JavaScript object to a Map. JavaScript is: "{"viewNewsUrl":"some url","addNewsUrl":"some url","viewEventsUrl":"some url","addEventsUrl":"some url"}"
I have tried multiple ways to map data at client side like below:
JavaScriptObject jso = (JavaScriptObject)rawData; Map<String,String> map = (Map<String,String>)JSOHelper.convertToMap(jso);
Comment
-
Hi isomorphic,
What is the best approach to use global variables in smartgwt? I have some variables which should be loaded once globally and can be used later on as required. For more specifically, I have some configurable constants which are going to be retrieved from the server. I want to load these variables on page load in some global variables at smartgwt end use them later on. Can you suggest some approach with some example?
Regards
Ankul
Comment
-
Originally posted by ankulchoudhary View PostHi isomorphic,
What is the best approach to use global variables in smartgwt? I have some variables which should be loaded once globally and can be used later on as required. For more specifically, I have some configurable constants which are going to be retrieved from the server. I want to load these variables on page load in some global variables at smartgwt end use them later on. Can you suggest some approach with some example?
Regards
Ankul
In onModuleLoad:
Code:final SettingsCache sc = SettingsCache.getInstance(); sc.refresh(new RPCQueueCallback() { @Override public void execute(RPCResponse... response) { // Show tabs (depending on user grants) mainLayout = new MainLayout(); mainLayout.draw();
Code:public void refresh(final RPCQueueCallback rpcQueueCallback) { RPCManager.startQueue(); settingsAndDefaultsDS.fetchData(null, new DSCallback() { ... ... ...many requests... ...many requests... RPCManager.sendQueue(rpcQueueCallback); }
Best regards
Blama
Comment
Comment