Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array in @ExtDirectMethod #49

Closed
salamoun opened this issue Nov 20, 2012 · 11 comments
Closed

Array in @ExtDirectMethod #49

salamoun opened this issue Nov 20, 2012 · 11 comments

Comments

@salamoun
Copy link

Is it possible to send array over simple named method??
For example:

@ExtDirectMethod(ExtDirectMethodType.SIMPLE_NAMED)
public void sendSomeData(List objects, int someId) {
...
}

@ralscha
Copy link
Owner

ralscha commented Nov 20, 2012

Hi

Yes it looks like it works. I made a quick test with this client code:

var values = {
aLotOfStrings: ['a', 'b', 'c'],
firstName: 'first',
lastName: 'last',
age: 27
};
namedService.showDetails(values, function(value){
Ext.example.msg('Server Response', value);
});

and this server code:

@ExtDirectMethod(value = ExtDirectMethodType.SIMPLE_NAMED, group = "named")
public String showDetails(List aLotOfStrings, String firstName,
String lastName, int age) {
for (String string : aLotOfStrings) {
System.out.println(string);
}
return String.format("Hi %s %s, you are %d years old.", firstName,
lastName, age);
}

Ralph

On Tue, Nov 20, 2012 at 1:38 PM, salamoun notifications@github.com wrote:

Is it possible to send array over simple named method??
For example:

@ExtDirectMethod(ExtDirectMethodType.SIMPLE_NAMED)
public void sendSomeData(List objects, int someId) {
...
}


Reply to this email directly or view it on GitHubhttps://github.com//issues/49.

@salamoun
Copy link
Author

OK, but I'm not sending array of string. I have array of bussines objects.

var myObjects = [{id:1,name:'test'},{id:2,name:'test2}];

Is it possible too? Because I got spring conversion error in this case.

@ralscha
Copy link
Owner

ralscha commented Nov 20, 2012

Here the missing stacktrace:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.LinkedHashMap to type ch.rasc.extdirectspring.demo.named.Business
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:276) ~[spring-core-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:172) ~[spring-core-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.core.convert.support.CollectionToCollectionConverter.convert(CollectionToCollectionConverter.java:74) ~[spring-core-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35) ~[spring-core-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:169) ~[spring-core-3.2.0.RC1.jar:3.2.0.RC1]
at ch.ralscha.extdirectspring.util.ParametersResolver.convertValue(ParametersResolver.java:241) ~[classes/:na]
at ch.ralscha.extdirectspring.util.ParametersResolver.resolveParameters(ParametersResolver.java:169) ~[classes/:na]
at ch.ralscha.extdirectspring.controller.RouterController.processRemotingRequest(RouterController.java:556) [classes/:na]
at ch.ralscha.extdirectspring.controller.RouterController.handleMethodCall(RouterController.java:462) [classes/:na]
at ch.ralscha.extdirectspring.controller.RouterController.handleMethodCallsSequential(RouterController.java:442) [classes/:na]
at ch.ralscha.extdirectspring.controller.RouterController.router(RouterController.java:393) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_09]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_09]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_09]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_09]
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219) [spring-web-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) [spring-web-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:917) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:824) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:798) [spring-webmvc-3.2.0.RC1.jar:3.2.0.RC1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) [spring-web-3.2.0.RC1.jar:3.2.0.RC1]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-3.2.0.RC1.jar:3.2.0.RC1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176) [urlrewritefilter-3.2.0.jar:3.2.0]
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145) [urlrewritefilter-3.2.0.jar:3.2.0]
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92) [urlrewritefilter-3.2.0.jar:3.2.0]
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381) [urlrewritefilter-3.2.0.jar:3.2.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585) [tomcat-embed-core-7.0.32.jar:7.0.32]
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) [tomcat-embed-core-7.0.32.jar:7.0.32]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_09]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_09]
at java.lang.Thread.run(Thread.java:722) [na:1.7.0_09]

@salamoun
Copy link
Author

yes, i get exactly same error

@ralscha
Copy link
Owner

ralscha commented Nov 20, 2012

Found a solution that works with my simple test case. I try and integrate the fix into the 'next' branch (1.2.3-SNAPSHOT) tomorrow. I keep you posted.

@salamoun
Copy link
Author

OK, thanks for help.

@ralscha
Copy link
Owner

ralscha commented Nov 21, 2012

Fix is now integrated in the lastest 1.2.3-SNAPSHOT Release.
https://oss.sonatype.org/content/repositories/snapshots/ch/ralscha/extdirectspring/1.2.3-SNAPSHOT/extdirectspring-1.2.3-20121121.035026-8.jar

Maybe you have time and test this release with your program.
If all goes planned I will release the 1.2.3 version end of November.

It's important that the business object has a default constructor. The jackson library needs this to deserialize the object. The method also has to use generics:
public void sendSomeData(List<BusinessObject> objects, int someId) {

If the method only has a raw list as parameter it will work but the list then contains a map with String key and Object values.
public void sendSomeData(List objects, int someId) {

@salamoun
Copy link
Author

I test it and now works perfect with 1.2.3 version!

But it has side effect. I previously use version 1.1.1. When I switch to 1.2.3 I must update all my JSON annotations on business object, otherwise they were ignored.
From import org.codehaus.jackson.annotate.* to import com.fasterxml.jackson.annotation.*.
New versions of extdirectspring use com.fasterxml.jackson serialiazer?? Or I'm doing something wrong?

@ralscha
Copy link
Owner

ralscha commented Nov 21, 2012

Hi

We switched to Jackson 2 in version 1.2.0 and they changed the package
structure.
Is this a problem in your project? If yes I could try and add this fix in
version 1.1.x

Ralph

On Wed, Nov 21, 2012 at 10:53 AM, salamoun notifications@github.com wrote:

I test it and now works perfect with 1.2.3 version!

But it has side effect. I previously use version 1.1.1. When I switch to
1.2.3 I must update all my JSON annotations on business object, otherwise
they were ignored.
From import org.codehaus.jackson.annotate.* to import
com.fasterxml.jackson.annotation.*.
New versions of extdirectspring use com.fasterxml.jackson serialiazer?? Or
I'm doing something wrong?


Reply to this email directly or view it on GitHubhttps://github.com//issues/49#issuecomment-10591036.

@salamoun
Copy link
Author

No, I change import to new packages and all code works fine. Thanks!

@ralscha
Copy link
Owner

ralscha commented Nov 30, 2012

Version 1.2.3 released

@ralscha ralscha closed this as completed Nov 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants